forked from webpack/webpack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix quadratic evaluation performance of async modules
improve runtime code for async modules
- Loading branch information
Showing
5 changed files
with
60 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
await 1; | ||
export default 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
it("should not take too long to evaluate nested async modules", async () => { | ||
const start = Date.now(); | ||
await import(/* webpackMode: "eager" */ "./loader.js?i=40!./loader.js"); | ||
expect(Date.now() - start).toBeLessThan(100); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** @type {import("../../../../").LoaderDefinition<{ i: string }>} */ | ||
module.exports = function () { | ||
const options = this.getOptions(); | ||
const i = +options.i; | ||
let src = `import n from "./async.js";\n`; | ||
if (i > 0) { | ||
src += `import a from "./loader.js?i=${i - 1}&a!./loader.js";\n`; | ||
src += `import b from "./loader.js?i=${i - 1}&b!./loader.js";\n`; | ||
src += `export default n + a + b;\n`; | ||
} else { | ||
src += `export default n;\n`; | ||
} | ||
return src; | ||
}; |