Doesn't work on Windows
RReverser opened this issue · 1 comments
RReverser commented
On Windows default example produces a following error:
> node --experimental-modules --loader ../loader.mjs index.mjs
(node:17848) ExperimentalWarning: The ESM module loader is experimental.
{ Error: ENOENT: no such file or directory, open '/C:/Users/Ingvar/cf-repos/node-loader/example/addTwo.wasm'
at Object.openSync (fs.js:450:3)
at Proxy.readFileSync (fs.js:350:35)
at readFile (file:///C:/Users/Ingvar/cf-repos/node-loader/loader.mjs:14:13)
at dynamicInstantiate (file:///C:/Users/Ingvar/cf-repos/node-loader/loader.mjs:18:18)
at loaderInstance (internal/modules/esm/loader.js:125:49)
at new ModuleJob (internal/modules/esm/module_job.js:20:26)
at Loader.getModuleJob (internal/modules/esm/loader.js:138:11)
errno: -4058,
syscall: 'open',
code: 'ENOENT',
path: '/C:/Users/Ingvar/cf-repos/node-loader/example/addTwo.wasm' }
I suspect the reason lies in using path.join
instead of URL
manipulation (which is cross-platform and per-spec).
RReverser commented
Fixed that one, another issue is that instead of URL
only pathname
part is sent to readFile
:
> node --experimental-modules --loader ../loader.mjs index.mjs
(node:7192) ExperimentalWarning: The ESM module loader is experimental.
/C:/Users/Ingvar/cf-repos/node-loader/example/addTwo.wasm
/C:/Users/Ingvar/cf-repos/node-loader/example/get.wasm
{ Error: ENOENT: no such file or directory, open '/C:/Users/Ingvar/cf-repos/node-loader/example/addTwo.wasm'
at Object.openSync (fs.js:450:3)
at Proxy.readFileSync (fs.js:350:35)
at readFile (file:///C:/Users/Ingvar/cf-repos/node-loader/loader.mjs:15:13)
at dynamicInstantiate (file:///C:/Users/Ingvar/cf-repos/node-loader/loader.mjs:19:18)
at loaderInstance (internal/modules/esm/loader.js:125:49)
at new ModuleJob (internal/modules/esm/module_job.js:20:26)
at Loader.getModuleJob (internal/modules/esm/loader.js:138:11)
errno: -4058,
syscall: 'open',
code: 'ENOENT',
path: '/C:/Users/Ingvar/cf-repos/node-loader/example/addTwo.wasm' }