import path from 'path' ; import { Configuration } from 'webpack' ; import { omitBy } from 'lodash' ; import findUp from 'find-up' ; import { ConfigurationFactory } from '../interface' ; const factory = async ( entry ) => { const { cwd } = entry ; const nodeModule = async ( ... segments ) : Promise < string > => { const name = path . join ( 'node_modules' , ... segments ) ; const module = await findUp ( name , { cwd } ) ?? '' ; return module ; } ; const resolvingModules = [ nodeModule ( 'react' , 'umd' , 'react.production.min.js' ) , nodeModule ( 'react-dom' , 'umd' , 'react-dom.production.min.js' ) , nodeModule ( 'react-redux' , 'dist' , 'react-redux.min.js' ) , nodeModule ( 'redux' , 'dist' , 'redux.min.js' ) , ] as const ; const [ react , reactDOM , reactRedux , redux ] = await Promise . all ( resolvingModules ) ; const alias = { react$ : react , 'react-dom$' : reactDOM , 'react-redux$' : reactRedux , redux$ : redux , } ; const config = { devtool : 'source-map' , resolve : { alias : omitBy ( alias , v => ! v ) , } , performance : { maxEntrypointSize : Infinity , maxAssetSize : 1.5 * 1024 * 1024 , } , optimization : { removeEmptyChunks : true , sideEffects : true , } , } ; return config ; } ; export default factory ;