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 #15266 from webpack/bugfix/throwing-in-async-modules
fix handling of errors thrown in async modules
- Loading branch information
Showing
15 changed files
with
120 additions
and
33 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
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,3 @@ | ||
import x from "./shared"; | ||
|
||
export default x + " world"; |
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 @@ | ||
import x from "./shared"; | ||
|
||
export default x + " world"; |
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,4 @@ | ||
it("should allow to import an async module twice", async () => { | ||
const result = await require("./main"); | ||
expect(result.default).toBe("hello world, hello world"); | ||
}); |
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,4 @@ | ||
import a from "./a"; | ||
import b from "./b"; | ||
|
||
export default a + ", " + b; |
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 @@ | ||
await 1; | ||
await 1; | ||
export default "hello"; |
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,6 @@ | ||
await 1; | ||
let value = 0; | ||
export const count = () => { | ||
value++; | ||
return value; | ||
}; |
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,39 @@ | ||
it("should allow to import an rejected async module again", async () => { | ||
await expect(require("./main")).rejects.toEqual( | ||
expect.objectContaining({ | ||
message: expect.stringContaining("expected rejection 1") | ||
}) | ||
); | ||
await expect(require("./module")).rejects.toEqual( | ||
expect.objectContaining({ | ||
message: expect.stringContaining("expected rejection 1") | ||
}) | ||
); | ||
await expect(require("./module?2")).rejects.toEqual( | ||
expect.objectContaining({ | ||
message: expect.stringContaining("expected rejection 2") | ||
}) | ||
); | ||
await expect(require("./reexport?2")).rejects.toEqual( | ||
expect.objectContaining({ | ||
message: expect.stringContaining("expected rejection 1") | ||
}) | ||
); | ||
await Promise.all([ | ||
expect(require("./module?3")).rejects.toEqual( | ||
expect.objectContaining({ | ||
message: expect.stringContaining("expected rejection 3") | ||
}) | ||
), | ||
expect(require("./module?4")).rejects.toEqual( | ||
expect.objectContaining({ | ||
message: expect.stringContaining("expected rejection 4") | ||
}) | ||
), | ||
expect(require("./module?5")).rejects.toEqual( | ||
expect.objectContaining({ | ||
message: expect.stringContaining("expected rejection 5") | ||
}) | ||
) | ||
]); | ||
}); |
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 @@ | ||
export { default as a } from "./reexport"; | ||
export { default as b } from "./module?2"; |
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,6 @@ | ||
import { count } from "./counter"; | ||
|
||
const c = count(); | ||
throw new Error("expected rejection " + c); | ||
|
||
export default "ok"; |
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 @@ | ||
export { default as default } from "./module"; |