File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -131,7 +131,8 @@ module.exports = {
131131 ) ;
132132 }
133133 try {
134- this . webpackConfig = require ( webpackConfigFilePath ) ;
134+ const webpackConfig = require ( webpackConfigFilePath ) ;
135+ this . webpackConfig = webpackConfig . default || webpackConfig ;
135136 } catch ( err ) {
136137 this . serverless . cli . log ( `Could not load webpack config '${ webpackConfigFilePath } '` ) ;
137138 return BbPromise . reject ( err ) ;
Original file line number Diff line number Diff line change @@ -271,6 +271,30 @@ describe('validate', () => {
271271 } ) ;
272272 } ) ;
273273
274+ it ( 'should interop default when webpack config is exported as an ES6 module' , ( ) => {
275+ const testConfig = 'testconfig' ;
276+ const testServicePath = 'testpath' ;
277+ const requiredPath = path . join ( testServicePath , testConfig ) ;
278+ module . serverless . config . servicePath = testServicePath ;
279+ module . serverless . service . custom . webpack = testConfig ;
280+ serverless . utils . fileExistsSync = sinon . stub ( ) . returns ( true ) ;
281+ const loadedConfig = {
282+ default : {
283+ entry : 'testentry'
284+ }
285+ } ;
286+ mockery . registerMock ( requiredPath , loadedConfig ) ;
287+ return expect ( module . validate ( ) )
288+ . to . fulfilled . then ( ( ) => {
289+ expect ( serverless . utils . fileExistsSync ) . to . have . been . calledWith ( requiredPath ) ;
290+ expect ( module . webpackConfig ) . to . eql ( loadedConfig . default ) ;
291+ return null ;
292+ } )
293+ . finally ( ( ) => {
294+ mockery . deregisterMock ( requiredPath ) ;
295+ } ) ;
296+ } ) ;
297+
274298 it ( 'should catch errors while loading a async webpack config from file if `custom.webpack` is a string' , ( ) => {
275299 const testConfig = 'testconfig' ;
276300 const testServicePath = 'testpath' ;
You can’t perform that action at this time.
0 commit comments