this one might need to be implemented (first) on the node side-of-things:
I like the idea of passing [file] url parameters around, instead of using env parameters, or args. it's also really great for scripts and things of that nature.
// index.[m]js
console.log(import.meta)
node -r esm index.js?myparam=param
# { url: 'file:///index.js' } // no exception
this also doesn't work with the --experimental-modules flag (exception):
node --experimental-modules index.mjs?myparam=param
(node:19012) ExperimentalWarning: The ESM module loader is experimental.
{ Error: Cannot find module /index.mjs%3Ftest=test
at search (internal/modules/esm/default_resolve.js:28:12)
at Loader.resolve [as _resolve] (internal/modules/esm/default_resolve.js:64:11)
at Loader.resolve (internal/modules/esm/loader.js:58:33)
at Loader.getModuleJob (internal/modules/esm/loader.js:113:40)
at Loader.import (internal/modules/esm/loader.js:99:28)
at asyncESM.loaderPromise.then (internal/modules/cjs/loader.js:734:27)
at process._tickCallback (internal/process/next_tick.js:68:7)
at Function.Module.runMain (internal/modules/cjs/loader.js:745:11)
at startup (internal/bootstrap/node.js:266:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:596:3) code: 'MODULE_NOT_FOUND' }
is it possible for esm to grab the full file url?
The reason it doesn't work in Node --experimental-modules currently because it does a simple extension sniff, so sees the path.extname("index.mjs?myparam=param") as '.mjs?myparam=param'. The esm loader is taking the param and fully resolving it, but losing the query in the process. When loading from static/dynamic import we hold on to the query for the meta property. I can tweak this so that it's preserved for the entry too.
awesome, thanks!!!
LOL it was 1 variable change. If you dig you could add a test for it.
LOL it was 1 variable change.
馃槂
If you dig you could add a test for it.
sure!
got the same problem as the build box:
ReferenceError: isAsync is not defined
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
even though I see the correct changes in the git log.
You'll want to rebase to the current master.
I'll get to the test case later today ...
v3.0.73 is released :tada: