Skip to content

Commit 7c28ec2

Browse files
authored
WASM: Only use import.meta.url in fallback scenario (#410)
I'm currently using this in a "classic" (not module) worker and `import.meta.url` is not defined which is breaking the call to the `URL` constructor, which I don't even use because I send in the path the WASM module manually. This change uses `import.meta.url` and the `URL` constructor only in the fallback case when a user doesn't pass in a custom url.
1 parent 6419d54 commit 7c28ec2

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

wasm/index.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Environment, napi } from 'napi-wasm';
22

3-
const url = new URL('lightningcss_node.wasm', import.meta.url);
43
let wasm;
54

6-
export default async function init(input = url) {
5+
export default async function init(input) {
6+
input = input ?? new URL('lightningcss_node.wasm', import.meta.url);
77
if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
88
input = fetch(input);
99
}

0 commit comments

Comments
 (0)