-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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 #13997 from yujunjung/main
fix: exporting async module as library `type: "module"`
- Loading branch information
Showing
6 changed files
with
47 additions
and
0 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 @@ | ||
export const a = await Promise.resolve(42); |
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 @@ | ||
exports.noTests = true; |
18 changes: 18 additions & 0 deletions
18
test/configCases/async-library/0-create-library/webpack.config.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,18 @@ | ||
/** @type {import("../../../../types").Configuration} */ | ||
module.exports = { | ||
entry: "./a.js", | ||
output: { | ||
filename: "lib.js", | ||
library: { | ||
type: "module" | ||
} | ||
}, | ||
target: "node14", | ||
optimization: { | ||
minimize: true | ||
}, | ||
experiments: { | ||
topLevelAwait: true, | ||
outputModule: true | ||
} | ||
}; |
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 get valid export from library", () => { | ||
return import("library").then(({ a }) => { | ||
expect(a).toBe(42); | ||
}); | ||
}); |
18 changes: 18 additions & 0 deletions
18
test/configCases/async-library/1-use-library/webpack.config.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,18 @@ | ||
var path = require("path"); | ||
|
||
/** @type {function(any, any): import("../../../../types").Configuration} */ | ||
module.exports = (env, { testPath }) => ({ | ||
target: "node14", | ||
output: { | ||
chunkLoading: "import" | ||
}, | ||
resolve: { | ||
alias: { | ||
library: path.resolve(testPath, "../0-create-library/lib.js") | ||
} | ||
}, | ||
experiments: { | ||
topLevelAwait: true, | ||
outputModule: true | ||
} | ||
}); |