interface IOpts { typescript ? : boolean ; env ? : object ; react ? : boolean | object ; } /**
 * babel config
 */ function resolvePlugin ( plugins ) { return plugins . filter ( Boolean ) . map ( ( plugin ) => { if ( Array . isArray ( plugin ) ) { const [ pluginName , ... args ] = plugin ; return [ require . resolve ( pluginName ) , ... args ] ; } return require . resolve ( plugin ) ; } ) ; } export default ( opts = { } ) => { const plugins = [ '@builder/pack/deps/@babel/plugin-proposal-function-bind' , '@builder/pack/deps/@babel/plugin-proposal-export-default-from' , '@builder/pack/deps/@babel/plugin-proposal-logical-assignment-operators' , [ '@builder/pack/deps/@babel/plugin-proposal-optional-chaining' , { loose : false } ] , [ '@builder/pack/deps/@babel/plugin-proposal-pipeline-operator' , { proposal : 'minimal' } ] , [ '@builder/pack/deps/@babel/plugin-proposal-nullish-coalescing-operator' , { loose : false } ] , '@builder/pack/deps/@babel/plugin-proposal-do-expressions' , [ '@builder/pack/deps/@babel/plugin-proposal-decorators' , { legacy : true } ] , '@builder/pack/deps/@babel/plugin-proposal-function-sent' , '@builder/pack/deps/@babel/plugin-proposal-export-namespace-from' , '@builder/pack/deps/@babel/plugin-proposal-numeric-separator' , '@builder/pack/deps/@babel/plugin-proposal-throw-expressions' , '@builder/pack/deps/@babel/plugin-syntax-dynamic-import' , '@builder/pack/deps/@babel/plugin-syntax-import-meta' , [ '@builder/pack/deps/@babel/plugin-proposal-class-properties' , { loose : true } ] , [ '@builder/pack/deps/@babel/plugin-proposal-private-methods' , { loose : true } ] , [ '@builder/pack/deps/@babel/plugin-proposal-private-property-in-object' , { loose : true } ] , '@builder/pack/deps/@babel/plugin-proposal-json-strings' , ] ; return { presets : resolvePlugin ( [ opts . env && [ '@builder/pack/deps/@babel/preset-env' , opts . env , ] , opts . typescript && '@builder/pack/deps/@babel/preset-typescript' , opts . react && ( typeof opts . react === 'boolean' ? '@builder/pack/deps/@babel/preset-react' : [ '@builder/pack/deps/@babel/preset-react' , opts . react ] ) , ] ) , plugins : resolvePlugin ( plugins ) , } ; } ;