Skip to content

Commit

Permalink
[compiler:babel] Don't read config files when not running as part of
Browse files Browse the repository at this point in the history
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: #29211
  • Loading branch information
poteto committed May 29, 2024
1 parent 2e15dae commit ccc3d6f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export function runBabelPluginReactCompiler(
"babel-plugin-fbt-runtime",
],
sourceType: "module",
configFile: false,
babelrc: false,
});
invariant(
result?.code != null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ const rule: Rule.RuleModule = {
[BabelPluginReactCompiler, options],
],
sourceType: "module",
configFile: false,
babelrc: false,
});
} catch (err) {
if (isReactCompilerError(err) && Array.isArray(err.details)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ function runBabelPluginReactCompiler(
retainLines: true,
plugins: [[BabelPluginReactCompiler, options]],
sourceType: "module",
configFile: false,
babelrc: false,
});
if (result?.code == null) {
throw new Error(
Expand Down
6 changes: 6 additions & 0 deletions compiler/packages/snap/src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@ export async function transformFixtureInput(
sourceType: "module",
ast: includeEvaluator,
cloneInputAst: includeEvaluator,
configFile: false,
babelrc: false,
});
invariant(
forgetResult?.code != null,
Expand All @@ -355,6 +357,8 @@ export async function transformFixtureInput(
const result = transformFromAstSync(forgetResult.ast, forgetOutput, {
presets,
filename: virtualFilepath,
configFile: false,
babelrc: false,
});
if (result?.code == null) {
return {
Expand All @@ -379,6 +383,8 @@ export async function transformFixtureInput(
const result = transformFromAstSync(inputAst, input, {
presets,
filename: virtualFilepath,
configFile: false,
babelrc: false,
});

if (result?.code == null) {
Expand Down

0 comments on commit ccc3d6f

Please sign in to comment.