Skip to content

Commit

Permalink
Add test for 14233
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Feb 4, 2022
1 parent 89e26a0 commit bddda1c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/babel-core/package.json
Expand Up @@ -67,6 +67,7 @@
"devDependencies": {
"@babel/helper-transform-fixture-test-runner": "workspace:^",
"@babel/plugin-transform-modules-commonjs": "workspace:^",
"@babel/plugin-transform-runtime": "workspace:^",
"@types/convert-source-map": "^1.5.1",
"@types/debug": "^4.1.0",
"@types/resolve": "^1.3.2",
Expand Down
25 changes: 25 additions & 0 deletions packages/babel-core/test/external-dependencies.js
@@ -1,6 +1,7 @@
import path from "path";
import { fileURLToPath } from "url";
import { transformSync } from "../lib/index.js";
import transformRuntime from "@babel/plugin-transform-runtime";

const cwd = path.dirname(fileURLToPath(import.meta.url));

Expand Down Expand Up @@ -230,4 +231,28 @@ describe("externalDependencies", () => {
).not.toThrow();
});
});

describe("regressions", () => {
it("#14233", () => {
const code = `let a = 1`;

expect(() => {
// TODO: Understand why transform-runtime makes it crash.
// Two important reaons are that:
// - It uses api.caller(), so it gets reinstantiated when it changes
// - It extends another plugin that does not need to be reinstantiated
// However, a very simple plugin that mets those conditions does not
// crash; there is something else going on.
transform(code, {
plugins: [transformRuntime],
caller: { name: "caller-1" },
});

transform(code, {
plugins: [transformRuntime],
caller: { name: "caller-2" },
});
}).not.toThrow();
});
});
});
1 change: 1 addition & 0 deletions yarn.lock
Expand Up @@ -332,6 +332,7 @@ __metadata:
"@babel/helpers": "workspace:^"
"@babel/parser": "workspace:^"
"@babel/plugin-transform-modules-commonjs": "workspace:^"
"@babel/plugin-transform-runtime": "workspace:^"
"@babel/template": "workspace:^"
"@babel/traverse": "workspace:^"
"@babel/types": "workspace:^"
Expand Down

0 comments on commit bddda1c

Please sign in to comment.