diff --git a/.changeset/soft-rats-punch.md b/.changeset/soft-rats-punch.md new file mode 100644 index 00000000..bdf53457 --- /dev/null +++ b/.changeset/soft-rats-punch.md @@ -0,0 +1,5 @@ +--- +"@opennextjs/cloudflare": patch +--- + +polyfill import.meta.url diff --git a/packages/cloudflare/src/cli/templates/init.ts b/packages/cloudflare/src/cli/templates/init.ts index 9d627803..1a95292c 100644 --- a/packages/cloudflare/src/cli/templates/init.ts +++ b/packages/cloudflare/src/cli/templates/init.ts @@ -61,6 +61,9 @@ function initRuntime() { globalThis.__dirname ??= ""; globalThis.__filename ??= ""; + // Some packages rely on `import.meta.url` but it is undefined in workerd + // For example it causes a bunch of issues, and will make even import crash with payload + import.meta.url ??= "file:///worker.js"; // Do not crash on cache not supported // https://github.com/cloudflare/workerd/pull/2434