Skip to content

Commit 8791cc2

Browse files
refactor!: minimum supported Node.js version is 20.9.0 (#303)
1 parent c0fad56 commit 8791cc2

20 files changed

+8459
-9480
lines changed

.github/workflows/nodejs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
strategy:
6868
matrix:
6969
os: [ubuntu-latest, windows-latest, macos-latest]
70-
node-version: [18.x, 20.x, 22.x, 24.x]
70+
node-version: [20.x, 22.x, 24.x, 25.x]
7171
webpack-version: [latest]
7272

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

package-lock.json

Lines changed: 8387 additions & 9402 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 & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -64,48 +64,37 @@
6464
"jest-worker": "^30.0.5",
6565
"postcss": "^8.4.40",
6666
"schema-utils": "^4.2.0",
67-
"serialize-javascript": "^6.0.2"
67+
"serialize-javascript": "^7.0.3"
6868
},
6969
"devDependencies": {
7070
"@babel/cli": "^7.24.8",
7171
"@babel/core": "^7.25.2",
7272
"@babel/preset-env": "^7.25.3",
73-
"@commitlint/cli": "^19.3.0",
74-
"@commitlint/config-conventional": "^19.2.2",
75-
"@eslint/js": "^9.32.0",
76-
"@eslint/markdown": "^7.0.0",
73+
"@commitlint/cli": "^20.4.2",
74+
"@commitlint/config-conventional": "^20.4.2",
7775
"@parcel/css": "^1.8.3",
78-
"@stylistic/eslint-plugin": "^5.2.2",
7976
"@swc/css": "^0.0.28",
8077
"@types/clean-css": "^4.2.11",
8178
"@types/csso": "^5.0.4",
8279
"@types/node": "^20.14.9",
8380
"@types/serialize-javascript": "^5.0.4",
8481
"babel-jest": "^30.0.5",
8582
"clean-css": "^5.3.3",
86-
"copy-webpack-plugin": "^13.0.0",
83+
"copy-webpack-plugin": "^14.0.0",
8784
"cross-env": "^7.0.3",
88-
"cspell": "^8.13.1",
85+
"cspell": "^9.7.0",
8986
"css-loader": "^6.10.0",
9087
"cssnano-preset-simple": "^4.0.0",
9188
"csso": "^5.0.3",
9289
"del": "^6.1.0",
93-
"del-cli": "^5.1.0",
94-
"esbuild": "^0.25.0",
90+
"del-cli": "^7.0.0",
91+
"esbuild": "^0.27.3",
9592
"eslint": "^9.30.1",
96-
"eslint-config-prettier": "^10.1.5",
9793
"eslint-config-webpack": "^4.4.1",
98-
"eslint-plugin-import": "^2.32.0",
99-
"eslint-plugin-jest": "^29.0.1",
100-
"eslint-plugin-jsdoc": "^52.0.0",
101-
"eslint-plugin-n": "^17.21.0",
102-
"eslint-plugin-prettier": "^5.5.3",
103-
"eslint-plugin-unicorn": "^60.0.0",
104-
"globals": "^16.3.0",
10594
"husky": "^9.1.4",
10695
"jest": "^30.0.5",
10796
"lightningcss": "^1.25.1",
108-
"lint-staged": "^15.2.8",
97+
"lint-staged": "^16.3.1",
10998
"memfs": "^4.11.1",
11099
"mini-css-extract-plugin": "^2.9.0",
111100
"npm-run-all": "^4.1.5",
@@ -141,6 +130,6 @@
141130
}
142131
},
143132
"engines": {
144-
"node": ">= 18.12.0"
133+
"node": ">= 20.9.0"
145134
}
146135
}

