Skip to content

Commit

Permalink
fixup! review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
vicb committed Jan 28, 2025
1 parent 6ef1a42 commit 1dd114d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ rule:
pattern: $MOD
kind: string_fragment
stopBy: end
regex: ^caniuse-lite(/|$)|jimp(/|$)|probe-image-size(/|$)
regex: ^(caniuse-lite|jimp|probe-image-size)(/|$)
not:
inside:
kind: try_statement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export default function inlineRequirePagePlugin(buildOpts: BuildOptions) {
}

function getRule(buildOpts: BuildOptions) {
// Load manifests
const { outputDir } = buildOpts;
const serverDir = join(outputDir, "server-functions/default", getPackagePath(buildOpts), ".next/server");

Expand All @@ -47,6 +46,7 @@ function getRule(buildOpts: BuildOptions) {
const htmlFiles = manifests.filter((file) => file.endsWith(".html"));
const jsFiles = manifests.filter((file) => file.endsWith(".js"));

// Inline fs access and dynamic require that are not supported ny workerd.
const fnBody = `
// html
${htmlFiles
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
/**
* Makes files handled by wrangler external.
* ESBuild plugin to mark files bundled by wrangler as external.
*
* Paths need to be absolute so that they are valid in the output bundle.
* `.wasm` and `.bin` will ultimately be bundled by wrangler.
* We should only mark them as external in the adapter.
*
* However simply marking them as external would copy the import path to the bundle,
* i.e. `import("./file.wasm?module")` and given than the bundle is generated in a
* different location than the input files, the relative path would not be valid.
*
* This ESBuild plugin convert relative paths to absolute paths so that they are
* still valid from inside the bundle.
*
* ref: https://developers.cloudflare.com/workers/wrangler/bundling/
*/

import { dirname, resolve } from "node:path";
Expand Down

0 comments on commit 1dd114d

Please sign in to comment.