@@ -29,9 +29,7 @@ export async function getSystem() {
2929
3030 sys . path = createPath ( sys ) ;
3131
32- if ( globalThis . IS_ESM ) {
33- sys . strictDynamicImport = sys . dynamicImport = ( path ) => import ( path ) ;
34- }
32+ sys . strictDynamicImport = sys . dynamicImport = ( path ) => import ( path ) ;
3533
3634 if ( sysEnv !== 'webworker' && sysEnv !== 'browsermain' ) {
3735 try {
@@ -119,14 +117,10 @@ export async function loadPlatformBinding(sys: OptimizerSystem) {
119117 for ( const triple of triples ) {
120118 // Node.js - Native Binding
121119 try {
122- if ( globalThis . IS_ESM ) {
123- const module = await sys . dynamicImport ( 'node:module' ) ;
124- const mod = module . default . createRequire ( import . meta. url ) (
125- `../bindings/${ triple . platformArchABI } `
126- ) ;
127- return mod ;
128- }
129- const mod = await sys . dynamicImport ( `../bindings/${ triple . platformArchABI } ` ) ;
120+ const module = await sys . dynamicImport ( 'node:module' ) ;
121+ const mod = module . default . createRequire ( import . meta. url ) (
122+ `../bindings/${ triple . platformArchABI } `
123+ ) ;
130124 return mod ;
131125 } catch ( e ) {
132126 console . warn (
@@ -139,24 +133,22 @@ export async function loadPlatformBinding(sys: OptimizerSystem) {
139133 }
140134 }
141135
142- if ( globalThis . IS_ESM ) {
143- if ( sysEnv === 'node' || sysEnv === 'bun' ) {
144- // ESM WASM Node.js
145- const url : typeof import ( 'url' ) = await sys . dynamicImport ( 'node:url' ) ;
146- const __dirname = sys . path . dirname ( url . fileURLToPath ( import . meta. url ) ) ;
147- const wasmPath = sys . path . join ( __dirname , '..' , 'bindings' , 'qwik_wasm_bg.wasm' ) ;
148- const mod = await sys . dynamicImport ( `../bindings/qwik.wasm.mjs` ) ;
149- const fs : typeof import ( 'fs' ) = await sys . dynamicImport ( 'node:fs' ) ;
150-
151- const buf = await fs . promises . readFile ( wasmPath ) ;
152- const wasm = await WebAssembly . compile ( buf as any ) ;
153- await mod . default ( wasm ) ;
154- return mod ;
155- } else {
156- const module = await sys . dynamicImport ( `../bindings/qwik.wasm.mjs` ) ;
157- await module . default ( ) ;
158- return module ;
159- }
136+ if ( sysEnv === 'node' || sysEnv === 'bun' ) {
137+ // ESM WASM Node.js
138+ const url : typeof import ( 'url' ) = await sys . dynamicImport ( 'node:url' ) ;
139+ const __dirname = sys . path . dirname ( url . fileURLToPath ( import . meta. url ) ) ;
140+ const wasmPath = sys . path . join ( __dirname , '..' , 'bindings' , 'qwik_wasm_bg.wasm' ) ;
141+ const mod = await sys . dynamicImport ( `../bindings/qwik.wasm.mjs` ) ;
142+ const fs : typeof import ( 'fs' ) = await sys . dynamicImport ( 'node:fs' ) ;
143+
144+ const buf = await fs . promises . readFile ( wasmPath ) ;
145+ const wasm = await WebAssembly . compile ( buf as any ) ;
146+ await mod . default ( wasm ) ;
147+ return mod ;
148+ } else {
149+ const module = await sys . dynamicImport ( `../bindings/qwik.wasm.mjs` ) ;
150+ await module . default ( ) ;
151+ return module ;
160152 }
161153
162154 throw new Error ( `Platform not supported` ) ;
@@ -218,7 +210,6 @@ const extensions: { [ext: string]: boolean } = {
218210 '.mjs' : true ,
219211} ;
220212
221- declare const globalThis : { IS_ESM : boolean ; [ key : string ] : any } ;
222213declare const WorkerGlobalScope : any ;
223214declare const Deno : any ;
224215declare const Bun : any ;
0 commit comments