@@ -110,7 +110,7 @@ async function updateDir(dirPath, options, hasChangedOptions) {
110110 await backupFile ( path ) ;
111111 await writeFile ( path , JSON . stringify ( localOptions , null , 2 ) + '\n' ) ;
112112 }
113- options = mergeOptions ( options , localOptions ) ;
113+ options = { ... options , ... localOptions } ;
114114 }
115115
116116 // Run Babel with updated options/input
@@ -154,58 +154,6 @@ function updateOptions(options) {
154154 return hasChangedOptions ;
155155}
156156
157- /**
158- * Merge `options` into `parentOptions`.
159- * Returns merged options object. Does not mutate either input.
160- * @param {Object } parentOptions - Parent options
161- * @param {Object } options - Local options
162- * @returns {Object } - Merged options object
163- */
164- function mergeOptions ( parentOptions , options ) {
165- parentOptions = { ...parentOptions } ;
166-
167- function merge ( key ) {
168- if ( ! options [ key ] ) return ;
169-
170- if ( ! parentOptions [ key ] ) {
171- parentOptions [ key ] = options [ key ] ;
172- return ;
173- }
174-
175- parentOptions [ key ] = [ ...parentOptions [ key ] ] ;
176-
177- const parentPluginIndexes = new Map ( ) ;
178- for ( const [ index , plugin ] of parentOptions [ key ] . entries ( ) ) {
179- parentPluginIndexes . set ( getName ( plugin ) , index ) ;
180- }
181-
182- for ( const plugin of options [ key ] ) {
183- const pluginName = getName ( plugin ) ;
184- const parentPluginIndex = parentPluginIndexes . get ( pluginName ) ;
185- if ( parentPluginIndex !== undefined ) {
186- parentOptions [ key ] [ parentPluginIndex ] = plugin ;
187- } else {
188- parentOptions [ key ] . push ( plugin ) ;
189- }
190- }
191- }
192-
193- merge ( 'presets' ) ;
194- merge ( 'plugins' ) ;
195-
196- if ( options . assumptions ) {
197- parentOptions . assumptions = { ...parentOptions . assumptions , ...options . assumptions } ;
198- }
199-
200- for ( const [ key , value ] of Object . entries ( options ) ) {
201- if ( key === 'plugins' || key === 'presets' || key === 'assumptions' ) continue ;
202- if ( Object . hasOwn ( parentOptions , key ) ) throw new Error ( `Clash: ${ key } ` ) ;
203- parentOptions [ key ] = value ;
204- }
205-
206- return parentOptions ;
207- }
208-
209157/**
210158 * Transform input with Babel and save to output file.
211159 * @param {string } inputPath - Path of input file
0 commit comments