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: 86daa0bc2390e02682675bc2fccb0bd83b64b7ac
Pull Request resolved: #29211
  • Loading branch information
poteto committed May 29, 2024
1 parent cd570f1 commit cdae1c4
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 1 deletion.
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 @@ -144,6 +144,7 @@ const rule: Rule.RuleModule = {
],
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 @@ -86,6 +86,7 @@ function runBabelPluginReactCompiler(
plugins: [[BabelPluginReactCompiler, options]],
sourceType: "module",
configFile: false,
babelrc: false,
});
if (result?.code == null) {
throw new Error(
Expand Down
3 changes: 3 additions & 0 deletions compiler/packages/snap/src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ export async function transformFixtureInput(
ast: includeEvaluator,
cloneInputAst: includeEvaluator,
configFile: false,
babelrc: false,
});
invariant(
forgetResult?.code != null,
Expand All @@ -357,6 +358,7 @@ export async function transformFixtureInput(
presets,
filename: virtualFilepath,
configFile: false,
babelrc: false,
});
if (result?.code == null) {
return {
Expand All @@ -382,6 +384,7 @@ export async function transformFixtureInput(
presets,
filename: virtualFilepath,
configFile: false,
babelrc: false,
});

if (result?.code == null) {
Expand Down
4 changes: 3 additions & 1 deletion scripts/jest/preprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ module.exports = {
sourceAst,
src,
Object.assign(
{filename: path.relative(process.cwd(), filePath)},
{
filename: path.relative(process.cwd(), filePath),
},
babelOptions,
{
plugins,
Expand Down

0 comments on commit cdae1c4

Please sign in to comment.