Fix: config lookup logic in babel-core (#5550)
This fixes a bug that was causing the config lookup to stop when a package.json file was found even if it did not contain a "babel" key.
This commit is contained in:
parent
7a1ccf076c
commit
1f2f63ccdf
@ -163,7 +163,7 @@ class ConfigChainBuilder {
|
||||
this.errorMultipleConfigs(arr.pop(), config);
|
||||
}
|
||||
|
||||
arr.push(config);
|
||||
if (configAdded) arr.push(config);
|
||||
}
|
||||
|
||||
return arr;
|
||||
|
||||
@ -128,6 +128,59 @@ describe("buildConfigChain", function () {
|
||||
assert.deepEqual(chain, expected);
|
||||
});
|
||||
|
||||
it("dir3", function () {
|
||||
const chain = buildConfigChain({
|
||||
filename: fixture("dir3", "src.js"),
|
||||
});
|
||||
|
||||
const expected = [
|
||||
{
|
||||
type: "options",
|
||||
options: {
|
||||
plugins: [
|
||||
"extended",
|
||||
],
|
||||
},
|
||||
alias: fixture("extended.babelrc.json"),
|
||||
loc: fixture("extended.babelrc.json"),
|
||||
dirname: fixture(),
|
||||
},
|
||||
{
|
||||
type: "options",
|
||||
options: {
|
||||
plugins: [
|
||||
"root",
|
||||
],
|
||||
},
|
||||
alias: fixture(".babelrc"),
|
||||
loc: fixture(".babelrc"),
|
||||
dirname: fixture(),
|
||||
},
|
||||
{
|
||||
type: "options",
|
||||
options: {
|
||||
ignore: [
|
||||
"root-ignore",
|
||||
],
|
||||
},
|
||||
alias: fixture(".babelignore"),
|
||||
loc: fixture(".babelignore"),
|
||||
dirname: fixture(),
|
||||
},
|
||||
{
|
||||
type: "arguments",
|
||||
options: {
|
||||
filename: fixture("dir3", "src.js"),
|
||||
},
|
||||
alias: "base",
|
||||
loc: "base",
|
||||
dirname: base(),
|
||||
},
|
||||
];
|
||||
|
||||
assert.deepEqual(chain, expected);
|
||||
});
|
||||
|
||||
it("env - base", function () {
|
||||
const chain = buildConfigChain({
|
||||
filename: fixture("env", "src.js"),
|
||||
|
||||
5
packages/babel-core/test/fixtures/config/dir3/package.json
vendored
Normal file
5
packages/babel-core/test/fixtures/config/dir3/package.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
{
|
||||
"name": "application-name",
|
||||
"version": "0.0.1"
|
||||
}
|
||||
1
packages/babel-core/test/fixtures/config/dir3/src.js
vendored
Normal file
1
packages/babel-core/test/fixtures/config/dir3/src.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
// empty
|
||||
Loading…
x
Reference in New Issue
Block a user