Skip to content

Commit 65c6f41

Browse files
committed
fix: better commonjs support
walk children of assignment expressions as they could have dynamic requires Should help with techniq/layerchart#512
1 parent 800084c commit 65c6f41

File tree

1 file changed

+3
-2
lines changed
  • packages/repl/src/lib/workers/bundler/plugins

1 file changed

+3
-2
lines changed

packages/repl/src/lib/workers/bundler/plugins/commonjs.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ const plugin: Plugin = {
4242
context.next();
4343
},
4444
AssignmentExpression: (node, context) => {
45+
// walk children to find nested requires
46+
context.next();
47+
4548
if (node.operator !== '=') return;
4649
if (node.left.type !== 'MemberExpression') return;
4750
if (node.left.object.type !== 'Identifier' || node.left.object.name !== 'exports') return;
@@ -53,8 +56,6 @@ const plugin: Plugin = {
5356
`export const ${node.left.property.name} = module.exports.${node.left.property.name};`
5457
);
5558
}
56-
57-
context.next();
5859
}
5960
});
6061

0 commit comments

Comments
 (0)