Skip to content

Commit 1dd114d

Browse files
committed
fixup! review feedback
1 parent 6ef1a42 commit 1dd114d

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

packages/cloudflare/src/cli/build/patches/ast/optional-deps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ rule:
1616
pattern: $MOD
1717
kind: string_fragment
1818
stopBy: end
19-
regex: ^caniuse-lite(/|$)|jimp(/|$)|probe-image-size(/|$)
19+
regex: ^(caniuse-lite|jimp|probe-image-size)(/|$)
2020
not:
2121
inside:
2222
kind: try_statement

packages/cloudflare/src/cli/build/patches/plugins/require-page.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export default function inlineRequirePagePlugin(buildOpts: BuildOptions) {
2929
}
3030

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

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

49+
// Inline fs access and dynamic require that are not supported ny workerd.
5050
const fnBody = `
5151
// html
5252
${htmlFiles

packages/cloudflare/src/cli/build/patches/plugins/wrangler-external.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
/**
2-
* Makes files handled by wrangler external.
2+
* ESBuild plugin to mark files bundled by wrangler as external.
33
*
4-
* Paths need to be absolute so that they are valid in the output bundle.
4+
* `.wasm` and `.bin` will ultimately be bundled by wrangler.
5+
* We should only mark them as external in the adapter.
6+
*
7+
* However simply marking them as external would copy the import path to the bundle,
8+
* i.e. `import("./file.wasm?module")` and given than the bundle is generated in a
9+
* different location than the input files, the relative path would not be valid.
10+
*
11+
* This ESBuild plugin convert relative paths to absolute paths so that they are
12+
* still valid from inside the bundle.
13+
*
14+
* ref: https://developers.cloudflare.com/workers/wrangler/bundling/
515
*/
616

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

0 commit comments

Comments
 (0)