esm: better error message for unsupported URL#31129
esm: better error message for unsupported URL#31129Hakerh400 wants to merge 1 commit intonodejs:masterfrom Hakerh400:esm-url
Conversation
|
test/es-module/test-esm-dynamic-import.js // TODO(jkrems): Right now this doesn't hit a protocol error because the
// module resolution step already rejects it. These arguably should be
// protocol errors.
expectMissingModuleError(import('node:fs'));
expectMissingModuleError(import('http://example.com/foo.js'));This is the only test failing right now. The problem is that the loader converts the url to a file url and ignores the url scheme, producing a misleading error message (and it may probably load a wrong module). Should we update this test to check for |
devsnek
left a comment
There was a problem hiding this comment.
you can use parsed.scheme a few lines down.
guybedford
left a comment
There was a problem hiding this comment.
Thanks for the PR, the approach looks great.
The test failures can be fixed by just changing the test expectations in https://github.com/nodejs/node/blob/master/test/es-module/test-esm-dynamic-import.js#L60. Note that the errors exactly align with a TODO comment @jkrems included previously.
The default ESM loader supports only file and data URLs. This PR adds better error message for it.
|
This is stalled on two issues in CI (nodejs/build#2116 and nodejs/build#2115) that will hopefully be resolved soon. |
|
Landed in a25a628 🎉 |
The default ESM loader supports only file and data URLs. This PR adds better error message for it. PR-URL: nodejs#31129 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
The default ESM loader supports only file and data URLs. This PR adds better error message for it. PR-URL: #31129 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
The default ESM loader supports only file and data URLs. This PR adds better error message for it. PR-URL: #31129 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
The default ESM loader supports only file and data URLs. This PR adds better error message for it. PR-URL: #31129 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
The default ESM loader supports only file and data URLs.
This PR adds better error message for it.
Fixes #31120
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes