Skip to content

Commit 6937e76

Browse files
franjohn21ljharb
authored andcommitted
[Fix] Handle visiting the same path gracefully
1 parent 7c6293b commit 6937e76

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/utils.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,15 @@ export function createDynamicImportTransform({ template, types: t }) {
1818
const buildImport = template('Promise.resolve(SOURCE).then(s => INTEROP(require(s)))');
1919
const buildImportNoInterop = template('Promise.resolve(SOURCE).then(s => require(s))');
2020

21+
const visited = typeof WeakSet === 'function' && new WeakSet();
22+
2123
return (context, path) => {
24+
if (visited) {
25+
if (visited.has(path)) {
26+
return;
27+
}
28+
visited.add(path);
29+
}
2230
const SOURCE = getImportSource(t, path.parent);
2331

2432
const newImport = context.opts.noInterop

0 commit comments

Comments
 (0)