Skip to content

Commit

Permalink
inline Babel template
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Aug 29, 2023
1 parent 77ae968 commit 25f788e
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion babel.config.js
Expand Up @@ -737,7 +737,26 @@ function pluginImportMetaUrl({ types: t, template }) {
if (binding.path.isImportSpecifier()) {
path.parentPath.parentPath.assertVariableDeclaration();
path.replaceWith(
template.expression.ast`{ __dirname, __filename, require }`
t.objectExpression([
t.objectProperty(
t.identifier("__dirname"),
t.identifier("__dirname"),
false,
true
),
t.objectProperty(
t.identifier("__filename"),
t.identifier("__filename"),
false,
true
),
t.objectProperty(
t.identifier("require"),
t.identifier("require"),
false,
true
),
])
);
}
},
Expand Down

0 comments on commit 25f788e

Please sign in to comment.