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

ghstack-source-id: 88a3958db2c6332167c00c9413645b1d14d848f4
Pull Request resolved: #29211
  • Loading branch information
poteto committed May 22, 2024
1 parent 3ac551e commit 674f2db
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export function runBabelPluginReactCompiler(
"babel-plugin-fbt-runtime",
],
sourceType: "module",
configFile: false
});
invariant(
result?.code != null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ const rule: Rule.RuleModule = {
[BabelPluginReactCompiler, options],
],
sourceType: "module",
configFile: 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,7 @@ function runBabelPluginReactCompiler(
retainLines: true,
plugins: [[BabelPluginReactCompiler, options]],
sourceType: "module",
configFile: false
});
if (result?.code == null) {
throw new Error(
Expand Down Expand Up @@ -140,7 +141,7 @@ export default {
report(): void {
const totalComponents =
SucessfulCompilation.length +
countUniqueLocInEvents(OtherFailures) +
countUniqueLocInEvents(OtherFailures) +
countUniqueLocInEvents(ActionableFailures)
console.log(
chalk.green(
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 @@ -327,6 +327,7 @@ export function transformFixtureInput(
sourceType: "module",
ast: includeEvaluator,
cloneInputAst: includeEvaluator,
configFile: false
});
invariant(
forgetResult?.code != null,
Expand All @@ -349,6 +350,7 @@ export function transformFixtureInput(
const result = transformFromAstSync(forgetResult.ast, forgetOutput, {
presets,
filename: virtualFilepath,
configFile: false
});
if (result?.code == null) {
return {
Expand All @@ -373,6 +375,7 @@ export function transformFixtureInput(
const result = transformFromAstSync(inputAst, input, {
presets,
filename: virtualFilepath,
configFile: false
});

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

0 comments on commit 674f2db

Please sign in to comment.