-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP Make CJS suggestions when file ext is not provided #30699
Conversation
This is breaking a test, this one // test/message/esm_loader_not_found.mjs
// Flags: --experimental-loader i-dont-exist
import '../common/index.mjs';
console.log('This should not be printed'); Script: Output: (node:43614) ExperimentalWarning: The ESM module loader is experimental.
(node:43614) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
internal/modules/esm/default_resolve.js:102
url = moduleWrapResolve(specifier, parentURL);
^
Error: Cannot find package 'i-dont-exist' imported from /Users/juanjose/Documents/GitHub/Node/node/
at Loader.resolve [as _resolve] (internal/modules/esm/default_resolve.js:102:11)
at Loader.resolve (internal/modules/esm/loader.js:73:33)
at Loader.getModuleJob (internal/modules/esm/loader.js:147:40)
at Loader.import (internal/modules/esm/loader.js:131:28)
at internal/process/esm_loader.js:63:31
at Object.initializeLoader (internal/process/esm_loader.js:67:5)
at runMainESM (internal/modules/run_main.js:41:20)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:64:5)
at internal/main/run_main_module.js:17:47 {
code: 'ERR_MODULE_NOT_FOUND'
} No idea why. I'm stuck on this. |
That's correct - |
Jm, I get it, but the thing is that test script is returning error, that output is the only error. I mean, |
Message tests will always provide a diff when there's an error. A stack line might change then the .output file can be updated. |
Aaaah, you say, it's a diff between .output file and my output? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea behind this. It does require a test case though.
I'm try to write that test |
Ping @juanarbol |
f2eb75b
to
3e23195
Compare
import '../common/index.mjs'; | ||
|
||
import('../fixtures/es-modules/cjs') | ||
.catch(err => console.error(err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BridgeAR I'm having a issue here, when I run ./node test/es-modules/this-test.mjs
does not work the CJS stuff, but when I change my cd to test/es-modules
, and run ../../node this-test.mjs
it works, you have any suggestions or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nodejs/modules-active-members PTAL
I like the error suggestions, but at least per files without an extension this is no longer true per #31021 try using a file like https://github.com/nodejs/node/blob/master/test/fixtures/es-modules/package-type-module/extension.unknown for your test fixture instead |
Ping @juanarbol |
Sorry, the ES Module implementation has changed like a lot, I'll take more time to migrate this to the new implementation, seems harder than before, but with some time this could be done. |
I'll close this, and spend some time to understand the new loader then open another PR; sorry |
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes