Skip to content
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

test: issue 636 #853

Merged
merged 1 commit into from
Dec 5, 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
36 changes: 36 additions & 0 deletions test/__snapshots__/modules-option.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5342,3 +5342,39 @@ exports.locals = {
`;

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

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

exports[`modules issue #636: module (evaluated) 1`] = `
Array [
Array [
2,
".prefix-foo {
color: red;
}",
"",
],
Array [
1,
".prefix-bar {
}",
"",
],
]
`;

exports[`modules issue #636: module 1`] = `
"exports = module.exports = require(\\"../../../../src/runtime/api.js\\")(false);
// imports
exports.i(require(\\"-!../../../../src/index.js??ref--4-0!../../../../node_modules/sass-loader/lib/loader.js??ref--4-1!./foo.scss\\"), \\"\\");

// module
exports.push([module.id, \\".prefix-bar {\\\\n}\\", \\"\\"]);

// exports
exports.locals = {
\\"bar\\": \\"prefix-bar \\" + require(\\"-!../../../../src/index.js??ref--4-0!../../../../node_modules/sass-loader/lib/loader.js??ref--4-1!./foo.scss\\").locals[\\"foo\\"] + \\"\\"
};"
`;

exports[`modules issue #636: warnings 1`] = `Array []`;
3 changes: 3 additions & 0 deletions test/fixtures/modules/issue-636/foo.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.foo {
color: red;
}
3 changes: 3 additions & 0 deletions test/fixtures/modules/issue-636/source.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.bar {
composes: foo from "./foo.scss";
}
1 change: 1 addition & 0 deletions test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ function evaluated(output, modules, moduleId = 1) {
'url/node_modules',
'modules/',
'modules/issue-286',
'modules/issue-636',
'modules/node_modules',
'modules/tests-cases/urls',
'modules/tests-cases/issue-589',
Expand Down
35 changes: 33 additions & 2 deletions test/modules-option.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('modules', () => {
});
});

it(`composes should supports resolving`, async () => {
it('composes should supports resolving', async () => {
const config = {
loader: { options: { import: true, modules: true } },
};
Expand All @@ -54,7 +54,7 @@ describe('modules', () => {
expect(stats.compilation.errors).toMatchSnapshot('errors');
});

it(`issue #286`, async () => {
it('issue #286', async () => {
const config = {
loader: {
test: /source\.css$/,
Expand Down Expand Up @@ -86,4 +86,35 @@ describe('modules', () => {
expect(stats.compilation.warnings).toMatchSnapshot('warnings');
expect(stats.compilation.errors).toMatchSnapshot('errors');
});

it('issue #636', async () => {
const config = {
loader: {
test: /\.s[ca]ss$/i,
options: {
modules: true,
importLoaders: 1,
localIdentName: '[local]',
getLocalIdent: (context, localIdentName, localName) =>
`prefix-${localName}`,
},
},
sassLoader: true,
sassLoaderOptions: {
// eslint-disable-next-line global-require
implementation: require('sass'),
},
};
const testId = './modules/issue-636/source.scss';
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');
});
});