[forgive] Various fixes to prepare for internal sync (#34928)
Fixes a few small things: - Update imports to reference root babel-plugin-react-compiler rather than from `[...]/src/...` - Remove unused cosmiconfig options parsing for now - Update type exports in babel-plugin-react-compiler accordingly
lauren committed
Oct 21, 2025 at 10:57 UTC
71b3a03cc936c8eb30a6e6108abf5550f5037f71
9 files changed
+15
-123
compiler/packages/babel-plugin-react-compiler/src/index.ts
+3
@@ -29,10 +29,13 @@ export {
29
ProgramContext,
30
tryFindDirectiveEnablingMemoization as findDirectiveEnablingMemoization,
31
findDirectiveDisablingMemoization,
32
+ defaultOptions,
33
type CompilerPipelineValue,
34
type Logger,
35
type LoggerEvent,
36
type PluginOptions,
37
+ type AutoDepsDecorationsEvent,
38
+ type CompileSuccessEvent,
39
} from './Entrypoint';
40
export {
41
Effect,
compiler/packages/react-forgive/package.json
+2
-1
@@ -36,13 +36,14 @@
36
},
37
"scripts": {
38
"build": "yarn run compile",
39
+ "build:compiler": "yarn workspace babel-plugin-react-compiler build --dts",
40
"compile": "rimraf dist && concurrently -n server,client \"scripts/build.mjs -t server\" \"scripts/build.mjs -t client\"",
41
"dev": "yarn run package && yarn run install-ext",
42
"install-ext": "code --install-extension react-forgive-0.0.0.vsix",
43
"lint": "echo 'no tests'",
44
"package": "rm -f react-forgive-0.0.0.vsix && vsce package --yarn",
45
"postinstall": "cd client && yarn install && cd ../server && yarn install && cd ..",
45
- "pretest": "yarn run compile && yarn run lint",
46
+ "pretest": "yarn run build:compiler && yarn run compile && yarn run lint",
47
"test": "vscode-test",
48
"vscode:prepublish": "yarn run compile",
49
"watch": "scripts/build.mjs --watch"
compiler/packages/react-forgive/server/package.json
-1
@@ -18,7 +18,6 @@
18
"@babel/parser": "^7.26.0",
19
"@babel/plugin-syntax-typescript": "^7.25.9",
20
"@babel/types": "^7.26.0",
21
- "cosmiconfig": "^9.0.0",
21
"prettier": "^3.3.3",
22
"vscode-languageserver": "^9.0.1",
23
"vscode-languageserver-textdocument": "^1.0.12"
compiler/packages/react-forgive/server/src/compiler/compat.ts
+1
-1
@@ -5,7 +5,7 @@
5
* LICENSE file in the root directory of this source tree.
6
*/
7
8
-import {SourceLocation} from 'babel-plugin-react-compiler/src';
8
+import {type SourceLocation} from 'babel-plugin-react-compiler';
9
import {type Range} from 'vscode-languageserver';
10
11
export function babelLocationToRange(loc: SourceLocation): Range | null {
compiler/packages/react-forgive/server/src/compiler/index.ts
+1
-1
@@ -9,7 +9,7 @@ import type * as BabelCore from '@babel/core';
9
import {parseAsync, transformFromAstAsync} from '@babel/core';
10
import BabelPluginReactCompiler, {
11
type PluginOptions,
12
-} from 'babel-plugin-react-compiler/src';
12
+} from 'babel-plugin-react-compiler';
13
import * as babelParser from 'prettier/plugins/babel.js';
14
import estreeParser from 'prettier/plugins/estree';
15
import * as typescriptParser from 'prettier/plugins/typescript';
compiler/packages/react-forgive/server/src/compiler/options.ts
deleted
-25
@@ -1,25 +0,0 @@
1
-/**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
-import {
9
- parsePluginOptions,
10
- type PluginOptions,
11
-} from 'babel-plugin-react-compiler/src';
12
-import {cosmiconfigSync} from 'cosmiconfig';
13
-
14
-export function resolveReactConfig(projectPath: string): PluginOptions | null {
15
- const explorerSync = cosmiconfigSync('react', {
16
- searchStrategy: 'project',
17
- cache: true,
18
- });
19
- const result = explorerSync.search(projectPath);
20
- if (result != null) {
21
- return parsePluginOptions(result.config);
22
- } else {
23
- return null;
24
- }
25
-}
compiler/packages/react-forgive/server/src/index.ts
+6
-8
@@ -20,13 +20,12 @@ import {
20
TextDocumentSyncKind,
21
} from 'vscode-languageserver/node';
22
import {compile, lastResult} from './compiler';
23
-import {type PluginOptions} from 'babel-plugin-react-compiler/src';
24
-import {resolveReactConfig} from './compiler/options';
23
import {
24
type CompileSuccessEvent,
25
type LoggerEvent,
26
+ type PluginOptions,
27
defaultOptions,
29
-} from 'babel-plugin-react-compiler/src/Entrypoint/Options';
28
+} from 'babel-plugin-react-compiler';
29
import {babelLocationToRange, getRangeFirstCharacter} from './compiler/compat';
30
import {
31
type AutoDepsDecorationsLSPEvent,
@@ -64,8 +63,7 @@ type CodeActionLSPEvent = {
63
};
64
65
connection.onInitialize((_params: InitializeParams) => {
67
- // TODO(@poteto) get config fr
68
- compilerOptions = resolveReactConfig('.') ?? defaultOptions;
66
+ compilerOptions = defaultOptions;
67
compilerOptions = {
68
...compilerOptions,
69
environment: {
@@ -76,21 +74,21 @@ connection.onInitialize((_params: InitializeParams) => {
74
importSpecifierName: 'useEffect',
75
source: 'react',
76
},
79
- numRequiredArgs: 1,
77
+ autodepsIndex: 1,
78
},
79
{
80
function: {
81
importSpecifierName: 'useSpecialEffect',
82
source: 'shared-runtime',
83
},
86
- numRequiredArgs: 2,
84
+ autodepsIndex: 2,
85
},
86
{
87
function: {
88
importSpecifierName: 'default',
89
source: 'useEffectWrapper',
90
},
93
- numRequiredArgs: 1,
91
+ autodepsIndex: 1,
92
},
93
],
94
},
compiler/packages/react-forgive/server/src/requests/autodepsdecorations.ts
+1
-1
@@ -5,7 +5,7 @@
5
* LICENSE file in the root directory of this source tree.
6
*/
7
8
-import {type AutoDepsDecorationsEvent} from 'babel-plugin-react-compiler/src/Entrypoint';
8
+import {type AutoDepsDecorationsEvent} from 'babel-plugin-react-compiler';
9
import {type Position} from 'vscode-languageserver-textdocument';
10
import {RequestType} from 'vscode-languageserver/node';
11
import {type Range, sourceLocationToRange} from '../utils/range';
compiler/packages/react-forgive/server/yarn.lock
+1
-85
@@ -10,7 +10,7 @@
10
"@jridgewell/gen-mapping" "^0.3.5"
11
"@jridgewell/trace-mapping" "^0.3.24"
12
13
-"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.25.9", "@babel/code-frame@^7.26.0", "@babel/code-frame@^7.26.2":
13
+"@babel/code-frame@^7.25.9", "@babel/code-frame@^7.26.0", "@babel/code-frame@^7.26.2":
14
version "7.26.2"
15
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.26.2.tgz#4b5fab97d33338eff916235055f0ebc21e573a85"
16
integrity sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ==
@@ -188,11 +188,6 @@
188
"@jridgewell/resolve-uri" "^3.1.0"
189
"@jridgewell/sourcemap-codec" "^1.4.14"
190
191
-argparse@^2.0.1:
192
- version "2.0.1"
193
- resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38"
194
- integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==
195
-
191
browserslist@^4.24.0:
192
version "4.24.3"
193
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.24.3.tgz#5fc2725ca8fb3c1432e13dac278c7cc103e026d2"
@@ -203,11 +198,6 @@ browserslist@^4.24.0:
198
node-releases "^2.0.19"
199
update-browserslist-db "^1.1.1"
200
206
-callsites@^3.0.0:
207
- version "3.1.0"
208
- resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73"
209
- integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==
210
-
201
caniuse-lite@^1.0.30001688:
202
version "1.0.30001690"
203
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001690.tgz#f2d15e3aaf8e18f76b2b8c1481abde063b8104c8"
@@ -218,16 +208,6 @@ convert-source-map@^2.0.0:
208
resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-2.0.0.tgz#4b560f649fc4e918dd0ab75cf4961e8bc882d82a"
209
integrity sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==
210
221
-cosmiconfig@^9.0.0:
222
- version "9.0.0"
223
- resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-9.0.0.tgz#34c3fc58287b915f3ae905ab6dc3de258b55ad9d"
224
- integrity sha512-itvL5h8RETACmOTFc4UfIyB2RfEHi71Ax6E/PivVxq9NseKbOWpeyHEOIbmAw1rs8Ak0VursQNww7lf7YtUwzg==
225
- dependencies:
226
- env-paths "^2.2.1"
227
- import-fresh "^3.3.0"
228
- js-yaml "^4.1.0"
229
- parse-json "^5.2.0"
230
-
211
debug@^4.1.0, debug@^4.3.1:
212
version "4.4.0"
213
resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.0.tgz#2b3f2aea2ffeb776477460267377dc8710faba8a"
@@ -240,18 +220,6 @@ electron-to-chromium@^1.5.73:
220
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.74.tgz#cb886b504a6467e4c00bea3317edb38393c53413"
221
integrity sha512-ck3//9RC+6oss/1Bh9tiAVFy5vfSKbRHAFh7Z3/eTRkEqJeWgymloShB17Vg3Z4nmDNp35vAd1BZ6CMW4Wt6Iw==
222
243
-env-paths@^2.2.1:
244
- version "2.2.1"
245
- resolved "https://registry.yarnpkg.com/env-paths/-/env-paths-2.2.1.tgz#420399d416ce1fbe9bc0a07c62fa68d67fd0f8f2"
246
- integrity sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==
247
-
248
-error-ex@^1.3.1:
249
- version "1.3.2"
250
- resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf"
251
- integrity sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==
252
- dependencies:
253
- is-arrayish "^0.2.1"
254
-
223
escalade@^3.2.0:
224
version "3.2.0"
225
resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.2.0.tgz#011a3f69856ba189dffa7dc8fcce99d2a87903e5"
@@ -267,51 +235,21 @@ globals@^11.1.0:
235
resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e"
236
integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==
237
270
-import-fresh@^3.3.0:
271
- version "3.3.0"
272
- resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.0.tgz#37162c25fcb9ebaa2e6e53d5b4d88ce17d9e0c2b"
273
- integrity sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==
274
- dependencies:
275
- parent-module "^1.0.0"
276
- resolve-from "^4.0.0"
277
-
278
-is-arrayish@^0.2.1:
279
- version "0.2.1"
280
- resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d"
281
- integrity sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==
282
-
238
js-tokens@^4.0.0:
239
version "4.0.0"
240
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
241
integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==
242
288
-js-yaml@^4.1.0:
289
- version "4.1.0"
290
- resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602"
291
- integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==
292
- dependencies:
293
- argparse "^2.0.1"
294
-
243
jsesc@^3.0.2:
244
version "3.1.0"
245
resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-3.1.0.tgz#74d335a234f67ed19907fdadfac7ccf9d409825d"
246
integrity sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==
247
300
-json-parse-even-better-errors@^2.3.0:
301
- version "2.3.1"
302
- resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d"
303
- integrity sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==
304
-
248
json5@^2.2.3:
249
version "2.2.3"
250
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283"
251
integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==
252
310
-lines-and-columns@^1.1.6:
311
- version "1.2.4"
312
- resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632"
313
- integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==
314
-
253
lru-cache@^5.1.1:
254
version "5.1.1"
255
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920"
@@ -329,23 +267,6 @@ node-releases@^2.0.19:
267
resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.19.tgz#9e445a52950951ec4d177d843af370b411caf314"
268
integrity sha512-xxOWJsBKtzAq7DY0J+DTzuz58K8e7sJbdgwkbMWQe8UYB6ekmsQ45q0M/tJDsGaZmbC+l7n57UV8Hl5tHxO9uw==
269
332
-parent-module@^1.0.0:
333
- version "1.0.1"
334
- resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2"
335
- integrity sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==
336
- dependencies:
337
- callsites "^3.0.0"
338
-
339
-parse-json@^5.2.0:
340
- version "5.2.0"
341
- resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-5.2.0.tgz#c76fc66dee54231c962b22bcc8a72cf2f99753cd"
342
- integrity sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==
343
- dependencies:
344
- "@babel/code-frame" "^7.0.0"
345
- error-ex "^1.3.1"
346
- json-parse-even-better-errors "^2.3.0"
347
- lines-and-columns "^1.1.6"
348
-
270
picocolors@^1.0.0, picocolors@^1.1.0:
271
version "1.1.1"
272
resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.1.1.tgz#3d321af3eab939b083c8f929a1d12cda81c26b6b"
@@ -356,11 +277,6 @@ prettier@^3.3.3:
277
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.4.2.tgz#a5ce1fb522a588bf2b78ca44c6e6fe5aa5a2b13f"
278
integrity sha512-e9MewbtFo+Fevyuxn/4rrcDAaq0IYxPGLvObpQjiZBMAzB9IGmzlnG9RZy3FFas+eBMu2vA0CszMeduow5dIuQ==
279
359
-resolve-from@^4.0.0:
360
- version "4.0.0"
361
- resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6"
362
- integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==
363
-
280
semver@^6.3.1:
281
version "6.3.1"
282
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4"