Skip to content

Commit

Permalink
[babel 8] Remove -d/-gc babel-node aliases (#15956)
Browse files Browse the repository at this point in the history
* [babel 8] Remove `-d`/`-gc` babel-node aliases

* Skip test
  • Loading branch information
nicolo-ribaudo authored Sep 12, 2023
1 parent 714d271 commit e976248
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
18 changes: 9 additions & 9 deletions packages/babel-node/src/babel-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@ function getNormalizedV8Flag(arg: string) {
return arg;
}

// These are aliases for node options defined by babel-node.
// TODO(Babel 8): Consider removing these
const aliases = new Map([
["-d", "--debug"],
["-gc", "--expose-gc"],
]);

getV8Flags(async function (err, v8Flags) {
if (!process.env.BABEL_8_BREAKING) {
// The version of v8flags used by Babel 7 uses _, while the one used
Expand All @@ -62,11 +55,18 @@ getV8Flags(async function (err, v8Flags) {
const arg = babelArgs[i];
const flag = arg.split("=")[0];

if (!process.env.BABEL_8_BREAKING) {
if (flag === "-d") {
args.unshift("--debug");
continue;
} else if (flag === "-gc") {
args.unshift("--expose-gc");
continue;
}
}
if (flag === "-r" || flag === "--require") {
args.push(flag);
args.push(babelArgs[++i]);
} else if (aliases.has(flag)) {
args.unshift(aliases.get(flag));
} else if (
flag === "debug" || // node debug foo.js
flag === "inspect" ||
Expand Down
9 changes: 7 additions & 2 deletions packages/babel-node/test/fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import path from "path";
import fs from "fs";
import { fileURLToPath } from "url";
import { createRequire } from "module";
import { itBabel8, itBabel7 } from "$repo-utils";

const require = createRequire(import.meta.url);

Expand Down Expand Up @@ -198,7 +199,11 @@ describe("bin/babel-node", function () {
opts.inFiles["package.json"] = `{ "type": "commonjs" }`;
}

// eslint-disable-next-line jest/valid-title
it(testName, buildTest(testName, opts), 20000);
let run = it;
if (typeof opts.BABEL_8_BREAKING === "boolean") {
run = opts.BABEL_8_BREAKING ? itBabel8 : itBabel7;
}

run(testName, buildTest(testName, opts), 20000);
});
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"args": ["-gc", "--eval", "console.log(typeof global.gc)"],
"stdout": "function"
"stdout": "function",
"BABEL_8_BREAKING": false
}

0 comments on commit e976248

Please sign in to comment.