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:
Nicolò Ribaudo
2021-03-05 19:55:36 +01:00
committed by GitHub
parent ea620e822e
commit d04842a700
147 changed files with 651 additions and 346 deletions

View File

@@ -18,6 +18,10 @@ import type { CallerMetadata } from "../validation/options";
import * as fs from "../../gensync-utils/fs";
import { createRequire } from "module";
// $FlowIgnore - https://github.com/facebook/flow/issues/6913#issuecomment-662787504
const require = createRequire(import /*::("")*/.meta.url);
const debug = buildDebug("babel:config:loading:files:configuration");
export const ROOT_CONFIG_FILENAMES = [

View File

@@ -2,6 +2,9 @@ import { isAsync, waitFor } from "../../gensync-utils/async";
import type { Handler } from "gensync";
import path from "path";
import { pathToFileURL } from "url";
import { createRequire } from "module";
const require = createRequire(import.meta.url);
let import_;
try {

View File

@@ -9,6 +9,10 @@ import path from "path";
import { type Handler } from "gensync";
import loadCjsOrMjsDefault from "./module-types";
import { createRequire } from "module";
// $FlowIgnore - https://github.com/facebook/flow/issues/6913#issuecomment-662787504
const require = createRequire(import /*::("")*/.meta.url);
const debug = buildDebug("babel:config:loading:files:plugins");
const EXACT_RE = /^module:/;