@@ -217,33 +217,21 @@ describe('compile', () => {
217217 outputPath : 'compileStats-outputPath'
218218 } ,
219219 modules : [
220- {
221- identifier : _ . constant ( '"crypto"' )
222- } ,
223- {
224- identifier : _ . constant ( '"uuid/v4"' )
225- } ,
226- {
227- identifier : _ . constant ( '"mockery"' )
228- } ,
229- {
230- identifier : _ . constant ( '"@scoped/vendor/module1"' )
231- } ,
232- {
233- identifier : _ . constant ( 'external "@scoped/vendor/module2"' )
234- } ,
235- {
236- identifier : _ . constant ( 'external "uuid/v4"' )
237- } ,
238- {
239- identifier : _ . constant ( 'external "localmodule"' )
240- } ,
241- {
242- identifier : _ . constant ( 'external "bluebird"' )
243- } ,
244- {
245- identifier : _ . constant ( 'external "aws-sdk"' )
246- }
220+ { identifier : _ . constant ( '"crypto"' ) } ,
221+ { identifier : _ . constant ( '"uuid/v4"' ) } ,
222+ { identifier : _ . constant ( '"mockery"' ) } ,
223+ { identifier : _ . constant ( '"@scoped/vendor/module1"' ) } ,
224+ { identifier : _ . constant ( 'external "@scoped/vendor/module2"' ) } ,
225+ { identifier : _ . constant ( 'external "uuid/v4"' ) } ,
226+ { identifier : _ . constant ( 'external "localmodule"' ) } ,
227+ { identifier : _ . constant ( 'external "bluebird"' ) } ,
228+ { identifier : _ . constant ( 'external "aws-sdk"' ) } ,
229+ { identifier : _ . constant ( 'external node-commonjs "lodash"' ) } ,
230+ { identifier : _ . constant ( 'external commonjs-module "globby"' ) } ,
231+ { identifier : _ . constant ( 'external this "glob"' ) } ,
232+ { identifier : _ . constant ( 'external module "semver"' ) } ,
233+ { identifier : _ . constant ( 'external assign "whatever"' ) } ,
234+ { identifier : _ . constant ( 'external umd2 "hiyou"' ) }
247235 ]
248236 } ,
249237 toString : sandbox . stub ( ) . returns ( 'testStats' ) ,
@@ -261,9 +249,41 @@ describe('compile', () => {
261249 { external : 'uuid' , origin : undefined } ,
262250 { external : 'localmodule' , origin : undefined } ,
263251 { external : 'bluebird' , origin : undefined } ,
264- { external : 'aws-sdk' , origin : undefined }
252+ { external : 'aws-sdk' , origin : undefined } ,
253+ { external : 'lodash' , origin : undefined } ,
254+ { external : 'globby' , origin : undefined } ,
255+ { external : 'glob' , origin : undefined } ,
256+ { external : 'semver' , origin : undefined } ,
257+ { external : 'whatever' , origin : undefined } ,
258+ { external : 'hiyou' , origin : undefined }
265259 ] ) ;
266260 return null ;
267261 } ) ;
268262 } ) ;
263+
264+ it ( 'should fail to set stats externals' , ( ) => {
265+ const testWebpackConfig = 'testconfig' ;
266+ const multiStats = {
267+ stats : [
268+ {
269+ compilation : {
270+ errors : [ ] ,
271+ compiler : {
272+ outputPath : 'compileStats-outputPath'
273+ } ,
274+ modules : [ { identifier : _ . constant ( 'external node-commonjs "aws-sdk".' ) } ]
275+ } ,
276+ toString : sandbox . stub ( ) . returns ( 'testStats' ) ,
277+ hasErrors : _ . constant ( false )
278+ }
279+ ]
280+ } ;
281+ module . webpackConfig = testWebpackConfig ;
282+ module . configuration = { concurrency : 1 } ;
283+ webpackMock . compilerMock . run . reset ( ) ;
284+ webpackMock . compilerMock . run . yields ( null , multiStats ) ;
285+ return expect ( module . compile ( ) ) . to . be . rejectedWith (
286+ 'Unable to extract module name from Webpack identifier: external node-commonjs "aws-sdk".'
287+ ) ;
288+ } ) ;
269289} ) ;
0 commit comments