@@ -62,22 +62,6 @@ describe('loader', () => {
62
62
expect ( getWarnings ( stats ) ) . toMatchSnapshot ( 'warnings' ) ;
63
63
} ) ;
64
64
65
- it ( 'should work multiple name from one library' , async ( ) => {
66
- const compiler = getCompiler ( 'simple-commonjs2-single-export.js' , {
67
- exposes : [ 'myOtherGlobal' , 'myGlobal' ] ,
68
- } ) ;
69
- const stats = await compile ( compiler ) ;
70
-
71
- expect (
72
- getModuleSource ( './global-commonjs2-single-export.js-exposed' , stats )
73
- ) . toMatchSnapshot ( 'module' ) ;
74
- expect (
75
- execute ( readAsset ( 'main.bundle.js' , compiler , stats ) )
76
- ) . toMatchSnapshot ( 'result' ) ;
77
- expect ( getErrors ( stats ) ) . toMatchSnapshot ( 'errors' ) ;
78
- expect ( getWarnings ( stats ) ) . toMatchSnapshot ( 'warnings' ) ;
79
- } ) ;
80
-
81
65
it ( 'should work for a nested property for a global object' , async ( ) => {
82
66
const compiler = getCompiler ( 'simple-commonjs2-single-export.js' , {
83
67
exposes : 'myGlobal.nested' ,
@@ -267,6 +251,40 @@ describe('loader', () => {
267
251
expect ( getWarnings ( stats ) ) . toMatchSnapshot ( 'warnings' ) ;
268
252
} ) ;
269
253
254
+ it ( 'should work multiple name from one package' , async ( ) => {
255
+ const compiler = getCompiler (
256
+ 'simple-commonjs2-single-export.js' ,
257
+ {
258
+ exposes : [ 'myOtherGlobal' , 'myGlobal' ] ,
259
+ } ,
260
+ {
261
+ output : {
262
+ path : path . resolve ( __dirname , './outputs' ) ,
263
+ filename : '[name]-[contenthash:8].bundle.js' ,
264
+ chunkFilename : '[name]-[contenthash:8].chunk.js' ,
265
+ library : 'ExposeLoader' ,
266
+ libraryTarget : 'var' ,
267
+ } ,
268
+ }
269
+ ) ;
270
+ const stats = await compile ( compiler ) ;
271
+
272
+ const webpack4Filename = 'main-bd1693c3.bundle.js' ;
273
+ const webpack5Filename = 'main-b4700c39.bundle.js' ;
274
+ const bundleName =
275
+ webpack . version [ 0 ] === '5' ? webpack5Filename : webpack4Filename ;
276
+
277
+ expect (
278
+ getModuleSource ( './global-commonjs2-single-export.js-exposed' , stats )
279
+ ) . toMatchSnapshot ( 'module' ) ;
280
+ expect ( Object . keys ( stats . compilation . assets ) [ 0 ] ) . toBe ( bundleName ) ;
281
+ expect ( execute ( readAsset ( bundleName , compiler , stats ) ) ) . toMatchSnapshot (
282
+ 'result'
283
+ ) ;
284
+ expect ( getErrors ( stats ) ) . toMatchSnapshot ( 'errors' ) ;
285
+ expect ( getWarnings ( stats ) ) . toMatchSnapshot ( 'warnings' ) ;
286
+ } ) ;
287
+
270
288
it ( 'should match hashes on all operating systems' , async ( ) => {
271
289
const compiler = getCompiler (
272
290
'inline-import-2.js' ,
0 commit comments