Merge pull request #10196 from webpack/bugfix/10194

generate await code for import without await too
This commit is contained in:
Tobias Koppers 2019-12-30 21:14:18 +01:00 committed by GitHub
commit 0e2b4f5b93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 2 deletions

View File

@ -236,7 +236,7 @@ HarmonyImportDependency.Template = class HarmonyImportDependencyTemplate extends
key
)
);
if (dep.await) {
if (templateContext.moduleGraph.isAsync(referencedModule)) {
templateContext.initFragments.push(
new AwaitDependenciesInitFragment(
new Set([dep.getImportVar(templateContext.moduleGraph)])

View File

@ -180,7 +180,8 @@ const describeCases = config => {
mjs: true,
asyncWebAssembly: true,
topLevelAwait: true,
importAwait: true
importAwait: true,
importAsync: true
}
};
beforeAll(done => {

View File

@ -0,0 +1,6 @@
it("should allow to use import await", () => {
return import("./reexport").then(({ default: value, other }) => {
expect(value).toBe(42);
expect(other).toBe(42);
});
});

View File

@ -0,0 +1,3 @@
await new Promise(r => setTimeout(r, 100));
export default 42;

View File

@ -0,0 +1,4 @@
export { default } from "./module";
import value from "./module";
export const other = value;