Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
CallExpression(path, state) {
if (t.isImport(path.node.callee)) {
if (!this.file.has("@babel/plugin-proposal-dynamic-import")) {
console.warn(MISSING_PLUGIN_WARNING);
}
path.replaceWith(
t.callExpression(
t.memberExpression(
t.identifier(state.contextIdent),
t.identifier("import"),
),
[getImportSource(t, path.node)],
),
);
}
},
}
if (!resolveId || !rejectId) {
resolveId = path.scope.generateUidIdentifier("resolve");
rejectId = path.scope.generateUidIdentifier("reject");
state.resolveId = resolveId;
state.rejectId = rejectId;
}
let result = t.identifier("imported");
if (!noInterop) result = wrapInterop(path, result, "namespace");
path.replaceWith(
template.expression.ast`
new Promise((${resolveId}, ${rejectId}) =>
${requireId}(
[${getImportSource(t, path.node)}],
imported => ${resolveId}(${result}),
${rejectId}
)
)`,
);
},