Skip to content

Commit

Permalink
generate await code for import without await too
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Dec 30, 2019
1 parent 2671b0b commit bbace17
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/dependencies/HarmonyImportDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)])
Expand Down
3 changes: 2 additions & 1 deletion test/TestCases.template.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ const describeCases = config => {
mjs: true,
asyncWebAssembly: true,
topLevelAwait: true,
importAwait: true
importAwait: true,
importAsync: true
}
};
beforeAll(done => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
await new Promise(r => setTimeout(r, 100));

export default 42;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export { default } from "./module";
import value from "./module";

export const other = value;

0 comments on commit bbace17

Please sign in to comment.