Skip to content

Commit 2d82b00

Browse files
authored
Merge pull request webpack#5113 from webpack/feature/better-error-message
better error message for missing internal names
2 parents e08d2f5 + 245dcc3 commit 2d82b00

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎lib/optimize/ConcatenatedModule.js‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ function getFinalName(info, exportName, moduleToInfoMap, requestShortener) {
2424
if(directExport) {
2525
if(exportName === true)
2626
info.needNamespaceObject = true;
27-
return info.internalNames.get(directExport);
27+
const name = info.internalNames.get(directExport);
28+
if(!name)
29+
throw new Error(`The export "${directExport}" in "${info.module.readableIdentifier(requestShortener)}" has no internal name`);
30+
return name;
2831
}
2932
const reexport = info.reexportMap.get(exportName);
3033
if(reexport) {
@@ -380,8 +383,6 @@ class ConcatenatedModule extends Module {
380383
exportName = referencedModule.module.providedExports[exportIdx];
381384
}
382385
const finalName = getFinalName(referencedModule, exportName, moduleToInfoMap, requestShortener);
383-
if(!finalName)
384-
throw new Error(`Cannot map to variable name in module ${info.module.resource} (export '${exportName}')`);
385386
const r = reference.identifier.range;
386387
const source = info.source;
387388
source.replace(r[0], r[1] - 1, finalName);

0 commit comments

Comments
 (0)