Skip to content

Commit 01869bc

Browse files
fix: allow to use module class name (#1649)
1 parent 7dd15ec commit 01869bc

File tree

6 files changed

+78
-5
lines changed

6 files changed

+78
-5
lines changed

package-lock.json

Lines changed: 30 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,7 @@ const keywords = new Set([
11831183
"volatile",
11841184
"while",
11851185
"with",
1186+
"module",
11861187
]);
11871188

11881189
function getExportCode(

test/__snapshots__/modules-option.test.js.snap

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12431,6 +12431,29 @@ exports[`"modules" option should work with \`default\` class and without named e
1243112431

1243212432
exports[`"modules" option should work with \`default\` class and without named export: warnings 1`] = `[]`;
1243312433

12434+
exports[`"modules" option should work with \`module\` class and with named export: errors 1`] = `[]`;
12435+
12436+
exports[`"modules" option should work with \`module\` class and with named export: module 1`] = `
12437+
"// Imports
12438+
import ___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___ from "../../../../src/runtime/noSourceMaps.js";
12439+
import ___CSS_LOADER_API_IMPORT___ from "../../../../src/runtime/api.js";
12440+
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___);
12441+
// Module
12442+
___CSS_LOADER_EXPORT___.push([module.id, \`.jeU4gq1x5FP0ehaW1cBG {
12443+
background: red
12444+
}
12445+
\`, ""]);
12446+
// Exports
12447+
var _1 = \`jeU4gq1x5FP0ehaW1cBG\`;
12448+
export { _1 as "module" };
12449+
export default ___CSS_LOADER_EXPORT___;
12450+
"
12451+
`;
12452+
12453+
exports[`"modules" option should work with \`module\` class and with named export: result 1`] = `"jeU4gq1x5FP0ehaW1cBG"`;
12454+
12455+
exports[`"modules" option should work with \`module\` class and with named export: warnings 1`] = `[]`;
12456+
1243412457
exports[`"modules" option should work with CSS nesting: errors 1`] = `[]`;
1243512458

1243612459
exports[`"modules" option should work with CSS nesting: module 1`] = `
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.module {
2+
background: red
3+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import * as css from './source.css';
2+
3+
__export__ = css.module;
4+
5+
export default css;

test/modules-option.test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2692,4 +2692,20 @@ describe('"modules" option', () => {
26922692
expect(getWarnings(stats)).toMatchSnapshot("warnings");
26932693
expect(getErrors(stats)).toMatchSnapshot("errors");
26942694
});
2695+
2696+
it("should work with `module` class and with named export", async () => {
2697+
const compiler = getCompiler("./modules/issue-1590/source.js", {
2698+
modules: true,
2699+
});
2700+
const stats = await compile(compiler);
2701+
2702+
expect(
2703+
getModuleSource("./modules/issue-1590/source.css", stats),
2704+
).toMatchSnapshot("module");
2705+
expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot(
2706+
"result",
2707+
);
2708+
expect(getWarnings(stats)).toMatchSnapshot("warnings");
2709+
expect(getErrors(stats)).toMatchSnapshot("errors");
2710+
});
26952711
});

0 commit comments

Comments
 (0)