Skip to content

test: resolving in node_modules #866

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
Dec 10, 2018
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
59 changes: 59 additions & 0 deletions test/__snapshots__/modules-option.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5378,3 +5378,62 @@ exports.locals = {
`;

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

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

exports[`modules issue #861: module (evaluated) 1`] = `
Array [
Array [
2,
"
",
"",
],
Array [
4,
"._1ef5Heix1Kf4k0qYvyWRRO {
display: flex;
}
",
"",
],
Array [
3,
".L8pnpYm5VAu49S290uPMA {
color: red;
margin: 0;
padding: 0;
}
",
"",
],
Array [
1,
"._2gV2e6TcHcPgyDTzxbvkKa {
color: gray;
margin: 0;
padding: 0;
}
",
"",
],
]
`;

exports[`modules issue #861: module 1`] = `
"exports = module.exports = require(\\"../../../src/runtime/api.js\\")(false);
// Imports
exports.i(require(\\"-!../../../src/index.js??ref--4-0!@localpackage/color.css\\"), \\"\\");
exports.i(require(\\"-!../../../src/index.js??ref--4-0!@localpackage/style.css\\"), \\"\\");

// Module
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\\", \\"\\"]);

// Exports
exports.locals = {
\\"color-grey\\": \\"\\" + require(\\"-!../../../src/index.js??ref--4-0!@localpackage/color.css\\").locals[\\"color-grey\\"] + \\"\\",
\\"copyright\\": \\"_2gV2e6TcHcPgyDTzxbvkKa \\" + require(\\"-!../../../src/index.js??ref--4-0!@localpackage/style.css\\").locals[\\"type-heading\\"] + \\"\\"
};"
`;

exports[`modules issue #861: warnings 1`] = `Array []`;
1 change: 1 addition & 0 deletions test/fixtures/modules/node_modules/@localpackage/color.css

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

6 changes: 6 additions & 0 deletions test/fixtures/modules/node_modules/@localpackage/style.css

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

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

8 changes: 8 additions & 0 deletions test/fixtures/modules/resolving-inside-node-modules.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@value color-grey from "~@localpackage/color.css";

.copyright {
color: color-grey;
composes: type-heading from "~@localpackage/style.css";
margin: 0;
padding: 0;
}
17 changes: 17 additions & 0 deletions test/modules-option.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,21 @@ describe('modules', () => {
expect(stats.compilation.warnings).toMatchSnapshot('warnings');
expect(stats.compilation.errors).toMatchSnapshot('errors');
});

it('issue #861', async () => {
const config = {
loader: { options: { modules: true } },
};
const testId = './modules/resolving-inside-node-modules.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');
});
});