Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,7 @@ const keywords = new Set([
"volatile",
"while",
"with",
"module",
]);

function getExportCode(
Expand Down
23 changes: 23 additions & 0 deletions test/__snapshots__/modules-option.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -12431,6 +12431,29 @@ exports[`"modules" option should work with \`default\` class and without named e

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

exports[`"modules" option should work with \`module\` class and with named export: errors 1`] = `[]`;

exports[`"modules" option should work with \`module\` class and with named export: module 1`] = `
"// Imports
import ___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___ from "../../../../src/runtime/noSourceMaps.js";
import ___CSS_LOADER_API_IMPORT___ from "../../../../src/runtime/api.js";
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___);
// Module
___CSS_LOADER_EXPORT___.push([module.id, \`.jeU4gq1x5FP0ehaW1cBG {
background: red
}
\`, ""]);
// Exports
var _1 = \`jeU4gq1x5FP0ehaW1cBG\`;
export { _1 as "module" };
export default ___CSS_LOADER_EXPORT___;
"
`;

exports[`"modules" option should work with \`module\` class and with named export: result 1`] = `"jeU4gq1x5FP0ehaW1cBG"`;

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

exports[`"modules" option should work with CSS nesting: errors 1`] = `[]`;

exports[`"modules" option should work with CSS nesting: module 1`] = `
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/modules/issue-1590/source.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.module {
background: red
}
5 changes: 5 additions & 0 deletions test/fixtures/modules/issue-1590/source.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as css from './source.css';

__export__ = css.module;

export default css;
16 changes: 16 additions & 0 deletions test/modules-option.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2692,4 +2692,20 @@ describe('"modules" option', () => {
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});

it("should work with `module` class and with named export", async () => {
const compiler = getCompiler("./modules/issue-1590/source.js", {
modules: true,
});
const stats = await compile(compiler);

expect(
getModuleSource("./modules/issue-1590/source.css", stats),
).toMatchSnapshot("module");
expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot(
"result",
);
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
});