@@ -14,6 +14,7 @@ import { getEnv } from "./helpers/environment";
1414import {
1515 validate ,
1616 type ValidatedOptions ,
17+ type NormalizedOptions ,
1718 type RootMode ,
1819} from "./validation/options" ;
1920
@@ -24,6 +25,7 @@ import {
2425 type ConfigFile ,
2526 type IgnoreFile ,
2627} from "./files" ;
28+ import { resolveTargets } from "./resolve-targets" ;
2729
2830function * resolveRootMode (
2931 rootDir : string ,
@@ -61,7 +63,7 @@ function* resolveRootMode(
6163}
6264
6365type PrivPartialConfig = {
64- options : ValidatedOptions ,
66+ options : NormalizedOptions ,
6567 context : ConfigContext ,
6668 fileHandling : FileHandling ,
6769 ignore : IgnoreFile | void ,
@@ -115,30 +117,36 @@ export default function* loadPrivatePartialConfig(
115117 const configChain = yield * buildRootChain ( args , context ) ;
116118 if ( ! configChain ) return null ;
117119
118- const options = { } ;
120+ const merged : ValidatedOptions = { } ;
119121 configChain . options . forEach ( opts => {
120- mergeOptions ( options , opts ) ;
122+ mergeOptions ( ( merged : any ) , opts ) ;
121123 } ) ;
122124
123- // Tack the passes onto the object itself so that, if this object is
124- // passed back to Babel a second time, it will be in the right structure
125- // to not change behavior.
126- options . cloneInputAst = cloneInputAst ;
127- options . babelrc = false ;
128- options . configFile = false ;
129- options . passPerPreset = false ;
130- options . envName = context . envName ;
131- options . cwd = context . cwd ;
132- options . root = context . root ;
133- options . filename =
134- typeof context . filename === "string" ? context . filename : undefined ;
135-
136- options . plugins = configChain . plugins . map ( descriptor =>
137- createItemFromDescriptor ( descriptor ) ,
138- ) ;
139- options . presets = configChain . presets . map ( descriptor =>
140- createItemFromDescriptor ( descriptor ) ,
141- ) ;
125+ const options : NormalizedOptions = {
126+ ...merged ,
127+ targets : resolveTargets ( merged , absoluteRootDir , filename ) ,
128+
129+ // Tack the passes onto the object itself so that, if this object is
130+ // passed back to Babel a second time, it will be in the right structure
131+ // to not change behavior.
132+ cloneInputAst,
133+ babelrc : false ,
134+ configFile : false ,
135+ browserslistConfigFile : false ,
136+ passPerPreset : false ,
137+ envName : context . envName ,
138+ cwd : context . cwd ,
139+ root : context . root ,
140+ filename :
141+ typeof context . filename === "string" ? context . filename : undefined ,
142+
143+ plugins : configChain . plugins . map ( descriptor =>
144+ createItemFromDescriptor ( descriptor ) ,
145+ ) ,
146+ presets : configChain . presets . map ( descriptor =>
147+ createItemFromDescriptor ( descriptor ) ,
148+ ) ,
149+ } ;
142150
143151 return {
144152 options ,
@@ -201,15 +209,15 @@ class PartialConfig {
201209 * These properties are public, so any changes to them should be considered
202210 * a breaking change to Babel's API.
203211 */
204- options : ValidatedOptions ;
212+ options : NormalizedOptions ;
205213 babelrc : string | void ;
206214 babelignore : string | void ;
207215 config : string | void ;
208216 fileHandling : FileHandling ;
209217 files : Set < string > ;
210218
211219 constructor (
212- options : ValidatedOptions ,
220+ options : NormalizedOptions ,
213221 babelrc : string | void ,
214222 ignore : string | void ,
215223 config : string | void ,
0 commit comments