Skip to content

Commit c1e94fa

Browse files
test(library): cover the module library types the harness reads
The test runner reads the config as written, so its ESM dispatch has to mirror every place the default reads a module library type from — `output.enabledLibraryTypes` was missing. The entry-level case now covers `modern-module` next to `module`, and the changeset moves back out of the pending `experiments.outputModule` entry into one of its own.
1 parent 3f3d210 commit c1e94fa

5 files changed

Lines changed: 24 additions & 5 deletions

File tree

‎.changeset/004-remove-output-module-experiment.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"webpack": minor
33
---
44

5-
Remove `experiments.outputModule`, set `output.module` to emit ESM instead — a `module` or `modern-module` library type turns it on.
5+
Remove `experiments.outputModule`, set `output.module` to emit ESM instead.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"webpack": patch
3+
---
4+
5+
Enable `output.module` for `module` and `modern-module` library types.
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
"use strict";
22

3-
const BUNDLES = ["module.mjs", "modern-module.mjs", "entry-library.mjs"];
3+
const BUNDLES = [
4+
["module.mjs"],
5+
["modern-module.mjs"],
6+
["entry-module.mjs", "entry-modern-module.mjs"]
7+
];
48

59
module.exports = {
610
findBundle(i) {
7-
return [`./${BUNDLES[i]}`];
11+
return BUNDLES[i].map((name) => `./${name}`);
812
}
913
};

‎test/configCases/library/module-type-implies-output-module/webpack.config.js‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,16 @@ module.exports = [
4141
{
4242
mode: "development",
4343
entry: {
44-
main: {
44+
"entry-module": {
4545
import: "./index.js",
4646
library: { type: "module" }
47+
},
48+
"entry-modern-module": {
49+
import: "./index.js",
50+
library: { type: "modern-module" }
4751
}
4852
},
49-
output: { filename: "entry-library.mjs" },
53+
output: { filename: "[name].mjs" },
5054
plugins: [expectModuleOutput]
5155
}
5256
];

‎test/harness/runner/index.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ class TestRunner {
130130
if (output.module) return true;
131131
if (isModuleLibraryType(output.libraryTarget)) return true;
132132
if (output.library && isModuleLibraryType(output.library.type)) return true;
133+
if (
134+
output.enabledLibraryTypes &&
135+
output.enabledLibraryTypes.some(isModuleLibraryType)
136+
) {
137+
return true;
138+
}
133139
const { entry } = webpackOptions;
134140
if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
135141
return false;

0 commit comments

Comments
 (0)