Skip to content

Commit 0b92084

Browse files
committed
Use fileHandling option instead of isIgnored
1 parent 7028627 commit 0b92084

4 files changed

Lines changed: 20 additions & 15 deletions

File tree

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,12 @@ const loadPresetOverridesEnvDescriptors = makeWeakCacheSync(
126126
),
127127
);
128128

129+
export type FileHandling = "transpile" | "ignored" | "unsupported";
129130
export type RootConfigChain = ConfigChain & {
130131
babelrc: ConfigFile | void,
131132
config: ConfigFile | void,
132133
ignore: IgnoreFile | void,
133-
isIgnored: boolean,
134+
fileHandling: FileHandling,
134135
files: Set<string>,
135136
};
136137

@@ -275,7 +276,7 @@ export function* buildRootChain(
275276
plugins: isIgnored ? [] : dedupDescriptors(chain.plugins),
276277
presets: isIgnored ? [] : dedupDescriptors(chain.presets),
277278
options: isIgnored ? [] : chain.options.map(o => normalizeOptions(o)),
278-
isIgnored,
279+
fileHandling: isIgnored ? "ignored" : "transpile",
279280
ignore: ignoreFile || undefined,
280281
babelrc: babelrcFile || undefined,
281282
config: configFile || undefined,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ export default gensync<[any], ResolvedConfig | null>(function* loadFullConfig(
6363
if (!result) {
6464
return null;
6565
}
66-
const { options, context, isIgnored } = result;
66+
const { options, context, fileHandling } = result;
6767

68-
if (isIgnored) {
68+
if (fileHandling === "ignored") {
6969
return null;
7070
}
7171

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ import gensync, { type Handler } from "gensync";
55
import Plugin from "./plugin";
66
import { mergeOptions } from "./util";
77
import { createItemFromDescriptor } from "./item";
8-
import { buildRootChain, type ConfigContext } from "./config-chain";
8+
import {
9+
buildRootChain,
10+
type ConfigContext,
11+
type FileHandling,
12+
} from "./config-chain";
913
import { getEnv } from "./helpers/environment";
1014
import {
1115
validate,
@@ -59,7 +63,7 @@ function* resolveRootMode(
5963
type PrivPartialConfig = {
6064
options: ValidatedOptions,
6165
context: ConfigContext,
62-
isIgnored: boolean,
66+
fileHandling: FileHandling,
6367
ignore: IgnoreFile | void,
6468
babelrc: ConfigFile | void,
6569
config: ConfigFile | void,
@@ -139,7 +143,7 @@ export default function* loadPrivatePartialConfig(
139143
return {
140144
options,
141145
context,
142-
isIgnored: configChain.isIgnored,
146+
fileHandling: configChain.fileHandling,
143147
ignore: configChain.ignore,
144148
babelrc: configChain.babelrc,
145149
config: configChain.config,
@@ -158,9 +162,9 @@ export const loadPartialConfig = gensync<[any], PartialConfig | null>(
158162
const result: ?PrivPartialConfig = yield* loadPrivatePartialConfig(opts);
159163
if (!result) return null;
160164

161-
const { options, babelrc, ignore, config, isIgnored, files } = result;
165+
const { options, babelrc, ignore, config, fileHandling, files } = result;
162166

163-
if (isIgnored && !showIgnoredFiles) {
167+
if (fileHandling === "ignored" && !showIgnoredFiles) {
164168
return null;
165169
}
166170

@@ -178,7 +182,7 @@ export const loadPartialConfig = gensync<[any], PartialConfig | null>(
178182
babelrc ? babelrc.filepath : undefined,
179183
ignore ? ignore.filepath : undefined,
180184
config ? config.filepath : undefined,
181-
isIgnored,
185+
fileHandling,
182186
files,
183187
);
184188
},
@@ -195,22 +199,22 @@ class PartialConfig {
195199
babelrc: string | void;
196200
babelignore: string | void;
197201
config: string | void;
198-
isIgnored: boolean;
202+
fileHandling: FileHandling;
199203
files: Set<string>;
200204

201205
constructor(
202206
options: ValidatedOptions,
203207
babelrc: string | void,
204208
ignore: string | void,
205209
config: string | void,
206-
isIgnored: boolean,
210+
fileHandling: FileHandling,
207211
files: Set<string>,
208212
) {
209213
this.options = options;
210214
this.babelignore = ignore;
211215
this.babelrc = babelrc;
212216
this.config = config;
213-
this.isIgnored = isIgnored;
217+
this.fileHandling = fileHandling;
214218
this.files = files;
215219

216220
// Freeze since this is a public API and it should be extremely obvious that

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,7 @@ describe("buildConfigChain", function () {
12321232
babelignore: fixture("config-files", ".babelignore"),
12331233
babelrc: fixture("config-files", "babelrc-extended", ".babelrc"),
12341234
config: undefined,
1235-
isIgnored: false,
1235+
fileHandling: "transpile",
12361236
options: {
12371237
...getDefaults(),
12381238
filename: filename,
@@ -1269,7 +1269,7 @@ describe("buildConfigChain", function () {
12691269
babelignore: fixture("config-files", "babelignore", ".babelignore"),
12701270
babelrc: undefined,
12711271
config: undefined,
1272-
isIgnored: true,
1272+
fileHandling: "ignored",
12731273
options: {
12741274
...getDefaults(),
12751275
filename: filename,

0 commit comments

Comments
 (0)