src/index.js

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ const {
2929
/** @typedef {import("postcss").Stringifier} Stringifier */
3030
/** @typedef {import("@jridgewell/trace-mapping").TraceMap} TraceMap */
3131

32+
// eslint-disable-next-line jsdoc/reject-any-type
33+
/** @typedef {any} EXPECTED_ANY */
34+
3235
/**
3336
* @typedef {Record<string, unknown>} CssNanoOptions
3437
* @property {string=} configFile Configuration file path
@@ -58,8 +61,8 @@ const {
5861
* @typedef {object} MinimizedResult
5962
* @property {string} code Minimized code
6063
* @property {RawSourceMap=} map Source map
61-
* @property {Array<Error | ErrorObject| string>=} errors Errors
62-
* @property {Array<Warning | WarningObject | string>=} warnings Warnings
64+
* @property {(Error | ErrorObject | string)[]=} errors Errors
65+
* @property {(Warning | WarningObject | string)[]=} warnings Warnings
6366
*/
6467

6568
/**
@@ -77,7 +80,7 @@ const {
7780

7881
/**
7982
* @template T
80-
* @typedef {T extends any[] ? { [P in keyof T]?: InferDefaultType<T[P]> } : InferDefaultType<T>} MinimizerOptions
83+
* @typedef {T extends EXPECTED_ANY[] ? { [P in keyof T]?: InferDefaultType<T[P]> } : InferDefaultType<T>} MinimizerOptions
8184
*/
8285

8386
/**
@@ -96,7 +99,7 @@ const {
9699

97100
/**
98101
* @template T
99-
* @typedef {T extends any[] ? { [P in keyof T]: BasicMinimizerImplementation<T[P]> & MinimizeFunctionHelpers; } : BasicMinimizerImplementation<T> & MinimizeFunctionHelpers} MinimizerImplementation
102+
* @typedef {T extends EXPECTED_ANY[] ? { [P in keyof T]: BasicMinimizerImplementation<T[P]> & MinimizeFunctionHelpers } : BasicMinimizerImplementation<T> & MinimizeFunctionHelpers} MinimizerImplementation
100103
*/
101104

102105
/**
@@ -110,9 +113,9 @@ const {
110113

111114
/**
112115
* @typedef InternalResult
113-
* @property {Array<{ code: string, map: RawSourceMap | undefined }>} outputs - Outputs
114-
* @property {Array<Warning | WarningObject | string>} warnings - Warnings
115-
* @property {Array<Error | ErrorObject | string>} errors - Errors
116+
* @property {{ code: string, map: RawSourceMap | undefined }[]} outputs - Outputs
117+
* @property {(Warning | WarningObject | string)[]} warnings - Warnings
118+
* @property {(Error | ErrorObject | string)[]} errors - Errors
116119
*/
117120

118121
/** @typedef {undefined | boolean | number} Parallel */
@@ -137,7 +140,7 @@ const {
137140
*/
138141

139142
/**
140-
* @typedef {ProcessOptions | { from?: string, to?: string, parser?: string | Syntax | Parser, stringifier?: string | Syntax | Stringifier, syntax?: string | Syntax } } ProcessOptionsExtender
143+
* @typedef {ProcessOptions | { from?: string, to?: string, parser?: string | Syntax | Parser, stringifier?: string | Syntax | Stringifier, syntax?: string | Syntax }} ProcessOptionsExtender
141144
*/
142145

143146
/**
@@ -209,13 +212,13 @@ class CssMinimizerPlugin {
209212
// https://github.com/mozilla/source-map#new-sourcemapconsumerrawsourcemap
210213
return Boolean(
211214
input &&
212-
typeof input === "object" &&
213-
input !== null &&
214-
"version" in input &&
215-
"sources" in input &&
216-
Array.isArray(input.sources) &&
217-
"mappings" in input &&
218-
typeof input.mappings === "string",
215+
typeof input === "object" &&
216+
input !== null &&
217+
"version" in input &&
218+
"sources" in input &&
219+
Array.isArray(input.sources) &&
220+
"mappings" in input &&
221+
typeof input.mappings === "string",
219222
);
220223
}
221224

@@ -391,10 +394,8 @@ class CssMinimizerPlugin {
391394
// https://github.com/nodejs/node/issues/19022
392395

393396
const cpus =
394-
// eslint-disable-next-line n/no-unsupported-features/node-builtins
395397
typeof os.availableParallelism === "function"
396-
? // eslint-disable-next-line n/no-unsupported-features/node-builtins
397-
{ length: os.availableParallelism() }
398+
? { length: os.availableParallelism() }
398399
: os.cpus() || { length: 1 };
399400

400401
return parallel === true || typeof parallel === "undefined"
@@ -419,7 +420,7 @@ class CssMinimizerPlugin {
419420
* @param {Compiler} compiler Compiler
420421
* @param {Compilation} compilation Compilation
421422
* @param {Record<string, import("webpack").sources.Source>} assets Assets
422-
* @param {{availableNumberOfCores: number}} optimizeOptions Optimize options
423+
* @param {{ availableNumberOfCores: number }} optimizeOptions Optimize options
423424
* @returns {Promise<void>} Promise
424425
*/
425426
async optimize(compiler, compilation, assets, optimizeOptions) {

src/utils.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/** @typedef {import("./index.js").RawSourceMap} RawSourceMap */
33
/** @typedef {import("./index.js").MinimizedResult} MinimizedResult */
44
/** @typedef {import("./index.js").CustomOptions} CustomOptions */
5+
/** @typedef {import("./index.js").EXPECTED_ANY} EXPECTED_ANY */
56
/** @typedef {import("postcss").ProcessOptions} ProcessOptions */
67
/** @typedef {import("postcss").Postcss} Postcss */
78

@@ -88,7 +89,7 @@ async function cssnanoMinify(
8889
}
8990

9091
if (
91-
/** @type {Error & {code: string}} */
92+
/** @type {Error & { code: string }} */
9293
(err).code === "ERR_REQUIRE_ESM" &&
9394
importESM
9495
) {
@@ -119,6 +120,7 @@ async function cssnanoMinify(
119120
`Loading PostCSS "${postcssOptions.parser}" parser failed: ${
120121
/** @type {Error} */ (error).message
121122
}\n\n(@${name})`,
123+
{ cause: error },
122124
);
123125
}
124126
}
@@ -131,6 +133,7 @@ async function cssnanoMinify(
131133
`Loading PostCSS "${postcssOptions.stringifier}" stringifier failed: ${
132134
/** @type {Error} */ (error).message
133135
}\n\n(@${name})`,
136+
{ cause: error },
134137
);
135138
}
136139
}
@@ -143,6 +146,7 @@ async function cssnanoMinify(
143146
`Loading PostCSS "${postcssOptions.syntax}" syntax failed: ${
144147
/** @type {Error} */ (error).message
145148
}\n\n(@${name})`,
149+
{ cause: error },
146150
);
147151
}
148152
}
@@ -224,8 +228,7 @@ async function cleanCssMinify(input, sourceMap, minimizerOptions) {
224228

225229
const generatedSourceMap = result.sourceMap
226230
? /** @type {RawSourceMap} */ (
227-
// eslint-disable-next-line jsdoc/no-restricted-syntax
228-
/** @type {any} */ (result.sourceMap).toJSON()
231+
/** @type {EXPECTED_ANY} */ (result.sourceMap).toJSON()
229232
)
230233
: undefined;
231234

@@ -349,10 +352,10 @@ esbuildMinify.supportsWorkerThreads = () => false;
349352
*/
350353
async function parcelCssMinify(input, sourceMap, minimizerOptions) {
351354
const [[filename, code]] = Object.entries(input);
352-
// eslint-disable-next-line jsdoc/no-restricted-syntax
355+
353356
/**
354-
* @param {Partial<import("@parcel/css").TransformOptions<any>>=} parcelCssOptions Parcel CSS options
355-
* @returns {import("@parcel/css").TransformOptions<any>} Built Parcel CSS options
357+
* @param {Partial<import("@parcel/css").TransformOptions<EXPECTED_ANY>>=} parcelCssOptions Parcel CSS options
358+
* @returns {import("@parcel/css").TransformOptions<EXPECTED_ANY>} Built Parcel CSS options
356359
*/
357360
const buildParcelCssOptions = (parcelCssOptions = {}) =>
358361
// Need deep copy objects to avoid https://github.com/terser/terser/issues/366
@@ -394,10 +397,10 @@ parcelCssMinify.supportsWorkerThreads = () => false;
394397
*/
395398
async function lightningCssMinify(input, sourceMap, minimizerOptions) {
396399
const [[filename, code]] = Object.entries(input);
397-
// eslint-disable-next-line jsdoc/no-restricted-syntax
400+
398401
/**
399-
* @param {Partial<import("lightningcss").TransformOptions<any>>=} lightningCssOptions Lightning CSS options
400-
* @returns {import("lightningcss").TransformOptions<any>} Built Lightning CSS options
402+
* @param {Partial<import("lightningcss").TransformOptions<EXPECTED_ANY>>=} lightningCssOptions Lightning CSS options
403+
* @returns {import("lightningcss").TransformOptions<EXPECTED_ANY>} Built Lightning CSS options
401404
*/
402405
const buildLightningCssOptions = (lightningCssOptions = {}) =>
403406
// Need deep copy objects to avoid https://github.com/terser/terser/issues/366
@@ -470,11 +473,10 @@ async function swcMinify(input, sourceMap, minimizerOptions) {
470473
? result.errors.map((diagnostic) => {
471474
const error = new Error(diagnostic.message);
472475

473-
// eslint-disable-next-line jsdoc/no-restricted-syntax
474-
/** @type {any} */ (error).span = diagnostic.span;
475-
476-
// eslint-disable-next-line jsdoc/no-restricted-syntax
477-
/** @type {any} */ (error).level = diagnostic.level;
476+
/** @type {EXPECTED_ANY} */
477+
(error).span = diagnostic.span;
478+
/** @type {EXPECTED_ANY} */
479+
(error).level = diagnostic.level;
478480

479481
return error;
480482
})

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`"cache" option should work with the "false" value for the "cache" option: assets 1`] = `
44
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`exclude option should match snapshot for a single RegExp value excluded1: assets 1`] = `
44
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`include option should match snapshot for a single RegExp value included1: assets 1`] = `
44
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`when applied with "minimizerOptions" option matches snapshot for "discardComments" option (disable): entry.css 1`] = `
44
"body{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`when applied with "test" option matches snapshot for a single "test" value (RegExp): assets 1`] = `
44
{

0 commit comments

Comments
 (0)