Skip to content

Commit 564ca66

Browse files
Set rootMode: "root" in loadPartialConfig (#13040)
1 parent b784c81 commit 564ca66

4 files changed

Lines changed: 22 additions & 0 deletions

File tree

packages/babel-core/src/config/partial.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ export default function* loadPrivatePartialConfig(
139139
envName: context.envName,
140140
cwd: context.cwd,
141141
root: context.root,
142+
rootMode: "root",
142143
filename:
143144
typeof context.filename === "string" ? context.filename : undefined,
144145

packages/babel-core/test/config-chain.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,7 @@ describe("buildConfigChain", function () {
982982
browserslistConfigFile: false,
983983
cwd: process.cwd(),
984984
root: process.cwd(),
985+
rootMode: "root",
985986
envName: "development",
986987
passPerPreset: false,
987988
plugins: [],

packages/babel-core/test/config-loading.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,25 @@ describe("@babel/core config loading", () => {
118118
expect(item.value).toBe(preset);
119119
expect(item.options).toBe(false);
120120
});
121+
122+
it("should always set 'rootMode' to 'root'", async () => {
123+
const cwd = path.join(
124+
path.dirname(fileURLToPath(import.meta.url)),
125+
"fixtures",
126+
"config-loading",
127+
"root",
128+
"nested",
129+
);
130+
131+
const { options } = await loadPartialConfig({
132+
cwd,
133+
filename: path.join(cwd, "file.js"),
134+
rootMode: "upward",
135+
});
136+
137+
expect(options.root).toBe(path.join(cwd, ".."));
138+
expect(options.rootMode).toBe("root");
139+
});
121140
});
122141

123142
describe("config file", () => {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

0 commit comments

Comments
 (0)