@samitouri / QOS-React / commits / 9d530e94c4

[compiler:babel] Don't read config files when not running as part of user's pipeline

[compiler:babel] Don't read config files when not running as part of user's pipeline When the user app has a babel.config file that is missing the compiler, strange things happen as babel does some strange merging of options from the user's config and in various callsites like in our eslint rule and healthcheck script. To minimize odd behavior, we default to not reading the user's babel.config Fixes #29135 ghstack-source-id: d6fdc43c5c9107645f36718203873aa3f6228475 Pull Request resolved: https://github.com/facebook/react/pull/29211

Lauren Tan committed May 29, 2024 at 11:41 UTC 9d530e94c40a9adf3fbf24390ee09f10dc5dcc2d
4 files changed +12
compiler/packages/babel-plugin-react-compiler/src/Babel/RunReactCompilerBabelPlugin.ts
+2
@@ -36,6 +36,8 @@ export function runBabelPluginReactCompiler(
36 "babel-plugin-fbt-runtime",
37 ],
38 sourceType: "module",
39 + configFile: false,
40 + babelrc: false,
41 });
42 invariant(
43 result?.code != null,
compiler/packages/eslint-plugin-react-compiler/src/rules/ReactCompilerRule.ts
+2
@@ -143,6 +143,8 @@ const rule: Rule.RuleModule = {
143 [BabelPluginReactCompiler, options],
144 ],
145 sourceType: "module",
146 + configFile: false,
147 + babelrc: false,
148 });
149 } catch (err) {
150 if (isReactCompilerError(err) && Array.isArray(err.details)) {
compiler/packages/react-compiler-healthcheck/src/checks/reactCompiler.ts
+2
@@ -85,6 +85,8 @@ function runBabelPluginReactCompiler(
85 retainLines: true,
86 plugins: [[BabelPluginReactCompiler, options]],
87 sourceType: "module",
88 + configFile: false,
89 + babelrc: false,
90 });
91 if (result?.code == null) {
92 throw new Error(
compiler/packages/snap/src/compiler.ts
+6
@@ -333,6 +333,8 @@ export async function transformFixtureInput(
333 sourceType: "module",
334 ast: includeEvaluator,
335 cloneInputAst: includeEvaluator,
336 + configFile: false,
337 + babelrc: false,
338 });
339 invariant(
340 forgetResult?.code != null,
@@ -355,6 +357,8 @@ export async function transformFixtureInput(
357 const result = transformFromAstSync(forgetResult.ast, forgetOutput, {
358 presets,
359 filename: virtualFilepath,
360 + configFile: false,
361 + babelrc: false,
362 });
363 if (result?.code == null) {
364 return {
@@ -379,6 +383,8 @@ export async function transformFixtureInput(
383 const result = transformFromAstSync(inputAst, input, {
384 presets,
385 filename: virtualFilepath,
386 + configFile: false,
387 + babelrc: false,
388 });
389
390 if (result?.code == null) {