Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only resolve package.json when relative configs are enabled #13063

Merged
merged 1 commit into from Mar 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
73 changes: 37 additions & 36 deletions packages/babel-core/src/config/config-chain.js
Expand Up @@ -201,56 +201,57 @@ export function* buildRootChain(
mergeChain(configFileChain, result);
}

const pkgData =
typeof context.filename === "string"
? yield* findPackageData(context.filename)
: null;

let ignoreFile, babelrcFile;
let isIgnored = false;
const fileChain = emptyChain();
// resolve all .babelrc files
if (
(babelrc === true || babelrc === undefined) &&
pkgData &&
babelrcLoadEnabled(context, pkgData, babelrcRoots, babelrcRootsDirectory)
typeof context.filename === "string"
) {
({ ignore: ignoreFile, config: babelrcFile } = yield* findRelativeConfig(
pkgData,
context.envName,
context.caller,
));

if (ignoreFile) {
fileChain.files.add(ignoreFile.filepath);
}
const pkgData = yield* findPackageData(context.filename);

if (
ignoreFile &&
shouldIgnore(context, ignoreFile.ignore, null, ignoreFile.dirname)
pkgData &&
babelrcLoadEnabled(context, pkgData, babelrcRoots, babelrcRootsDirectory)
) {
isIgnored = true;
}
({ ignore: ignoreFile, config: babelrcFile } = yield* findRelativeConfig(
pkgData,
context.envName,
context.caller,
));

if (ignoreFile) {
fileChain.files.add(ignoreFile.filepath);
}

if (babelrcFile && !isIgnored) {
const validatedFile = validateBabelrcFile(babelrcFile);
const babelrcLogger = new ConfigPrinter();
const result = yield* loadFileChain(
validatedFile,
context,
undefined,
babelrcLogger,
);
if (!result) {
if (
ignoreFile &&
shouldIgnore(context, ignoreFile.ignore, null, ignoreFile.dirname)
) {
isIgnored = true;
} else {
babelRcReport = yield* babelrcLogger.output();
mergeChain(fileChain, result);
}
}

if (babelrcFile && isIgnored) {
fileChain.files.add(babelrcFile.filepath);
if (babelrcFile && !isIgnored) {
const validatedFile = validateBabelrcFile(babelrcFile);
const babelrcLogger = new ConfigPrinter();
const result = yield* loadFileChain(
validatedFile,
context,
undefined,
babelrcLogger,
);
if (!result) {
isIgnored = true;
} else {
babelRcReport = yield* babelrcLogger.output();
mergeChain(fileChain, result);
}
}

if (babelrcFile && isIgnored) {
fileChain.files.add(babelrcFile.filepath);
}
}
}

Expand Down