Skip to content

Commit 6d3291f

Browse files
authored
define __filename (#417)
1 parent 8317b8c commit 6d3291f

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

.changeset/ten-flowers-begin.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+
define \_\_filename globally

packages/cloudflare/src/cli/build/bundle-server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,11 @@ export async function bundleServer(buildOpts: BuildOptions): Promise<void> {
136136
platform: "node",
137137
banner: {
138138
js: `
139-
// __dirname is used by unbundled js files (which don't inherit the __dirname present in the define field)
139+
// Used by unbundled js files (which don't inherit the __dirname present in the define field)
140140
// so we also need to set it on the global scope
141141
// Note: this was hit in the next/dist/compiled/@opentelemetry/api module
142142
globalThis.__dirname ??= "";
143+
globalThis.__filename ??= "";
143144
144145
// Do not crash on cache not supported
145146
// https://github.com/cloudflare/workerd/pull/2434

0 commit comments

Comments
 (0)