Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/import-to-globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,27 @@ async function prepare() {

function analyzeImport(node, importBindings, code, getName, globals) {
const name = node.source.value && getName(node.source.value);
if (!name) {
if (name === undefined) {
return false;
}
globals.add(name);
for (const spec of node.specifiers) {
importBindings.set(spec.local.name, makeGlobalName(
spec.imported ? spec.imported.name : "default",
name
));
}
code.remove(node.start, node.end);
if(name!=='')globals.add(name);
return true;
}

function makeGlobalName(prop, name) {
if (prop === "default") {
return name;
}
if(name===''){
return prop;
}
return `${name}.${prop}`;
}

Expand Down