Skip to content

Commit ffcda87

Browse files
2 parents cd754f5 + 3a1f1f2 commit ffcda87

File tree

13 files changed

+598
-357
lines changed

13 files changed

+598
-357
lines changed

.github/workflows/nodejs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
strategy:
5656
matrix:
5757
os: [ubuntu-latest, windows-latest, macos-latest]
58-
node-version: [8.x, 10.x, 12.x, 13.x]
58+
node-version: [8.x, 10.x, 12.x, 14.x]
5959
webpack-version: [latest, next]
6060

6161
runs-on: ${{ matrix.os }}

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
### [3.5.3](https://github.com/webpack-contrib/css-loader/compare/v3.5.2...v3.5.3) (2020-04-24)
6+
7+
8+
### Bug Fixes
9+
10+
* add file from an error to file dependencies ([841423f](https://github.com/webpack-contrib/css-loader/commit/841423fca2932c18f8ac0cf0a1f0012fc0a62fb6))
11+
* avoid query string in source maps ([#1082](https://github.com/webpack-contrib/css-loader/issues/1082)) ([f64de13](https://github.com/webpack-contrib/css-loader/commit/f64de13f7377eff9501348cf26213212ca696913))
12+
513
### [3.5.2](https://github.com/webpack-contrib/css-loader/compare/v3.5.1...v3.5.2) (2020-04-10)
614

715

package-lock.json

Lines changed: 496 additions & 342 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "css-loader",
3-
"version": "3.5.2-1",
3+
"version": "3.5.3",
44
"description": "css loader module for webpack",
55
"license": "MIT",
66
"repository": "webpack-contrib/css-loader",
@@ -54,40 +54,40 @@
5454
"postcss-modules-scope": "^2.2.0",
5555
"postcss-modules-values": "^3.0.0",
5656
"postcss-value-parser": "^4.0.3",
57-
"schema-utils": "^2.6.5",
57+
"schema-utils": "^2.6.6",
5858
"semver": "^6.3.0"
5959
},
6060
"devDependencies": {
6161
"@babel/cli": "^7.8.4",
6262
"@babel/core": "^7.9.0",
63-
"@babel/preset-env": "^7.9.0",
63+
"@babel/preset-env": "^7.9.5",
6464
"@commitlint/cli": "^8.3.5",
6565
"@commitlint/config-conventional": "^8.3.4",
6666
"@webpack-contrib/defaults": "^6.3.0",
6767
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
68-
"babel-jest": "^25.3.0",
68+
"babel-jest": "^25.4.0",
6969
"cross-env": "^7.0.2",
7070
"del": "^5.1.0",
7171
"del-cli": "^3.0.0",
7272
"es-check": "^5.1.0",
7373
"eslint": "^6.8.0",
74-
"eslint-config-prettier": "^6.10.1",
74+
"eslint-config-prettier": "^6.11.0",
7575
"eslint-plugin-import": "^2.20.2",
7676
"file-loader": "^6.0.0",
7777
"husky": "^4.2.5",
78-
"jest": "^25.3.0",
79-
"lint-staged": "^10.1.3",
78+
"jest": "^25.4.0",
79+
"lint-staged": "^10.1.7",
8080
"memfs": "^3.1.2",
8181
"npm-run-all": "^4.1.5",
8282
"postcss-loader": "^3.0.0",
8383
"postcss-preset-env": "^6.7.0",
84-
"prettier": "^2.0.4",
84+
"prettier": "^2.0.5",
8585
"sass": "^1.26.3",
8686
"sass-loader": "^8.0.2",
8787
"standard-version": "^7.1.0",
8888
"strip-ansi": "^6.0.0",
8989
"url-loader": "^4.1.0",
90-
"webpack": "^4.42.1"
90+
"webpack": "^4.43.0"
9191
},
9292
"keywords": [
9393
"webpack",

src/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ export default function loader(content, map, meta) {
8282

8383
postcss(plugins)
8484
.process(content, {
85-
from: this.remainingRequest.split('!').pop(),
86-
to: this.currentRequest.split('!').pop(),
85+
from: this.resourcePath,
86+
to: this.resourcePath,
8787
map: options.sourceMap
8888
? {
8989
// Some loaders (example `"postcss-loader": "1.x.x"`) always generates source map, we should remove it
@@ -150,6 +150,10 @@ export default function loader(content, map, meta) {
150150
return callback(null, `${importCode}${moduleCode}${exportCode}`);
151151
})
152152
.catch((error) => {
153+
if (error.file) {
154+
this.addDependency(error.file);
155+
}
156+
153157
callback(
154158
error.name === 'CssSyntaxError' ? new CssSyntaxError(error) : error
155159
);

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

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,49 @@ Array [
294294

295295
exports[`"sourceMap" option not specified should not generate source maps: warnings 1`] = `Array []`;
296296

297+
exports[`"sourceMap" option true should generate source maps #2: errors 1`] = `Array []`;
298+
299+
exports[`"sourceMap" option true should generate source maps #2: module 1`] = `
300+
"// Imports
301+
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../src/runtime/api.js\\");
302+
exports = ___CSS_LOADER_API_IMPORT___(true);
303+
// Module
304+
exports.push([module.id, \\".foo {\\\\n color: red;\\\\n}\\\\n\\", \\"\\",{\\"version\\":3,\\"sources\\":[\\"with-query.css\\"],\\"names\\":[],\\"mappings\\":\\"AAAA;EACE,UAAU;AACZ\\",\\"file\\":\\"with-query.css\\",\\"sourcesContent\\":[\\".foo {\\\\n color: red;\\\\n}\\\\n\\"]}]);
305+
// Exports
306+
module.exports = exports;
307+
"
308+
`;
309+
310+
exports[`"sourceMap" option true should generate source maps #2: result 1`] = `
311+
Array [
312+
Array [
313+
"./source-map/with-query.css?url=false",
314+
".foo {
315+
color: red;
316+
}
317+
",
318+
"",
319+
Object {
320+
"file": "with-query.css",
321+
"mappings": "AAAA;EACE,UAAU;AACZ",
322+
"names": Array [],
323+
"sources": Array [
324+
"with-query.css",
325+
],
326+
"sourcesContent": Array [
327+
".foo {
328+
color: red;
329+
}
330+
",
331+
],
332+
"version": 3,
333+
},
334+
],
335+
]
336+
`;
337+
338+
exports[`"sourceMap" option true should generate source maps #2: warnings 1`] = `Array []`;
339+
297340
exports[`"sourceMap" option true should generate source maps when source maps equal to "null" from an other loader: errors 1`] = `Array []`;
298341

299342
exports[`"sourceMap" option true should generate source maps when source maps equal to "null" from an other loader: module 1`] = `
File renamed without changes.

test/fixtures/invalid.js renamed to test/fixtures/error.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import css from './invalid.css';
1+
import css from './error.css';
22

33
__export__ = css;
44

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.foo {
2+
color: red;
3+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import css from './with-query.css?url=false';
2+
3+
__export__ = css;
4+
5+
export default css;

test/helpers/ast-loader.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ export default function astLoader(content) {
1111
const { spy = jest.fn() } = this.query;
1212

1313
postcss([postcssPresetEnv({ stage: 0 })])
14-
.process(content)
14+
.process(content, {
15+
// eslint-disable-next-line no-undefined
16+
from: undefined,
17+
})
1518
.then(({ css, map, root, messages }) => {
1619
const ast = {
1720
type: 'postcss',

test/loader.test.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,14 @@ describe('loader', () => {
123123
});
124124

125125
it('should throw error on invalid css syntax', async () => {
126-
const compiler = getCompiler('./invalid.js', {});
126+
const compiler = getCompiler('./error.js', {});
127127
const stats = await compile(compiler);
128128

129+
expect(
130+
stats.compilation.fileDependencies.has(
131+
path.resolve('./test/fixtures/error.css')
132+
)
133+
).toBe(true);
129134
expect(getWarnings(stats)).toMatchSnapshot('warnings');
130135
expect(getErrors(stats)).toMatchSnapshot('errors');
131136
});

test/sourceMap-option.test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,22 @@ describe('"sourceMap" option', () => {
4545
expect(getErrors(stats)).toMatchSnapshot('errors');
4646
});
4747

48+
it('should generate source maps #2', async () => {
49+
const compiler = getCompiler('./source-map/with-query.js', {
50+
sourceMap: true,
51+
});
52+
const stats = await compile(compiler);
53+
54+
expect(
55+
getModuleSource('./source-map/with-query.css?url=false', stats)
56+
).toMatchSnapshot('module');
57+
expect(
58+
getExecutedCode('main.bundle.js', compiler, stats)
59+
).toMatchSnapshot('result');
60+
expect(getWarnings(stats)).toMatchSnapshot('warnings');
61+
expect(getErrors(stats)).toMatchSnapshot('errors');
62+
});
63+
4864
it('should generate source maps when source maps equal to "null" from an other loader', async () => {
4965
const compiler = getCompiler(
5066
'./source-map/basic.js',

0 commit comments

Comments
 (0)