@@ -5,12 +5,12 @@ import buildDebug from "debug";
55import type { Handler } from "gensync" ;
66import { validate } from "./validation/options.ts" ;
77import type {
8- ValidatedOptions ,
9- IgnoreList ,
108 ConfigApplicableTest ,
119 BabelrcSearch ,
1210 CallerMetadata ,
13- IgnoreItem ,
11+ MatchItem ,
12+ InputOptions ,
13+ ConfigChainOptions ,
1414} from "./validation/options.ts" ;
1515import pathPatternToRegex from "./pattern-to-regex.ts" ;
1616import { ConfigPrinter , ChainFormatter } from "./printer.ts" ;
@@ -45,12 +45,12 @@ import type {
4545export type ConfigChain = {
4646 plugins : Array < UnloadedDescriptor < PluginAPI > > ;
4747 presets : Array < UnloadedDescriptor < PresetAPI > > ;
48- options : Array < ValidatedOptions > ;
48+ options : Array < ConfigChainOptions > ;
4949 files : Set < string > ;
5050} ;
5151
5252export type PresetInstance = {
53- options : ValidatedOptions ;
53+ options : InputOptions ;
5454 alias : string ;
5555 dirname : string ;
5656 externalDependencies : ReadonlyDeepArray < string > ;
@@ -78,7 +78,7 @@ export function* buildPresetChain(
7878 return {
7979 plugins : dedupDescriptors ( chain . plugins ) ,
8080 presets : dedupDescriptors ( chain . presets ) ,
81- options : chain . options . map ( o => normalizeOptions ( o ) ) ,
81+ options : chain . options . map ( o => createConfigChainOptions ( o ) ) ,
8282 files : new Set ( ) ,
8383 } ;
8484}
@@ -132,9 +132,9 @@ const loadPresetOverridesEnvDescriptors = makeWeakCacheSync(
132132
133133export type FileHandling = "transpile" | "ignored" | "unsupported" ;
134134export type RootConfigChain = ConfigChain & {
135- babelrc : ConfigFile | void ;
136- config : ConfigFile | void ;
137- ignore : IgnoreFile | void ;
135+ babelrc : ConfigFile | undefined ;
136+ config : ConfigFile | undefined ;
137+ ignore : IgnoreFile | undefined ;
138138 fileHandling : FileHandling ;
139139 files : Set < string > ;
140140} ;
@@ -143,7 +143,7 @@ export type RootConfigChain = ConfigChain & {
143143 * Build a config chain for Babel's full root configuration.
144144 */
145145export function * buildRootChain (
146- opts : ValidatedOptions ,
146+ opts : InputOptions ,
147147 context : ConfigContext ,
148148) : Handler < RootConfigChain | null > {
149149 let configReport , babelRcReport ;
@@ -279,7 +279,9 @@ export function* buildRootChain(
279279 return {
280280 plugins : isIgnored ? [ ] : dedupDescriptors ( chain . plugins ) ,
281281 presets : isIgnored ? [ ] : dedupDescriptors ( chain . presets ) ,
282- options : isIgnored ? [ ] : chain . options . map ( o => normalizeOptions ( o ) ) ,
282+ options : isIgnored
283+ ? [ ]
284+ : chain . options . map ( o => createConfigChainOptions ( o ) ) ,
283285 fileHandling : isIgnored ? "ignored" : "transpile" ,
284286 ignore : ignoreFile || undefined ,
285287 babelrc : babelrcFile || undefined ,
@@ -306,7 +308,7 @@ function babelrcLoadEnabled(
306308
307309 let babelrcPatterns = babelrcRoots ;
308310 if ( ! Array . isArray ( babelrcPatterns ) ) {
309- babelrcPatterns = [ babelrcPatterns as IgnoreItem ] ;
311+ babelrcPatterns = [ babelrcPatterns ] ;
310312 }
311313 babelrcPatterns = babelrcPatterns . map ( pat => {
312314 return typeof pat === "string"
@@ -457,7 +459,7 @@ function buildRootDescriptors(
457459 alias : string ,
458460 descriptors : (
459461 dirname : string ,
460- options : ValidatedOptions ,
462+ options : InputOptions ,
461463 alias : string ,
462464 ) => OptionsAndDescriptors ,
463465) {
@@ -482,7 +484,7 @@ function buildEnvDescriptors(
482484 alias : string ,
483485 descriptors : (
484486 dirname : string ,
485- options : ValidatedOptions ,
487+ options : InputOptions ,
486488 alias : string ,
487489 ) => OptionsAndDescriptors ,
488490 envName : string ,
@@ -496,7 +498,7 @@ function buildOverrideDescriptors(
496498 alias : string ,
497499 descriptors : (
498500 dirname : string ,
499- options : ValidatedOptions ,
501+ options : InputOptions ,
500502 alias : string ,
501503 ) => OptionsAndDescriptors ,
502504 index : number ,
@@ -512,7 +514,7 @@ function buildOverrideEnvDescriptors(
512514 alias : string ,
513515 descriptors : (
514516 dirname : string ,
515- options : ValidatedOptions ,
517+ options : InputOptions ,
516518 alias : string ,
517519 ) => OptionsAndDescriptors ,
518520 index : number ,
@@ -533,7 +535,7 @@ function buildOverrideEnvDescriptors(
533535
534536function makeChainWalker <
535537 ArgT extends {
536- options : ValidatedOptions ;
538+ options : InputOptions ;
537539 dirname : string ;
538540 filepath ?: string ;
539541 } ,
@@ -666,7 +668,7 @@ function makeChainWalker<
666668
667669function * mergeExtendsChain (
668670 chain : ConfigChain ,
669- opts : ValidatedOptions ,
671+ opts : InputOptions ,
670672 dirname : string ,
671673 context : ConfigContext ,
672674 files : Set < ConfigFile > ,
@@ -736,7 +738,7 @@ function emptyChain(): ConfigChain {
736738 } ;
737739}
738740
739- function normalizeOptions ( opts : ValidatedOptions ) : ValidatedOptions {
741+ function createConfigChainOptions ( opts : InputOptions ) : ConfigChainOptions {
740742 const options = {
741743 ...opts ,
742744 } ;
@@ -833,8 +835,8 @@ function configFieldIsApplicable(
833835 */
834836function ignoreListReplacer (
835837 _key : string ,
836- value : IgnoreList | IgnoreItem ,
837- ) : IgnoreList | IgnoreItem | string {
838+ value : MatchItem [ ] | MatchItem ,
839+ ) : MatchItem [ ] | MatchItem | string {
838840 if ( value instanceof RegExp ) {
839841 return String ( value ) ;
840842 }
@@ -847,8 +849,8 @@ function ignoreListReplacer(
847849 */
848850function shouldIgnore (
849851 context : ConfigContext ,
850- ignore : IgnoreList | undefined | null ,
851- only : IgnoreList | undefined | null ,
852+ ignore : MatchItem [ ] | undefined | null ,
853+ only : MatchItem [ ] | undefined | null ,
852854 dirname : string ,
853855) : boolean {
854856 if ( ignore && matchesPatterns ( context , ignore , dirname ) ) {
@@ -888,7 +890,7 @@ function shouldIgnore(
888890 */
889891function matchesPatterns (
890892 context : ConfigContext ,
891- patterns : IgnoreList ,
893+ patterns : MatchItem [ ] ,
892894 dirname : string ,
893895 configName ?: string ,
894896) : boolean {
@@ -898,7 +900,7 @@ function matchesPatterns(
898900}
899901
900902function matchPattern (
901- pattern : IgnoreItem ,
903+ pattern : MatchItem ,
902904 dirname : string ,
903905 pathToTest : string | undefined ,
904906 context : ConfigContext ,
0 commit comments