Skip to content

Commit 12f88e2

Browse files
test: resolving in node_modules (#866)
1 parent 1825e8a commit 12f88e2

File tree

6 files changed

+94
-0
lines changed

6 files changed

+94
-0
lines changed

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

+59
Original file line numberDiff line numberDiff line change
@@ -5378,3 +5378,62 @@ exports.locals = {
53785378
`;
53795379
53805380
exports[`modules issue #636: warnings 1`] = `Array []`;
5381+
5382+
exports[`modules issue #861: errors 1`] = `Array []`;
5383+
5384+
exports[`modules issue #861: module (evaluated) 1`] = `
5385+
Array [
5386+
Array [
5387+
2,
5388+
"
5389+
",
5390+
"",
5391+
],
5392+
Array [
5393+
4,
5394+
"._1ef5Heix1Kf4k0qYvyWRRO {
5395+
display: flex;
5396+
}
5397+
",
5398+
"",
5399+
],
5400+
Array [
5401+
3,
5402+
".L8pnpYm5VAu49S290uPMA {
5403+
color: red;
5404+
margin: 0;
5405+
padding: 0;
5406+
}
5407+
",
5408+
"",
5409+
],
5410+
Array [
5411+
1,
5412+
"._2gV2e6TcHcPgyDTzxbvkKa {
5413+
color: gray;
5414+
margin: 0;
5415+
padding: 0;
5416+
}
5417+
",
5418+
"",
5419+
],
5420+
]
5421+
`;
5422+
5423+
exports[`modules issue #861: module 1`] = `
5424+
"exports = module.exports = require(\\"../../../src/runtime/api.js\\")(false);
5425+
// Imports
5426+
exports.i(require(\\"-!../../../src/index.js??ref--4-0!@localpackage/color.css\\"), \\"\\");
5427+
exports.i(require(\\"-!../../../src/index.js??ref--4-0!@localpackage/style.css\\"), \\"\\");
5428+
5429+
// Module
5430+
exports.push([module.id, \\"._2gV2e6TcHcPgyDTzxbvkKa {\\\\n color: \\" + require(\\"-!../../../src/index.js??ref--4-0!@localpackage/color.css\\").locals[\\"color-grey\\"] + \\";\\\\n margin: 0;\\\\n padding: 0;\\\\n}\\\\n\\", \\"\\"]);
5431+
5432+
// Exports
5433+
exports.locals = {
5434+
\\"color-grey\\": \\"\\" + require(\\"-!../../../src/index.js??ref--4-0!@localpackage/color.css\\").locals[\\"color-grey\\"] + \\"\\",
5435+
\\"copyright\\": \\"_2gV2e6TcHcPgyDTzxbvkKa \\" + require(\\"-!../../../src/index.js??ref--4-0!@localpackage/style.css\\").locals[\\"type-heading\\"] + \\"\\"
5436+
};"
5437+
`;
5438+
5439+
exports[`modules issue #861: warnings 1`] = `Array []`;

test/fixtures/modules/node_modules/@localpackage/color.css

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/fixtures/modules/node_modules/@localpackage/style.css

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/fixtures/modules/node_modules/@otherlocalpackage/style.css

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@value color-grey from "~@localpackage/color.css";
2+
3+
.copyright {
4+
color: color-grey;
5+
composes: type-heading from "~@localpackage/style.css";
6+
margin: 0;
7+
padding: 0;
8+
}

test/modules-option.test.js

+17
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,21 @@ describe('modules', () => {
117117
expect(stats.compilation.warnings).toMatchSnapshot('warnings');
118118
expect(stats.compilation.errors).toMatchSnapshot('errors');
119119
});
120+
121+
it('issue #861', async () => {
122+
const config = {
123+
loader: { options: { modules: true } },
124+
};
125+
const testId = './modules/resolving-inside-node-modules.css';
126+
const stats = await webpack(testId, config);
127+
const { modules } = stats.toJson();
128+
const module = modules.find((m) => m.id === testId);
129+
130+
expect(module.source).toMatchSnapshot('module');
131+
expect(evaluated(module.source, modules)).toMatchSnapshot(
132+
'module (evaluated)'
133+
);
134+
expect(stats.compilation.warnings).toMatchSnapshot('warnings');
135+
expect(stats.compilation.errors).toMatchSnapshot('errors');
136+
});
120137
});

0 commit comments

Comments
 (0)