11import webpack from 'webpack' ;
22import { LoaderConfOptions , WebpackConfiguration } from 'kkt' ;
33import path from 'path' ;
4- import { transformationDefineString } from './uitls' ;
4+ import { transformationDefineString , getFunDefault } from './uitls' ;
55
66export * from 'kkt' ;
77
@@ -142,10 +142,10 @@ export default (props: ConfigProps) => {
142142 if ( newLoader ) {
143143 newLoader . forEach ( ( fun ) => {
144144 if ( typeof fun === 'string' ) {
145- conf = require ( fun ) ( conf , env , options ) ;
145+ conf = getFunDefault ( fun ) ( conf , env , options ) ;
146146 } else if ( Array . isArray ( fun ) ) {
147147 const [ paths , rest ] = fun ;
148- conf = require ( paths ) ( conf , env , { ...options , ...rest } ) ;
148+ conf = getFunDefault ( paths ) ( conf , env , { ...options , ...rest } ) ;
149149 } else if ( typeof fun === 'function' ) {
150150 conf = fun ( conf , env , options ) ;
151151 } else if ( fun && fun . loader ) {
@@ -159,11 +159,11 @@ export default (props: ConfigProps) => {
159159 if ( Array . isArray ( newPlugins ) ) {
160160 newPlugins . forEach ( ( pathArr ) => {
161161 if ( typeof pathArr === 'string' ) {
162- const Cls = require ( pathArr ) ;
162+ const Cls = getFunDefault ( pathArr ) ;
163163 plugin . push ( new Cls ( ) ) ;
164164 } else if ( Array . isArray ( pathArr ) ) {
165165 const [ paths , rest ] = pathArr ;
166- const Cls = require ( paths ) ;
166+ const Cls = getFunDefault ( paths ) ;
167167 plugin . push ( new Cls ( rest ) ) ;
168168 } else {
169169 plugin . push ( pathArr ) ;
0 commit comments