X Tutup
The Wayback Machine - https://web.archive.org/web/20220320015324/https://github.com/nodejs/node/commit/8dd06850ae
Skip to content
Permalink
Browse files
esm: use correct URL for error decoration
PR-URL: #37854
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Jan Krems <jan.krems@gmail.com>
  • Loading branch information
bmeck committed Apr 12, 2021
1 parent c8bbd83 commit 8dd06850ae9287d2171541f75654a56f34d356bd
@@ -109,7 +109,11 @@ class ModuleJob {
if (StringPrototypeIncludes(e.message,
' does not provide an export named')) {
const splitStack = StringPrototypeSplit(e.stack, '\n');
const parentFileUrl = splitStack[0];
const parentFileUrl = StringPrototypeReplace(
splitStack[0],
/:\d+$/,
''
);
const { 1: childSpecifier, 2: name } = StringPrototypeMatch(
e.message,
/module '(.*)' does not provide an export named '(.+)'/);
@@ -0,0 +1 @@
import {doesNotExist} from './dep.js';
@@ -0,0 +1,11 @@
{
"resources": {
"../bad-main.mjs": {
"integrity": true,
"dependencies": true
},
"../dep.js": {
"integrity": true
}
}
}
@@ -89,3 +89,23 @@ const dep = fixtures.path('policy', 'parent.js');
);
assert.strictEqual(status, 1);
}
{
// Regression test for https://github.com/nodejs/node/issues/37812
const depPolicy = fixtures.path(
'policy',
'dependencies',
'dependencies-missing-export-policy.json');
const { status, stderr } = spawnSync(
process.execPath,
[
'--experimental-policy',
depPolicy,
fixtures.path('policy', 'bad-main.mjs'),
]
);
assert.strictEqual(status, 1);
assert.match(
`${stderr}`,
/SyntaxError: Named export 'doesNotExist' not found\./,
'Should give the real SyntaxError and position');
}

0 comments on commit 8dd0685

Please sign in to comment.
X Tutup