Skip to content

Commit

Permalink
replace variable declarator to avoid id rename
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Aug 29, 2023
1 parent 77ae968 commit 4e966d1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -736,8 +736,12 @@ function pluginImportMetaUrl({ types: t, template }) {

if (binding.path.isImportSpecifier()) {
path.parentPath.parentPath.assertVariableDeclaration();
path.replaceWith(
template.expression.ast`{ __dirname, __filename, require }`
const { parentPath } = path;
parentPath.replaceWith(
t.variableDeclarator(
parentPath.node.id,
template.expression.ast`{ __dirname, __filename, require }`
)
);
}
},
Expand Down

0 comments on commit 4e966d1

Please sign in to comment.