Skip to content

Commit 6bd6dc0

Browse files
test: fix
1 parent 7dd15ec commit 6bd6dc0

5 files changed

Lines changed: 52 additions & 4 deletions

File tree

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: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11817,7 +11817,7 @@ ___CSS_LOADER_EXPORT___.push([module.id, \`.ComponentName-header {
1181711817
}
1181811818

1181911819
.ComponentName-footer {
11820-
color: blue;
11820+
color: blue;
1182111821
}
1182211822
\`, ""]);
1182311823
// Exports
@@ -11841,7 +11841,7 @@ exports[`"modules" option should work with [folder] #3: result 1`] = `
1184111841
}
1184211842

1184311843
.ComponentName-footer {
11844-
color: blue;
11844+
color: blue;
1184511845
}
1184611846
",
1184711847
"",
@@ -11868,7 +11868,7 @@ ___CSS_LOADER_EXPORT___.push([module.id, \`.ComponentName-header {
1186811868
}
1186911869

1187011870
.ComponentName-footer {
11871-
color: blue;
11871+
color: blue;
1187211872
}
1187311873
\`, ""]);
1187411874
// Exports
@@ -11892,7 +11892,7 @@ exports[`"modules" option should work with [folder] #4: result 1`] = `
1189211892
}
1189311893

1189411894
.ComponentName-footer {
11895-
color: blue;
11895+
color: blue;
1189611896
}
1189711897
",
1189811898
"",
@@ -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)