Skip to content

Commit

Permalink
Set rootMode: "root" in loadPartialConfig (#13040)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Mar 23, 2021
1 parent b784c81 commit 564ca66
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/babel-core/src/config/partial.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export default function* loadPrivatePartialConfig(
envName: context.envName,
cwd: context.cwd,
root: context.root,
rootMode: "root",
filename:
typeof context.filename === "string" ? context.filename : undefined,

Expand Down
1 change: 1 addition & 0 deletions packages/babel-core/test/config-chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,7 @@ describe("buildConfigChain", function () {
browserslistConfigFile: false,
cwd: process.cwd(),
root: process.cwd(),
rootMode: "root",
envName: "development",
passPerPreset: false,
plugins: [],
Expand Down
19 changes: 19 additions & 0 deletions packages/babel-core/test/config-loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,25 @@ describe("@babel/core config loading", () => {
expect(item.value).toBe(preset);
expect(item.options).toBe(false);
});

it("should always set 'rootMode' to 'root'", async () => {
const cwd = path.join(
path.dirname(fileURLToPath(import.meta.url)),
"fixtures",
"config-loading",
"root",
"nested",
);

const { options } = await loadPartialConfig({
cwd,
filename: path.join(cwd, "file.js"),
rootMode: "upward",
});

expect(options.root).toBe(path.join(cwd, ".."));
expect(options.rootMode).toBe("root");
});
});

describe("config file", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}

0 comments on commit 564ca66

Please sign in to comment.