diff --git a/scripts/generators/archived-libs-typings.js b/scripts/generators/archived-libs-typings.js index 4fd5d1a8a5d6..ab3c25860782 100644 --- a/scripts/generators/archived-libs-typings.js +++ b/scripts/generators/archived-libs-typings.js @@ -1,8 +1,5 @@ import fs from "fs"; - -const archivedSyntaxPkgs = JSON.parse( - fs.readFileSync(new URL("./archived-syntax-pkgs.json", import.meta.url)) -); +import archivedSyntaxPkgs from "./archived-syntax-pkgs.json" with { "type": "json" }; const root = new URL("../..", import.meta.url); let output = `/* This file is automatically generated by scripts/generators/archived-libs-typings.js */ diff --git a/scripts/generators/tsconfig.js b/scripts/generators/tsconfig.js index 742c04a31473..f4c9fde7e649 100644 --- a/scripts/generators/tsconfig.js +++ b/scripts/generators/tsconfig.js @@ -1,13 +1,10 @@ import fs from "fs"; +import archivedSyntaxPkgs from "./archived-syntax-pkgs.json" with { "type": "json" }; function importJSON(path) { return JSON.parse(fs.readFileSync(path)); } -const archivedSyntaxPkgs = importJSON( - new URL("./archived-syntax-pkgs.json", import.meta.url) -); - const thirdPartyBabelPlugins = [ "@babel/preset-modules/lib/plugins/transform-async-arrows-in-class", "@babel/preset-modules/lib/plugins/transform-edge-default-parameters", diff --git a/scripts/integration-tests/utils/bump-babel-dependencies.js b/scripts/integration-tests/utils/bump-babel-dependencies.js index 54008813f2fd..d4d66308f911 100644 --- a/scripts/integration-tests/utils/bump-babel-dependencies.js +++ b/scripts/integration-tests/utils/bump-babel-dependencies.js @@ -1,11 +1,5 @@ import fs from "fs"; -import path from "path"; -import { fileURLToPath } from "url"; - -const __dirname = path.dirname(fileURLToPath(import.meta.url)); - -const packageJSONPath = path.resolve(process.cwd(), "./package.json"); -const content = JSON.parse(fs.readFileSync(packageJSONPath)); +import content from "../../../package.json" with { type: "json" }; function bumpBabelDependency(type, version) { const dependencies = content[type]; @@ -20,7 +14,7 @@ function bumpBabelDependency(type, version) { if (process.argv[2] === "resolutions") { const resolutions = content.resolutions || {}; for (const name of fs.readdirSync( - path.join(__dirname, "../../../packages") + new URL("../../../packages", import.meta.url) )) { if (!name.startsWith("babel-")) continue; resolutions[name.replace("babel-", "@babel/")] = "*"; @@ -38,4 +32,5 @@ if (process.argv[2] === "resolutions") { } } +const packageJSONPath = new URL("../../../package.json", import.meta.url); fs.writeFileSync(packageJSONPath, JSON.stringify(content, undefined, 2)); diff --git a/scripts/rename-proposal-to-transform.js b/scripts/rename-proposal-to-transform.js index 49b5d4e762bf..28ef0ec5895d 100755 --- a/scripts/rename-proposal-to-transform.js +++ b/scripts/rename-proposal-to-transform.js @@ -13,7 +13,8 @@ const oldPackageJSONPath = path.join(oldPackageFolder, "package.json"); console.info("Updating package.json..."); { - const pkgJSON = JSON.parse(fs.readFileSync(oldPackageJSONPath, "utf8")); + const pkgJSON = (await import(oldPackageJSONPath, { with: { type: "json" } })) + .default; pkgJSON.name = pkgJSON.name.replace(oldName, newName); pkgJSON.description = pkgJSON.description.replace( /the ([a-z-]+?)s? proposal/gi, diff --git a/scripts/rollup-plugin-standalone-internals.js b/scripts/rollup-plugin-standalone-internals.js index 4b8e879faa0e..913ec3184240 100644 --- a/scripts/rollup-plugin-standalone-internals.js +++ b/scripts/rollup-plugin-standalone-internals.js @@ -1,12 +1,10 @@ -import fs from "fs"; import { fileURLToPath } from "url"; +import pluginConfig from "../packages/babel-standalone/scripts/pluginConfig.json" with { "type": "json" }; const standaloneURL = new URL("../packages/babel-standalone/", import.meta.url); const inStandalone = path => fileURLToPath(new URL(path, standaloneURL)).replace(/\\/g, "/"); -const { noopPlugins, unexposedNoopPlugins } = JSON.parse( - fs.readFileSync(new URL("./scripts/pluginConfig.json", standaloneURL), "utf8") -); +const { noopPlugins, unexposedNoopPlugins } = pluginConfig; const pluginUtilsID = "@babel/helper-plugin-utils";