Skip to content

Commit

Permalink
better error message for missing internal names
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Jun 20, 2017
1 parent bf4ec9c commit 245dcc3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/optimize/ConcatenatedModule.js
Expand Up @@ -24,7 +24,10 @@ function getFinalName(info, exportName, moduleToInfoMap, requestShortener) {
if(directExport) {
if(exportName === true)
info.needNamespaceObject = true;
return info.internalNames.get(directExport);
const name = info.internalNames.get(directExport);
if(!name)
throw new Error(`The export "${directExport}" in "${info.module.readableIdentifier(requestShortener)}" has no internal name`);
return name;
}
const reexport = info.reexportMap.get(exportName);
if(reexport) {
Expand Down Expand Up @@ -380,8 +383,6 @@ class ConcatenatedModule extends Module {
exportName = referencedModule.module.providedExports[exportIdx];
}
const finalName = getFinalName(referencedModule, exportName, moduleToInfoMap, requestShortener);
if(!finalName)
throw new Error(`Cannot map to variable name in module ${info.module.resource} (export '${exportName}')`);
const r = reference.identifier.range;
const source = info.source;
source.replace(r[0], r[1] - 1, finalName);
Expand Down

0 comments on commit 245dcc3

Please sign in to comment.