Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14692 from webpack/feature/chunk-loading-false
add `chunkLoading: false` support
- Loading branch information
Showing
7 changed files
with
72 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import fs from "fs"; | ||
|
||
it("should load chunks on demand", async () => { | ||
expect((await import("./async")).default).toEqual(42); | ||
expect((await (await import("./async")).nested()).default).toEqual(43); | ||
expect(fs.readFileSync(__filename, "utf-8")).not.toContain( | ||
"This is the" + " async chunk" | ||
); | ||
expect(fs.readFileSync(__filename, "utf-8")).not.toContain( | ||
"This is the" + " nested async chunk" | ||
); | ||
}); |
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,3 @@ | ||
// This is the async chunk | ||
export default 42; | ||
export const nested = () => import("./nested"); |
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,12 @@ | ||
import fs from "fs"; | ||
|
||
it("should include all async imports in the main chunk", async () => { | ||
expect((await import("./async")).default).toEqual(42); | ||
expect((await (await import("./async")).nested()).default).toEqual(43); | ||
expect(fs.readFileSync(__filename, "utf-8")).toContain( | ||
"This is the async chunk" | ||
); | ||
expect(fs.readFileSync(__filename, "utf-8")).toContain( | ||
"This is the nested async chunk" | ||
); | ||
}); |
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 @@ | ||
// This is the nested async chunk | ||
export default 43; |
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 @@ | ||
module.exports = { | ||
findBundle: function (i, options) { | ||
return ["./a.js", "./b.js"]; | ||
} | ||
}; |
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,13 @@ | ||
/** @type {import("../../../../").Configuration} */ | ||
module.exports = { | ||
entry: { | ||
a: "./a.js", | ||
b: { | ||
import: "./b.js", | ||
chunkLoading: false | ||
} | ||
}, | ||
output: { | ||
filename: "[name].js" | ||
} | ||
}; |