diff --git a/babel.config-ts.js b/babel.config-ts.js index 20b35ec013e0f..45efe2a870820 100644 --- a/babel.config-ts.js +++ b/babel.config-ts.js @@ -7,6 +7,8 @@ module.exports = { plugins: [ '@babel/plugin-syntax-jsx', '@babel/plugin-transform-flow-strip-types', + ['@babel/plugin-transform-class-properties', {loose: true}], + '@babel/plugin-transform-classes', ], presets: [ ['@babel/preset-env', {targets: {node: 'current'}}], diff --git a/babel.config.js b/babel.config.js index f8a28b20cc87d..3498e2aebe86f 100644 --- a/babel.config.js +++ b/babel.config.js @@ -4,7 +4,8 @@ module.exports = { plugins: [ '@babel/plugin-syntax-jsx', '@babel/plugin-transform-flow-strip-types', - ['@babel/plugin-proposal-class-properties', {loose: true}], + ['@babel/plugin-transform-class-properties', {loose: true}], + '@babel/plugin-transform-classes', 'syntax-trailing-function-commas', [ '@babel/plugin-proposal-object-rest-spread', diff --git a/compiler/packages/eslint-plugin-react-compiler/src/types/hermes-eslint.d.ts b/compiler/packages/eslint-plugin-react-compiler/src/types/hermes-eslint.d.ts index 539daf7142051..280b1e1e00a21 100644 --- a/compiler/packages/eslint-plugin-react-compiler/src/types/hermes-eslint.d.ts +++ b/compiler/packages/eslint-plugin-react-compiler/src/types/hermes-eslint.d.ts @@ -6,7 +6,7 @@ */ // v0.17.1 -declare module "hermes-eslint" { +declare module 'hermes-eslint' { // https://fburl.com/2vikhmaa type ParseForESLintOptions = { /** @@ -37,7 +37,7 @@ declare module "hermes-eslint" { /** * The source type of the script. */ - sourceType: "script" | "module"; + sourceType: 'script' | 'module'; /** * Ignore JSX elements when adding references to the module-level `React` variable. diff --git a/compiler/packages/eslint-plugin-react-compiler/src/types/hermes-parser.d.ts b/compiler/packages/eslint-plugin-react-compiler/src/types/hermes-parser.d.ts index 40771d183c06b..b624caf19c548 100644 --- a/compiler/packages/eslint-plugin-react-compiler/src/types/hermes-parser.d.ts +++ b/compiler/packages/eslint-plugin-react-compiler/src/types/hermes-parser.d.ts @@ -6,14 +6,14 @@ */ // v0.17.1 -declare module "hermes-parser" { +declare module 'hermes-parser' { type HermesParserOptions = { allowReturnOutsideFunction?: boolean; babel?: boolean; - flow?: "all" | "detect"; + flow?: 'all' | 'detect'; enableExperimentalComponentSyntax?: boolean; sourceFilename?: string; - sourceType?: "module" | "script" | "unambiguous"; + sourceType?: 'module' | 'script' | 'unambiguous'; tokens?: boolean; }; export function parse(code: string, options: Partial); diff --git a/fixtures/eslint-v6/build.mjs b/fixtures/eslint-v6/build.mjs index ebcea15190dae..e0dd355ba4391 100644 --- a/fixtures/eslint-v6/build.mjs +++ b/fixtures/eslint-v6/build.mjs @@ -1,12 +1,13 @@ #!/usr/bin/env node -import {exec} from 'node:child_process'; +import {execSync} from 'node:child_process'; import {dirname, resolve} from 'node:path'; import {fileURLToPath} from 'node:url'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); -exec('yarn build -r stable eslint-plugin-react-hooks', { +execSync('yarn build -r stable eslint-plugin-react-hooks', { cwd: resolve(__dirname, '..', '..'), + stdio: 'inherit', }); diff --git a/fixtures/eslint-v7/build.mjs b/fixtures/eslint-v7/build.mjs index ebcea15190dae..e0dd355ba4391 100644 --- a/fixtures/eslint-v7/build.mjs +++ b/fixtures/eslint-v7/build.mjs @@ -1,12 +1,13 @@ #!/usr/bin/env node -import {exec} from 'node:child_process'; +import {execSync} from 'node:child_process'; import {dirname, resolve} from 'node:path'; import {fileURLToPath} from 'node:url'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); -exec('yarn build -r stable eslint-plugin-react-hooks', { +execSync('yarn build -r stable eslint-plugin-react-hooks', { cwd: resolve(__dirname, '..', '..'), + stdio: 'inherit', }); diff --git a/fixtures/eslint-v8/build.mjs b/fixtures/eslint-v8/build.mjs index ebcea15190dae..e0dd355ba4391 100644 --- a/fixtures/eslint-v8/build.mjs +++ b/fixtures/eslint-v8/build.mjs @@ -1,12 +1,13 @@ #!/usr/bin/env node -import {exec} from 'node:child_process'; +import {execSync} from 'node:child_process'; import {dirname, resolve} from 'node:path'; import {fileURLToPath} from 'node:url'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); -exec('yarn build -r stable eslint-plugin-react-hooks', { +execSync('yarn build -r stable eslint-plugin-react-hooks', { cwd: resolve(__dirname, '..', '..'), + stdio: 'inherit', }); diff --git a/fixtures/eslint-v9/build.mjs b/fixtures/eslint-v9/build.mjs index ebcea15190dae..e0dd355ba4391 100644 --- a/fixtures/eslint-v9/build.mjs +++ b/fixtures/eslint-v9/build.mjs @@ -1,12 +1,13 @@ #!/usr/bin/env node -import {exec} from 'node:child_process'; +import {execSync} from 'node:child_process'; import {dirname, resolve} from 'node:path'; import {fileURLToPath} from 'node:url'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); -exec('yarn build -r stable eslint-plugin-react-hooks', { +execSync('yarn build -r stable eslint-plugin-react-hooks', { cwd: resolve(__dirname, '..', '..'), + stdio: 'inherit', }); diff --git a/package.json b/package.json index 156eba91a7a05..d30b4034e8ca8 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,8 @@ "@babel/plugin-transform-arrow-functions": "^7.10.4", "@babel/plugin-transform-block-scoped-functions": "^7.10.4", "@babel/plugin-transform-block-scoping": "^7.11.1", - "@babel/plugin-transform-classes": "^7.10.4", + "@babel/plugin-transform-class-properties": "^7.25.9", + "@babel/plugin-transform-classes": "^7.25.9", "@babel/plugin-transform-computed-properties": "^7.10.4", "@babel/plugin-transform-destructuring": "^7.10.4", "@babel/plugin-transform-for-of": "^7.10.4", diff --git a/scripts/rollup/build.js b/scripts/rollup/build.js index 874b5b139f37c..02aa167b6332c 100644 --- a/scripts/rollup/build.js +++ b/scripts/rollup/build.js @@ -12,6 +12,7 @@ const stripBanner = require('rollup-plugin-strip-banner'); const chalk = require('chalk'); const resolve = require('@rollup/plugin-node-resolve').nodeResolve; const fs = require('fs'); +const childProcess = require('child_process'); const argv = require('minimist')(process.argv.slice(2)); const Modules = require('./modules'); const Bundles = require('./bundles'); @@ -22,7 +23,7 @@ const useForks = require('./plugins/use-forks-plugin'); const dynamicImports = require('./plugins/dynamic-imports'); const Packaging = require('./packaging'); const {asyncRimRaf} = require('./utils'); -const codeFrame = require('@babel/code-frame'); +const codeFrame = require('@babel/code-frame').default; const Wrappers = require('./wrappers'); const RELEASE_CHANNEL = process.env.RELEASE_CHANNEL; @@ -812,6 +813,11 @@ function handleRollupError(error) { } } +function runShellCommand(command) { + console.log(chalk.dim('Running: ') + chalk.cyan(command)); + childProcess.execSync(command, {stdio: 'inherit', shell: true}); +} + async function buildEverything() { if (!argv['unsafe-partial']) { await asyncRimRaf('build'); @@ -859,6 +865,9 @@ async function buildEverything() { // eslint-disable-next-line no-for-of-loops/no-for-of-loops for (const [bundle, bundleType] of bundles) { + if (bundle.prebuild) { + runShellCommand(bundle.prebuild); + } await createBundle(bundle, bundleType); } diff --git a/yarn.lock b/yarn.lock index 7bc936afae4bd..ed53f3284334f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -103,6 +103,11 @@ resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.24.4.tgz#6f102372e9094f25d908ca0d34fc74c74606059a" integrity sha512-vg8Gih2MLK+kOkHJp4gBEIkyaIi00jgWot2D9QOmmfLC8jINSOzmCLta6Bvz/JSBCqnegV0L80jhxkol5GWNfQ== +"@babel/compat-data@^7.26.5": + version "7.26.8" + resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.26.8.tgz#821c1d35641c355284d4a870b8a4a7b0c141e367" + integrity sha512-oH5UPLMWR3L2wEFLnFJ1TZXqHufiTKAiLfqw5zkhS4dKXLJ10yVztfil/twG8EDTA4F/tvVNw9nOl4ZMslB8rQ== + "@babel/core@^7.0.0": version "7.20.12" resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.20.12.tgz#7930db57443c6714ad216953d1356dac0eb8496d" @@ -358,6 +363,17 @@ lru-cache "^5.1.1" semver "^6.3.1" +"@babel/helper-compilation-targets@^7.25.9": + version "7.26.5" + resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.26.5.tgz#75d92bb8d8d51301c0d49e52a65c9a7fe94514d8" + integrity sha512-IXuyn5EkouFJscIDuFF5EsiSolseme1s0CZB+QxVugqJLYmKdxI1VfIBOst0SUu4rnk2Z7kqTwmoO1lp3HIfnA== + dependencies: + "@babel/compat-data" "^7.26.5" + "@babel/helper-validator-option" "^7.25.9" + browserslist "^4.24.0" + lru-cache "^5.1.1" + semver "^6.3.1" + "@babel/helper-create-class-features-plugin@^7.10.4": version "7.10.5" resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.10.5.tgz#9f61446ba80e8240b0a5c85c6fdac8459d6f259d" @@ -740,7 +756,7 @@ "@babel/traverse" "^7.20.7" "@babel/types" "^7.20.7" -"@babel/helper-replace-supers@^7.26.5": +"@babel/helper-replace-supers@^7.25.9", "@babel/helper-replace-supers@^7.26.5": version "7.26.5" resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.26.5.tgz#6cb04e82ae291dae8e72335dfe438b0725f14c8d" integrity sha512-bJ6iIVdYX1YooY2X7w1q6VITt+LnUILtNk7zT78ykuwStx8BauCzxvFqFaHjOpW1bVnSUM1PN1f0p5P21wHxvg== @@ -1469,6 +1485,14 @@ dependencies: "@babel/helper-plugin-utils" "^7.10.4" +"@babel/plugin-transform-class-properties@^7.25.9": + version "7.25.9" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-class-properties/-/plugin-transform-class-properties-7.25.9.tgz#a8ce84fedb9ad512549984101fa84080a9f5f51f" + integrity sha512-bbMAII8GRSkcd0h0b4X+36GksxuheLFjP65ul9w6C3KgAamI3JqErNgSrosX6ZPj+Mpim5VvEbawXxJCyEUV3Q== + dependencies: + "@babel/helper-create-class-features-plugin" "^7.25.9" + "@babel/helper-plugin-utils" "^7.25.9" + "@babel/plugin-transform-classes@^7.0.0": version "7.20.7" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-classes/-/plugin-transform-classes-7.20.7.tgz#f438216f094f6bb31dc266ebfab8ff05aecad073" @@ -1498,6 +1522,18 @@ "@babel/helper-split-export-declaration" "^7.10.4" globals "^11.1.0" +"@babel/plugin-transform-classes@^7.25.9": + version "7.25.9" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-classes/-/plugin-transform-classes-7.25.9.tgz#7152457f7880b593a63ade8a861e6e26a4469f52" + integrity sha512-mD8APIXmseE7oZvZgGABDyM34GUmK45Um2TXiBUt7PnuAxrgoSVf123qUzPxEr/+/BHrRn5NMZCdE2m/1F8DGg== + dependencies: + "@babel/helper-annotate-as-pure" "^7.25.9" + "@babel/helper-compilation-targets" "^7.25.9" + "@babel/helper-plugin-utils" "^7.25.9" + "@babel/helper-replace-supers" "^7.25.9" + "@babel/traverse" "^7.25.9" + globals "^11.1.0" + "@babel/plugin-transform-computed-properties@^7.0.0": version "7.20.7" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.20.7.tgz#704cc2fd155d1c996551db8276d55b9d46e4d0aa" @@ -5480,6 +5516,16 @@ browserslist@^4.21.3, browserslist@^4.22.2: node-releases "^2.0.14" update-browserslist-db "^1.0.13" +browserslist@^4.24.0: + version "4.24.4" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.24.4.tgz#c6b2865a3f08bcb860a0e827389003b9fe686e4b" + integrity sha512-KDi1Ny1gSePi1vm0q4oxSF8b4DR44GF4BbmS2YdhPLOEqd8pDviZOGH/GsmRwoWJ2+5Lr085X7naowMwKHDG1A== + dependencies: + caniuse-lite "^1.0.30001688" + electron-to-chromium "^1.5.73" + node-releases "^2.0.19" + update-browserslist-db "^1.1.1" + browserslist@^4.8.3: version "4.8.5" resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.8.5.tgz#691af4e327ac877b25e7a3f7ee869c4ef36cdea3" @@ -5758,6 +5804,11 @@ caniuse-lite@^1.0.30001449, caniuse-lite@^1.0.30001587: resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001616.tgz#4342712750d35f71ebba9fcac65e2cf8870013c3" integrity sha512-RHVYKov7IcdNjVHJFNY/78RdG4oGVjbayxv8u5IO74Wv7Hlq4PnJE6mo/OjFijjVFNy5ijnCt6H3IIo4t+wfEw== +caniuse-lite@^1.0.30001688: + version "1.0.30001703" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001703.tgz#977cb4920598c158f491ecf4f4f2cfed9e354718" + integrity sha512-kRlAGTRWgPsOj7oARC9m1okJEXdL/8fekFVcxA8Hl7GH4r/sN4OJn/i6Flde373T50KS7Y37oFbMwlE8+F42kQ== + capture-stack-trace@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/capture-stack-trace/-/capture-stack-trace-1.0.1.tgz#a6c0bbe1f38f3aa0b92238ecb6ff42c344d4135d" @@ -7310,6 +7361,11 @@ electron-to-chromium@^1.4.284, electron-to-chromium@^1.4.668: resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.758.tgz#f39e530cae2ca4329a0f0e1840629d8d1da73156" integrity sha512-/o9x6TCdrYZBMdGeTifAP3wlF/gVT+TtWJe3BSmtNh92Mw81U9hrYwW9OAGUh+sEOX/yz5e34sksqRruZbjYrw== +electron-to-chromium@^1.5.73: + version "1.5.115" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.115.tgz#193dd534948b3ea77e3d95dd38ca12cdc01c76a9" + integrity sha512-MN1nahVHAQMOz6dz6bNZ7apgqc9InZy7Ja4DBEVCTdeiUcegbyOYE9bi/f2Z/z6ZxLi0RxLpyJ3EGe+4h3w73A== + electron@^23.1.2: version "23.1.2" resolved "https://registry.yarnpkg.com/electron/-/electron-23.1.2.tgz#f03e361c94f8dd2407963b5461d19aadea335316" @@ -7537,6 +7593,11 @@ escalade@^3.1.1, escalade@^3.1.2: resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.2.tgz#54076e9ab29ea5bf3d8f1ed62acffbb88272df27" integrity sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA== +escalade@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.2.0.tgz#011a3f69856ba189dffa7dc8fcce99d2a87903e5" + integrity sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA== + escape-goat@^2.0.0: version "2.1.1" resolved "https://registry.yarnpkg.com/escape-goat/-/escape-goat-2.1.1.tgz#1b2dc77003676c457ec760b2dc68edb648188675" @@ -12534,6 +12595,11 @@ node-releases@^2.0.14, node-releases@^2.0.8: resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.14.tgz#2ffb053bceb8b2be8495ece1ab6ce600c4461b0b" integrity sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw== +node-releases@^2.0.19: + version "2.0.19" + resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.19.tgz#9e445a52950951ec4d177d843af370b411caf314" + integrity sha512-xxOWJsBKtzAq7DY0J+DTzuz58K8e7sJbdgwkbMWQe8UYB6ekmsQ45q0M/tJDsGaZmbC+l7n57UV8Hl5tHxO9uw== + node-rsa@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/node-rsa/-/node-rsa-1.0.5.tgz#854dc1b275729d69bc25883f83ca80705db9262e" @@ -13366,6 +13432,11 @@ picocolors@^1.0.0: resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== +picocolors@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.1.1.tgz#3d321af3eab939b083c8f929a1d12cda81c26b6b" + integrity sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA== + picomatch@^2.0.4, picomatch@^2.2.3, picomatch@^2.3.1: version "2.3.1" resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" @@ -16544,6 +16615,14 @@ update-browserslist-db@^1.0.10, update-browserslist-db@^1.0.13: escalade "^3.1.2" picocolors "^1.0.0" +update-browserslist-db@^1.1.1: + version "1.1.3" + resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.1.3.tgz#348377dd245216f9e7060ff50b15a1b740b75420" + integrity sha512-UxhIZQ+QInVdunkDAaiazvvT/+fXL5Osr0JZlJulepYu6Jd7qJtDZjlur0emRlT71EN3ScPoE7gvsuIKKNavKw== + dependencies: + escalade "^3.2.0" + picocolors "^1.1.1" + update-notifier@4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/update-notifier/-/update-notifier-4.1.0.tgz#4866b98c3bc5b5473c020b1250583628f9a328f3"