You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Run node (interactive with no flags), and the following works:
> let { installWindowOnGlobal } = await import("@lit-labs/ssr/lib/dom-shim.js")
undefined
Run node --experimental-specifier-resolution=node and it no longer works
> let { installWindowOnGlobal } = await import("@lit-labs/ssr/lib/dom-shim.js")
Uncaught:
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'node-fetch' imported from /Users/tstewart/dev/ex-spec-res-issue/node_modules/@lit-labs/ssr/lib/dom-shim.js
at __node_internal_captureLargerStackTrace (node:internal/errors:465:5)
at new NodeError (node:internal/errors:372:5)
at packageResolve (node:internal/modules/esm/resolve:901:9)
at moduleResolve (node:internal/modules/esm/resolve:950:20)
at defaultResolve (node:internal/modules/esm/resolve:1166:11)
at ESMLoader.resolve (node:internal/modules/esm/loader:536:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:250:18) {
code: 'ERR_MODULE_NOT_FOUND'
}
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior?
I expect the flag to only affect the behaviour relating to file extensions.
What do you see instead?
The flag also produces a changed behaviour in terms of the module search path with symlinked modules.
Additional information
I would expect the --experimental-specifier-resolution flag to only affect the behaviour with regard to the ".js" extension, at least that is what I am aiming at, so I can use Typescript output without post-processing all files to have ".js" extensions or similar workaround. This works fine if I use the "shamefully-hoist" flag in pnpm installation, so that all packages are flattened at the top level of node_modules. If that is indeed the intended behaviour of --experimental-specifier-resolution - i.e. that it should change BOTH the file extension behaviour AND the symlinked path behaviour, then is it possible in any way to get the desired behaviour (working without ".js" extensions) without the undesired behaviour (different interpretation of symlinked paths).
Yep that fixes it, many thanks. So this will be in the 18.0.0 release? Is it likely to be back-ported to any other major versions? Just wanting to understand my users' system requirements once this rolls out.
It will be in v18.0.0, and it should also be backported to the next v17.x release, and later in a v16.x release. Good to hear that fixed it for you, closing :)
Activity
meixg commentedon Mar 7, 2022
This may have been solved by #42197, and a duplicate of #42195
Can you please try on the master branch to see if it work?
tstewart-klaudhaus commentedon Mar 7, 2022
Yes that does sound very similar, thanks. I'm unfamiliar with building node from source, but will address this over the coming day or so to check.
aduh95 commentedon Mar 7, 2022
You can also use one of the nightly builds (the most recent one at the time of writing can be found at https://nodejs.org/download/nightly/v18.0.0-nightly202203074158d62dec/ and
I think it containsdoes contain the fix), so you don't have to set up a whole dev env :)tstewart-klaudhaus commentedon Mar 7, 2022
Yep that fixes it, many thanks. So this will be in the 18.0.0 release? Is it likely to be back-ported to any other major versions? Just wanting to understand my users' system requirements once this rolls out.
v 0.17.1
aduh95 commentedon Mar 7, 2022
It will be in v18.0.0, and it should also be backported to the next v17.x release, and later in a v16.x release. Good to hear that fixed it for you, closing :)
tstewart-klaudhaus commentedon Mar 7, 2022
Thanks again, great result.