Preserve import binding locations during module rewriting (#7378)
* Only wrap import references that need it. * Preserve the import binding location for sourcemaps. * Add tests.
This commit is contained in:
@@ -181,7 +181,13 @@ const rewriteReferencesVisitor = {
|
||||
if (importData) {
|
||||
const ref = buildImportReference(importData, path.node);
|
||||
|
||||
if (path.parentPath.isCallExpression({ callee: path.node })) {
|
||||
// Preserve the binding location so that sourcemaps are nicer.
|
||||
ref.loc = path.node.loc;
|
||||
|
||||
if (
|
||||
path.parentPath.isCallExpression({ callee: path.node }) &&
|
||||
t.isMemberExpression(ref)
|
||||
) {
|
||||
path.replaceWith(t.sequenceExpression([t.numericLiteral(0), ref]));
|
||||
} else if (path.isJSXIdentifier() && t.isMemberExpression(ref)) {
|
||||
const { object, property } = ref;
|
||||
|
||||
Reference in New Issue
Block a user