Skip to content

Commit c4d278e

Browse files
authored
polyfill import.meta.url (#639)
* polyfill import.meta.url * review fix * changeset
1 parent c525ee9 commit c4d278e

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

.changeset/soft-rats-punch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@opennextjs/cloudflare": patch
3+
---
4+
5+
polyfill import.meta.url

packages/cloudflare/src/cli/templates/init.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ function initRuntime() {
6161

6262
globalThis.__dirname ??= "";
6363
globalThis.__filename ??= "";
64+
// Some packages rely on `import.meta.url` but it is undefined in workerd
65+
// For example it causes a bunch of issues, and will make even import crash with payload
66+
import.meta.url ??= "file:///worker.js";
6467

6568
// Do not crash on cache not supported
6669
// https://github.com/cloudflare/workerd/pull/2434

0 commit comments

Comments
 (0)