Skip to content

Commit 6480f02

Browse files
authored
chore: upgrade dependencies (#342)
1 parent 700eb14 commit 6480f02

File tree

13 files changed

+3024
-3369
lines changed

13 files changed

+3024
-3369
lines changed

package.json

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,40 +33,40 @@
3333
"types": "./types/index.d.ts",
3434
"homepage": "https://github.com/egoist/rollup-plugin-postcss#readme",
3535
"devDependencies": {
36-
"@babel/core": "^7.9.0",
37-
"@babel/preset-env": "^7.9.5",
38-
"autoprefixer": "^9.7.6",
36+
"@babel/core": "^7.12.9",
37+
"@babel/preset-env": "^7.12.7",
38+
"autoprefixer": "^10.0.4",
3939
"babel-core": "^7.0.0-bridge.0",
40-
"babel-jest": "^25.3.0",
41-
"bili": "^4.9.0",
40+
"babel-jest": "^26.6.3",
41+
"bili": "^5.0.5",
4242
"eslint-config-rem": "^4.0.0",
43-
"fs-extra": "^9.0.0",
44-
"jest": "^25.3.0",
45-
"less": "^3.11.1",
46-
"node-sass": "^4.13.1",
47-
"postcss": "^8.0.0",
48-
"rollup": "^2.6.1",
49-
"stylus": "^0.54.7",
50-
"sugarss": "^2.0.0",
51-
"xo": "^0.29.1"
43+
"fs-extra": "^9.0.1",
44+
"jest": "^26.6.3",
45+
"less": "^3.12.2",
46+
"node-sass": "^5.0.0",
47+
"postcss": "^8.1.14",
48+
"rollup": "^2.34.2",
49+
"stylus": "^0.54.8",
50+
"sugarss": "^3.0.3",
51+
"xo": "^0.35.0"
5252
},
5353
"dependencies": {
54-
"chalk": "^4.0.0",
54+
"chalk": "^4.1.0",
5555
"concat-with-sourcemaps": "^1.1.0",
5656
"cssnano": "^4.1.10",
5757
"import-cwd": "^3.0.0",
58-
"p-queue": "^6.3.0",
58+
"p-queue": "^6.6.2",
5959
"pify": "^5.0.0",
60-
"postcss-load-config": "^2.1.0",
61-
"postcss-modules": "^2.0.0",
60+
"postcss-load-config": "^3.0.0",
61+
"postcss-modules": "^4.0.0",
6262
"promise.series": "^0.2.0",
63-
"resolve": "^1.16.1",
63+
"resolve": "^1.19.0",
6464
"rollup-pluginutils": "^2.8.2",
65-
"safe-identifier": "^0.4.1",
65+
"safe-identifier": "^0.4.2",
6666
"style-inject": "^0.3.0"
6767
},
6868
"peerDependencies": {
69-
"postcss": "^8.0.0"
69+
"postcss": "^8.1.14"
7070
},
7171
"xo": {
7272
"extends": "rem",

src/index.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ function getRecursiveImportOrder(id, getModuleInfo, seen = new Set()) {
3838
return result
3939
}
4040

41+
/* eslint import/no-anonymous-default-export: [2, {"allowArrowFunction": true}] */
4142
export default (options = {}) => {
4243
const filter = createFilter(options.include, options.exclude)
4344
const postcssPlugins = Array.isArray(options.plugins) ?
@@ -139,6 +140,7 @@ export default (options = {}) => {
139140

140141
augmentChunkHash() {
141142
if (extracted.size === 0) return
143+
// eslint-disable-next-line unicorn/no-reduce
142144
const extractedValue = [...extracted].reduce((object, [key, value]) => ({
143145
...object,
144146
[key]: value
@@ -152,6 +154,7 @@ export default (options = {}) => {
152154
!(options_.dir || options_.file)
153155
) return
154156

157+
// eslint-disable-next-line no-warning-comments
155158
// TODO: support `[hash]`
156159
const dir = options_.dir || path.dirname(options_.file)
157160
const file =
@@ -163,11 +166,7 @@ export default (options = {}) => {
163166
const getExtracted = () => {
164167
let fileName = `${path.basename(file, path.extname(file))}.css`
165168
if (typeof postcssLoaderOptions.extract === 'string') {
166-
if (path.isAbsolute(postcssLoaderOptions.extract)) {
167-
fileName = normalizePath(path.relative(dir, postcssLoaderOptions.extract))
168-
} else {
169-
fileName = normalizePath(postcssLoaderOptions.extract)
170-
}
169+
fileName = path.isAbsolute(postcssLoaderOptions.extract) ? normalizePath(path.relative(dir, postcssLoaderOptions.extract)) : normalizePath(postcssLoaderOptions.extract)
171170
}
172171

173172
const concat = new Concat(true, fileName, '\n')

src/less-loader.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import pify from 'pify'
22
import humanlizePath from './utils/humanlize-path'
33
import { loadModule } from './utils/load-module'
44

5+
/* eslint import/no-anonymous-default-export: [2, {"allowObject": true}] */
56
export default {
67
name: 'less',
78
test: /\.less$/,

src/postcss-loader.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,12 @@ function isModuleFile(file) {
5252
return /\.module\.[a-z]{2,6}$/.test(file)
5353
}
5454

55+
/* eslint import/no-anonymous-default-export: [2, {"allowObject": true}] */
5556
export default {
5657
name: 'postcss',
5758
alwaysProcess: true,
5859
// `test` option is dynamically set in ./loaders
60+
// eslint-disable-next-line complexity
5961
async process({ code, map }) {
6062
const config = this.options.config ?
6163
await loadConfig(this.id, this.options.config) :
@@ -126,9 +128,14 @@ export default {
126128
if (plugins.length === 0) {
127129
// Prevent from postcss warning:
128130
// You did not set any plugins, parser, or stringifier. Right now, PostCSS does nothing. Pick plugins for your case on https://www.postcss.parts/ and use them in postcss.config.js
129-
const noopPlugin = postcss.plugin('postcss-noop-plugin', () => () => {
130-
/* noop */
131-
})
131+
const noopPlugin = () => {
132+
return {
133+
postcssPlugin: 'postcss-noop-plugin',
134+
Once() {
135+
}
136+
}
137+
}
138+
132139
plugins.push(noopPlugin())
133140
}
134141

@@ -201,17 +208,12 @@ export default {
201208
}
202209

203210
if (!shouldExtract && shouldInject) {
204-
if (typeof options.inject === 'function') {
205-
output += options.inject(cssVariableName, this.id)
206-
} else {
207-
output += '\n' +
208-
`import styleInject from '${styleInjectPath}';\n` +
209-
`styleInject(${cssVariableName}${
210-
Object.keys(options.inject).length > 0 ?
211-
`,${JSON.stringify(options.inject)}` :
212-
''
213-
});`
214-
}
211+
output += typeof options.inject === 'function' ? options.inject(cssVariableName, this.id) : '\n' +
212+
`import styleInject from '${styleInjectPath}';\n` +
213+
`styleInject(${cssVariableName}${Object.keys(options.inject).length > 0 ?
214+
`,${JSON.stringify(options.inject)}` :
215+
''
216+
});`
215217
}
216218

217219
return {

src/sass-loader.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const resolvePromise = pify(resolve)
2121
// List of supported SASS modules in the order of preference
2222
const sassModuleIds = ['node-sass', 'sass']
2323

24+
/* eslint import/no-anonymous-default-export: [2, {"allowObject": true}] */
2425
export default {
2526
name: 'sass',
2627
test: /\.(sass|scss)$/,
@@ -29,7 +30,7 @@ export default {
2930
const sass = loadSassOrThrow()
3031
const render = pify(sass.render.bind(sass))
3132
const data = this.options.data || ''
32-
return workQueue.add(() =>
33+
workQueue.add(() =>
3334
render({
3435
...this.options,
3536
file: this.id,

src/stylus-loader.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import pify from 'pify'
22
import { loadModule } from './utils/load-module'
33

4+
/* eslint import/no-anonymous-default-export: [2, {"allowObject": true}] */
45
export default {
56
name: 'stylus',
67
test: /\.(styl|stylus)$/,

src/utils/load-module.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export function loadModule(moduleId) {
44
// Trying to load module normally (relative to plugin directory)
55
try {
66
return require(moduleId)
7-
} catch (_) {
7+
} catch {
88
// Ignore error
99
}
1010

src/utils/normalize-path.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
/* eslint import/no-anonymous-default-export: [2, {"allowArrowFunction": true}] */
12
export default path => path && path.replace(/\\+/g, '/')

test/__snapshots__/index.test.js.snap

Lines changed: 97 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,57 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`basic on-import: js code 1`] = `
4+
"'use strict';
5+
6+
function styleInject(css, ref) {
7+
if ( ref === void 0 ) ref = {};
8+
var insertAt = ref.insertAt;
9+
10+
if (!css || typeof document === 'undefined') { return; }
11+
12+
var head = document.head || document.getElementsByTagName('head')[0];
13+
var style = document.createElement('style');
14+
style.type = 'text/css';
15+
16+
if (insertAt === 'top') {
17+
if (head.firstChild) {
18+
head.insertBefore(style, head.firstChild);
19+
} else {
20+
head.appendChild(style);
21+
}
22+
} else {
23+
head.appendChild(style);
24+
}
25+
26+
if (style.styleSheet) {
27+
style.styleSheet.cssText = css;
28+
} else {
29+
style.appendChild(document.createTextNode(css));
30+
}
31+
}
32+
33+
var css_248z = \\"body {\\\\n color: red;\\\\n}\\\\n\\";
34+
styleInject(css_248z);
35+
36+
var css_248z$1 = \\".bar {\\\\n color: red;\\\\n}\\\\n\\";
37+
styleInject(css_248z$1);
38+
39+
var css_248z$2 = \\"body {\\\\n color: #f00;\\\\n background: #f00;\\\\n}\\\\n\\";
40+
styleInject(css_248z$2);
41+
42+
var css_248z$3 = \\"#sidebar {\\\\n width: 30%;\\\\n background-color: #faa; }\\\\n\\";
43+
styleInject(css_248z$3);
44+
45+
var css_248z$4 = \\"#header {\\\\n color: #6c94be;\\\\n}\\\\n\\";
46+
styleInject(css_248z$4);
47+
48+
var css_248z$5 = \\".pcss {\\\\n color: red;\\\\n}\\\\n\\";
49+
styleInject(css_248z$5);
50+
51+
console.log(css_248z, css_248z$1);
52+
"
53+
`;
54+
355
exports[`basic postcss-config: js code 1`] = `
456
"'use strict';
557
@@ -191,7 +243,11 @@ exports[`extract custom-path: css map 1`] = `"{\\"version\\":3,\\"sources\\":[\\
191243
exports[`extract custom-path: js code 1`] = `
192244
"'use strict';
193245
194-
console.log(undefined, undefined);
246+
var foo = undefined;
247+
248+
var bar = undefined;
249+
250+
console.log(foo, bar);
195251
"
196252
`;
197253

@@ -289,7 +345,11 @@ exports[`extract relative-path: css map 1`] = `"{\\"version\\":3,\\"sources\\":[
289345
exports[`extract relative-path: js code 1`] = `
290346
"'use strict';
291347
292-
console.log(undefined, undefined);
348+
var foo = undefined;
349+
350+
var bar = undefined;
351+
352+
console.log(foo, bar);
293353
"
294354
`;
295355

@@ -326,7 +386,11 @@ body {
326386
exports[`extract sourcemap-inline: js code 1`] = `
327387
"'use strict';
328388
329-
console.log(undefined, undefined);
389+
var foo = undefined;
390+
391+
var bar = undefined;
392+
393+
console.log(foo, bar);
330394
"
331395
`;
332396

@@ -364,7 +428,11 @@ exports[`extract sourcemap-true: css map 1`] = `"{\\"version\\":3,\\"sources\\":
364428
exports[`extract sourcemap-true: js code 1`] = `
365429
"'use strict';
366430
367-
console.log(undefined, undefined);
431+
var foo = undefined;
432+
433+
var bar = undefined;
434+
435+
console.log(foo, bar);
368436
"
369437
`;
370438

@@ -399,7 +467,11 @@ body {
399467
exports[`extract true: js code 1`] = `
400468
"'use strict';
401469
402-
console.log(undefined, undefined);
470+
var foo = undefined;
471+
472+
var bar = undefined;
473+
474+
console.log(foo, bar);
403475
"
404476
`;
405477

@@ -496,7 +568,11 @@ exports[`minimize extract: css code 1`] = `".bar,body{color:red}body{background:
496568
exports[`minimize extract: js code 1`] = `
497569
"'use strict';
498570
499-
console.log(undefined, undefined);
571+
var foo = undefined;
572+
573+
var bar = undefined;
574+
575+
console.log(foo, bar);
500576
"
501577
`;
502578

@@ -508,7 +584,11 @@ exports[`minimize extract-sourcemap-inline: css code 1`] = `
508584
exports[`minimize extract-sourcemap-inline: js code 1`] = `
509585
"'use strict';
510586
511-
console.log(undefined, undefined);
587+
var foo = undefined;
588+
589+
var bar = undefined;
590+
591+
console.log(foo, bar);
512592
"
513593
`;
514594

@@ -522,7 +602,11 @@ exports[`minimize extract-sourcemap-true: css map 1`] = `"{\\"version\\":3,\\"so
522602
exports[`minimize extract-sourcemap-true: js code 1`] = `
523603
"'use strict';
524604
525-
console.log(undefined, undefined);
605+
var foo = undefined;
606+
607+
var bar = undefined;
608+
609+
console.log(foo, bar);
526610
"
527611
`;
528612

@@ -825,7 +909,11 @@ console.log(style$1);
825909
exports[`onExtract 1`] = `
826910
"'use strict';
827911
828-
console.log(undefined, undefined);
912+
var foo = undefined;
913+
914+
var bar = undefined;
915+
916+
console.log(foo, bar);
829917
"
830918
`;
831919

test/fixtures/nested/nested.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import './nested.css'
2-
2+
/* eslint import/no-anonymous-default-export: [2, {"allowLiteral": true}] */
33
export default 'test'
44
export { default as component } from './component'

0 commit comments

Comments
 (0)