File tree Expand file tree Collapse file tree 6 files changed +47
-0
lines changed
test/configCases/async-library Expand file tree Collapse file tree 6 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,10 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
78
78
const result = new ConcatSource ( source ) ;
79
79
const exportsInfo = moduleGraph . getExportsInfo ( module ) ;
80
80
const exports = [ ] ;
81
+ const isAsync = moduleGraph . isAsync ( module ) ;
82
+ if ( isAsync ) {
83
+ result . add ( `__webpack_exports__ = await __webpack_exports__;\n` ) ;
84
+ }
81
85
for ( const exportInfo of exportsInfo . orderedExports ) {
82
86
if ( ! exportInfo . provided ) continue ;
83
87
const varName = `__webpack_exports__${ Template . toIdentifier (
Original file line number Diff line number Diff line change
1
+ export const a = await Promise . resolve ( 42 ) ;
Original file line number Diff line number Diff line change
1
+ exports . noTests = true ;
Original file line number Diff line number Diff line change
1
+ /** @type {import("../../../../types").Configuration } */
2
+ module . exports = {
3
+ entry : "./a.js" ,
4
+ output : {
5
+ filename : "lib.js" ,
6
+ library : {
7
+ type : "module"
8
+ }
9
+ } ,
10
+ target : "node14" ,
11
+ optimization : {
12
+ minimize : true
13
+ } ,
14
+ experiments : {
15
+ topLevelAwait : true ,
16
+ outputModule : true
17
+ }
18
+ } ;
Original file line number Diff line number Diff line change
1
+ it ( "should get valid export from library" , ( ) => {
2
+ return import ( "library" ) . then ( ( { a } ) => {
3
+ expect ( a ) . toBe ( 42 ) ;
4
+ } ) ;
5
+ } ) ;
Original file line number Diff line number Diff line change
1
+ var path = require ( "path" ) ;
2
+
3
+ /** @type {function(any, any): import("../../../../types").Configuration } */
4
+ module . exports = ( env , { testPath } ) => ( {
5
+ target : "node14" ,
6
+ output : {
7
+ chunkLoading : "import"
8
+ } ,
9
+ resolve : {
10
+ alias : {
11
+ library : path . resolve ( testPath , "../0-create-library/lib.js" )
12
+ }
13
+ } ,
14
+ experiments : {
15
+ topLevelAwait : true ,
16
+ outputModule : true
17
+ }
18
+ } ) ;
You can’t perform that action at this time.
0 commit comments