Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not transpile @swc/helpers #7529

Merged
merged 1 commit into from Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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