Skip to content

Commit 38e8cee

Browse files
committed
chore: update package.json files to use "module" type and remove globalThis.IS_ESM references
1 parent e543709 commit 38e8cee

File tree

19 files changed

+52
-48
lines changed

19 files changed

+52
-48
lines changed

e2e/docs-e2e/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
"test": "pnpm exec playwright test --config=playwright.config.ts --project=chromium",
1515
"test-ui": "pnpm exec playwright test --config=playwright.config.ts --project=chromium --ui"
1616
},
17-
"type": "commonjs"
17+
"type": "module"
1818
}

e2e/qwik-cli-e2e/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
"scripts": {
99
"e2e": "vitest run --config=vite.config.ts",
1010
"e2e.watch": "vitest watch --config=vite.config.ts"
11-
}
11+
},
12+
"type": "module"
1213
}

packages/qwik/src/optimizer/src/platform.ts

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -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 };
222213
declare const WorkerGlobalScope: any;
223214
declare const Deno: any;
224215
declare const Bun: any;

scripts/submodule-optimizer.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ export async function submoduleOptimizer(config: BuildConfig) {
7373
},
7474
define: {
7575
...commonConfig.define,
76-
'globalThis.IS_ESM': 'true',
7776
},
7877
};
7978

scripts/submodule-server.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ export async function submoduleServer(config: BuildConfig) {
7676
define: {
7777
...(await inlineQwikScriptsEsBuild(config)),
7878
...(await inlineBackpatchScriptsEsBuild(config)),
79-
'globalThis.IS_ESM': 'true',
8079
'globalThis.QWIK_VERSION': JSON.stringify(config.distVersion),
8180
'globalThis.QWIK_DOM_VERSION': JSON.stringify(qwikDomVersion),
8281
},

starters/adapters/aws-lambda/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@
1919
"https://aws.amazon.com/es/lambda/",
2020
"https://www.serverless.com/cloud/docs/get-started"
2121
]
22-
}
22+
},
23+
"type": "module"
2324
}

starters/adapters/azure-swa/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@
2424
"- pnpm run deploy: it will use the SWA CLI to deploy your site"
2525
]
2626
}
27-
}
27+
},
28+
"type": "module"
2829
}

starters/adapters/bun/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@
2323
},
2424
"devDependencies": {
2525
"@types/bun": "*"
26-
}
26+
},
27+
"type": "module"
2728
}

starters/adapters/cloud-run/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@
2020
"- pnpm run deploy: it will use the gcloud CLI to deploy your site"
2121
]
2222
}
23-
}
23+
},
24+
"type": "module"
2425
}

starters/adapters/cloudflare-pages/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@
2424
"- pnpm run deploy: it will use the Cloudflare CLI to deploy your site"
2525
]
2626
}
27-
}
27+
},
28+
"type": "module"
2829
}

0 commit comments

Comments
 (0)