Skip to content

Issue 1307 test #1334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 14, 2021
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
42 changes: 42 additions & 0 deletions test/__snapshots__/modules-option.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13412,6 +13412,48 @@ Array [

exports[`"modules" option should work with the "auto" by default for icss: warnings 1`] = `Array []`;

exports[`"modules" option should work with the "auto" by default when CSS file is entrypoint: entry 1`] = `
"// Imports
import ___CSS_LOADER_API_IMPORT___ from \\"../../../../src/runtime/api.js\\";
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(function(i){return i[1]});
// Module
___CSS_LOADER_EXPORT___.push([module.id, \\".class {\\\\n color: red;\\\\n}\\\\n\\", \\"\\"]);
// Exports
export default ___CSS_LOADER_EXPORT___;
"
`;

exports[`"modules" option should work with the "auto" by default when CSS file is entrypoint: errors 1`] = `Array []`;

exports[`"modules" option should work with the "auto" by default when CSS file is entrypoint: module 1`] = `
"// Imports
import ___CSS_LOADER_API_IMPORT___ from \\"../../../../src/runtime/api.js\\";
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(function(i){return i[1]});
// Module
___CSS_LOADER_EXPORT___.push([module.id, \\"._wr0eVpMbaGr94MKhByE {\\\\n color: red;\\\\n}\\\\n\\", \\"\\"]);
// Exports
___CSS_LOADER_EXPORT___.locals = {
\\"relative\\": \\"_wr0eVpMbaGr94MKhByE\\"
};
export default ___CSS_LOADER_EXPORT___;
"
`;

exports[`"modules" option should work with the "auto" by default when CSS file is entrypoint: result 1`] = `
Array [
Array [
"./modules/mode/relative.module.css",
"._wr0eVpMbaGr94MKhByE {
color: red;
}
",
"",
],
]
`;

exports[`"modules" option should work with the "auto" by default when CSS file is entrypoint: warnings 1`] = `Array []`;

exports[`"modules" option should work with the "auto" by default with "modules" filename: errors 1`] = `Array []`;

exports[`"modules" option should work with the "auto" by default with "modules" filename: module 1`] = `
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/modules/mode/entry.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.class {
color: red;
}
4 changes: 3 additions & 1 deletion test/helpers/getCompiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ export default (fixture, loaderOptions = {}, config = {}) => {
target: "node",
devtool: config.devtool || false,
context: path.resolve(__dirname, "../fixtures"),
entry: path.resolve(__dirname, "../fixtures", fixture),
entry: Array.isArray(fixture)
? fixture
: path.resolve(__dirname, "../fixtures", fixture),
output: {
path: path.resolve(__dirname, "../outputs"),
filename: "[name].bundle.js",
Expand Down
20 changes: 20 additions & 0 deletions test/modules-option.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,26 @@ describe('"modules" option', () => {
expect(getErrors(stats)).toMatchSnapshot("errors");
});

it('should work with the "auto" by default when CSS file is entrypoint', async () => {
const compiler = getCompiler([
"./modules/mode/entry.css",
"./modules/mode/modules.js",
]);
const stats = await compile(compiler);

expect(getModuleSource("./modules/mode/entry.css", stats)).toMatchSnapshot(
"entry"
);
expect(
getModuleSource("./modules/mode/relative.module.css", stats)
).toMatchSnapshot("module");
expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot(
"result"
);
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});

it('should work with the "auto" by default with "modules" filename', async () => {
const compiler = getCompiler("./modules/mode/modules-2.js");
const stats = await compile(compiler);
Expand Down