mirror of https://github.com/webpack/webpack.git
fix: resolve execution order issue from extra await in async modules
This commit is contained in:
parent
c92deaf02c
commit
8db97f863f
|
@ -62,9 +62,12 @@ class AwaitDependenciesInitFragment extends InitFragment {
|
|||
this.dependencies.size === 1 ||
|
||||
!runtimeTemplate.supportsDestructuring()
|
||||
) {
|
||||
templateInput.push(
|
||||
"var __webpack_async_dependencies_result__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);"
|
||||
);
|
||||
for (const [index, importVar] of importVars.entries()) {
|
||||
templateInput.push(
|
||||
`${importVar} = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[${index}];`
|
||||
`${importVar} = __webpack_async_dependencies_result__[${index}];`
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
await 1;
|
||||
export const a = "a"
|
|
@ -0,0 +1,2 @@
|
|||
await 1;
|
||||
export const b = "b"
|
|
@ -0,0 +1,4 @@
|
|||
import {a} from "./a";
|
||||
import {b} from "./b";
|
||||
|
||||
export const c = a + b
|
|
@ -0,0 +1,3 @@
|
|||
import {c} from "./c";
|
||||
|
||||
export const d = c
|
|
@ -0,0 +1,5 @@
|
|||
it("should work", () => {
|
||||
return import("./d").then(d => {
|
||||
expect(d.d).toBe("ab");
|
||||
});
|
||||
});
|
|
@ -0,0 +1,10 @@
|
|||
"use strict";
|
||||
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
output: {
|
||||
environment: {
|
||||
destructuring: false
|
||||
}
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue