-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Description
Version
17.6.0 and 16.14.0
Platform
Darwin MacBook-Pro.local 19.6.0 Darwin Kernel Version 19.6.0: Tue Aug 24 20:28:00 PDT 2021; root:xnu-6153.141.40~1/RELEASE_X86_64 x86_64
Subsystem
internal/modules/esm/resolve
What steps will reproduce the bug?
-
ensure pnpm is installed globally
-
In a new, blank directory, add the following package.json:
{
"dependencies": {
"@lit-labs/ssr": "^2.0.3"
},
"type": "module"
}
-
Run
pnpm install
-
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).