Avoid using CJS globals in internal source files (#12963)
* Lint against CJS globals in modules * Use `import.meta.url` instead of `__filename` in `src` files * Prepare fixtures runner for `import.meta.url` * Use `import.meta.url` instead of `__filename` in `test/index` files * Remove `__dirname` from remaining test files dirname * Avoid using `module` in `src` files * Avoid using `require` in `src` files * Avoid using `require` in `test` files * Update `@types/node` * Compile dynamic import in `@babel/node` * Fix windows * Use `@babel/plugin-proposal-dynamic-import` from npm
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import path from "path";
|
||||
import { runThrowTestsWithEstree } from "./helpers/runFixtureTests";
|
||||
import { parse } from "../lib";
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
runThrowTestsWithEstree(path.join(__dirname, "fixtures"), parse);
|
||||
runThrowTestsWithEstree(
|
||||
path.join(path.dirname(fileURLToPath(import.meta.url)), "fixtures"),
|
||||
parse,
|
||||
);
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import path from "path";
|
||||
import { runFixtureTests } from "./helpers/runFixtureTests";
|
||||
import { parseExpression } from "../lib";
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
runFixtureTests(path.join(__dirname, "expressions"), parseExpression);
|
||||
const fixtures = path.join(
|
||||
path.dirname(fileURLToPath(import.meta.url)),
|
||||
"expressions",
|
||||
);
|
||||
|
||||
runFixtureTests(fixtures, parseExpression);
|
||||
|
||||
@@ -2,8 +2,12 @@ import { multiple as getFixtures } from "@babel/helper-fixtures";
|
||||
import { codeFrameColumns } from "@babel/code-frame";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
const rootPath = path.join(__dirname, "../../../..");
|
||||
const rootPath = path.join(
|
||||
path.dirname(fileURLToPath(import.meta.url)),
|
||||
"../../../..",
|
||||
);
|
||||
|
||||
const serialized = "$$ babel internal serialized type";
|
||||
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
import path from "path";
|
||||
import { runFixtureTests } from "./helpers/runFixtureTests";
|
||||
import { parse } from "../lib";
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
runFixtureTests(path.join(__dirname, "fixtures"), parse);
|
||||
const fixtures = path.join(
|
||||
path.dirname(fileURLToPath(import.meta.url)),
|
||||
"fixtures",
|
||||
);
|
||||
runFixtureTests(fixtures, parse);
|
||||
|
||||
Reference in New Issue
Block a user