Skip to content

Commit a0a8008

Browse files
fix: make sure that the __import_unsupported patch is applied in cloudflare as well
1 parent 697681b commit a0a8008

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

packages/open-next/src/build/edge/createEdgeBundle.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,21 +130,22 @@ globalThis.Buffer = Buffer;
130130
131131
import {AsyncLocalStorage} from "node:async_hooks";
132132
globalThis.AsyncLocalStorage = AsyncLocalStorage;
133+
134+
const defaultDefineProperty = Object.defineProperty;
135+
Object.defineProperty = function(o, p, a) {
136+
if(p=== '__import_unsupported' && Boolean(globalThis.__import_unsupported)) {
137+
return;
138+
}
139+
return defaultDefineProperty(o, p, a);
140+
};
141+
133142
${
134143
isInCloudfare
135144
? ""
136145
: `
137146
const require = (await import("node:module")).createRequire(import.meta.url);
138147
const __filename = (await import("node:url")).fileURLToPath(import.meta.url);
139148
const __dirname = (await import("node:path")).dirname(__filename);
140-
141-
const defaultDefineProperty = Object.defineProperty;
142-
Object.defineProperty = function(o, p, a) {
143-
if(p=== '__import_unsupported' && Boolean(globalThis.__import_unsupported)) {
144-
return;
145-
}
146-
return defaultDefineProperty(o, p, a);
147-
};
148149
`
149150
}
150151
${additionalInject ?? ""}

0 commit comments

Comments
 (0)