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
27 changes: 27 additions & 0 deletions test/__snapshots__/modules-option.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6355,6 +6355,33 @@ exports.locals = {

exports[`modules issue #861: warnings 1`] = `Array []`;

exports[`modules issue #966: errors 1`] = `Array []`;

exports[`modules issue #966: module (evaluated) 1`] = `
Array [
Array [
1,
".button.hey {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the bug is right here: .button.hey is very different than: .button\.hey. The former is a selector for when both .button and .hey are on an element

color: red;
}
",
"",
],
]
`;

exports[`modules issue #966: module 1`] = `
"exports = module.exports = require(\\"../../../../src/runtime/api.js\\")(false);
// Module
exports.push([module.id, \\".button.hey {\\\\n color: red;\\\\n}\\\\n\\", \\"\\"]);
// Exports
exports.locals = {
\\"button\\": \\"button.hey\\"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also wrong, but if you escaped in getLocalIdent it would be fixed

};"
`;

exports[`modules issue #966: warnings 1`] = `Array []`;

exports[`modules issue #967: errors 1`] = `Array []`;

exports[`modules issue #967: module (evaluated) 1`] = `
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/modules/issue-966/button.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.button {
color: red;
}
5 changes: 5 additions & 0 deletions test/fixtures/modules/issue-966/toolbar.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@value btn from './button.css';

.toolbar > btn {
color: red
}
24 changes: 24 additions & 0 deletions test/modules-option.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,4 +485,28 @@ describe('modules', () => {
expect(stats.compilation.warnings).toMatchSnapshot('warnings');
expect(stats.compilation.errors).toMatchSnapshot('errors');
});

it('issue #966', async () => {
const config = {
loader: {
options: {
modules: {
getLocalIdent: (ctx, localIdentName, localName) =>
`${localName}.hey`,
},
},
},
};
const testId = './modules/issue-966/button.css';
const stats = await webpack(testId, config);
const { modules } = stats.toJson();
const module = modules.find((m) => m.id === testId);

expect(module.source).toMatchSnapshot('module');
expect(evaluated(module.source, modules)).toMatchSnapshot(
'module (evaluated)'
);
expect(stats.compilation.warnings).toMatchSnapshot('warnings');
expect(stats.compilation.errors).toMatchSnapshot('errors');
});
});