Skip to content

Commit

Permalink
fix: tla for await won't run
Browse files Browse the repository at this point in the history
  • Loading branch information
ahabhgk committed Jun 16, 2023
1 parent 8e0e0eb commit 6e62cf4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/runtime/AsyncModuleRuntimeModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class AsyncModuleRuntimeModule extends HelperRuntimeModule {
)};`,
`${fn} = ${runtimeTemplate.basicFunction("module, body, hasAwait", [
"var queue;",
"hasAwait && ((queue = []).d = 1);",
"hasAwait && ((queue = []).d = -1);",
"var depQueues = new Set();",
"var exports = module.exports;",
"var currentDeps;",
Expand Down Expand Up @@ -124,7 +124,7 @@ class AsyncModuleRuntimeModule extends HelperRuntimeModule {
"(err ? reject(promise[webpackError] = err) : outerResolve(exports)), resolveQueue(queue)",
"err"
)});`,
"queue && (queue.d = 0);"
"queue && queue < 0 && (queue.d = 0);"
])};`
]);
}
Expand Down
2 changes: 2 additions & 0 deletions test/configCases/issues/issue-16097/fake-tla.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
global.someNonExistentVariable && await 'test';
export default 42;
5 changes: 5 additions & 0 deletions test/configCases/issues/issue-16097/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import i from './fake-tla';

it("should have value imported from fake-tla", async () => {
expect(i).toBe(42);
});
6 changes: 6 additions & 0 deletions test/configCases/issues/issue-16097/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
mode: "development",
devtool: false,
experiments: { topLevelAwait: true }
};

0 comments on commit 6e62cf4

Please sign in to comment.