Skip to content

Commit

Permalink
Do not transpile @swc/helpers (#7529)
Browse files Browse the repository at this point in the history
  • Loading branch information
devongovett committed Jan 6, 2022
1 parent 5a80fbe commit c85eb04
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
Expand Up @@ -2,3 +2,4 @@ import Foo from 'foo';

export {Foo};
export class Bar {}
export const t = typeof Foo;
4 changes: 3 additions & 1 deletion packages/core/integration-tests/test/transpilation.js
Expand Up @@ -57,13 +57,15 @@ describe('transpilation', function () {
});

it('should transpile node_modules by default', async function () {
await bundle(
let b = await bundle(
path.join(__dirname, '/integration/babel-node-modules/index.js'),
);

let file = await outputFS.readFile(path.join(distDir, 'index.js'), 'utf8');
assert(!/class \S+ \{/.test(file));
assert(file.includes('function Bar'));
let res = await run(b);
assert.equal(res.t, 'function');
});

it('should not support JSX in node_modules', async function () {
Expand Down
5 changes: 5 additions & 0 deletions packages/transformers/js/src/JSTransformer.js
Expand Up @@ -333,6 +333,11 @@ export default (new Transformer({
targets = {node: semver.minVersion(asset.env.engines.node)?.toString()};
}

// Avoid transpiling @swc/helpers so that we don't cause infinite recursion.
if (asset.filePath.includes('@swc/helpers')) {
targets = null;
}

let env: EnvMap = {};

if (!config?.inlineEnvironment) {
Expand Down

0 comments on commit c85eb04

Please sign in to comment.