Skip to content

Commit 8dd0315

Browse files
authored
chore!: minimum supported Node.js version is 18.12.0 (#677)
1 parent 754c4a5 commit 8dd0315

19 files changed

+1991
-1354
lines changed

.github/workflows/nodejs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
strategy:
6161
matrix:
6262
os: [ubuntu-latest, windows-latest, macos-latest]
63-
node-version: [14.x, 16.x, 18.x, 20.x]
63+
node-version: [18.x, 20.x, 21.x]
6464
webpack-version: [latest]
6565

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

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ npm-debug.log
44
yarn-error.log
55
npm-debug.log*
66
.eslintcache
7+
.cspellcache
78

89
dmd
910
jest

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ const postcssCustomPlugin = (opts = {}) => {
11391139
postcssPlugin: "postcss-custom-plugin",
11401140
Once: (root, { result }) => {
11411141
opts.loaderContext.addDependency(
1142-
path.resolve(__dirname, "path", "to", "file")
1142+
path.resolve(__dirname, "path", "to", "file"),
11431143
);
11441144
},
11451145
};

babel.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = (api) => {
1010
"@babel/preset-env",
1111
{
1212
targets: {
13-
node: "14.15.0",
13+
node: "18.12.0",
1414
},
1515
},
1616
],

jest.config.js

+2
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ module.exports = {
44
"\\.[mc]?tsx?$": ["ts-jest", { rootDir: ".", esModuleInterop: true }],
55
"\\.[mc]?jsx?$": "babel-jest",
66
},
7+
// ignore node_modules except for strip-ansi and ansi-regex
8+
transformIgnorePatterns: ["node_modules/(?!strip-ansi|ansi-regex)"],
79
};

lint-staged.config.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
module.exports = {
2-
"*": ["prettier --write --ignore-unknown", "cspell --no-must-find-files"],
2+
"*": [
3+
"prettier --cache --write --ignore-unknown",
4+
"cspell --cache --no-must-find-files",
5+
],
36
"*.js": ["eslint --cache --fix"],
47
};

package-lock.json

+1,846-1,216
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+25-25
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"main": "dist/cjs.js",
1515
"engines": {
16-
"node": ">= 14.15.0"
16+
"node": ">= 18.12.0"
1717
},
1818
"scripts": {
1919
"start": "npm run build -- -w",
@@ -22,9 +22,9 @@
2222
"build": "cross-env NODE_ENV=production babel src -d dist --copy-files",
2323
"commitlint": "commitlint --from=master",
2424
"security": "npm audit --production",
25-
"lint:prettier": "prettier \"{**/*,*}.{js,json,md,yml,css,ts}\" --list-different",
25+
"lint:prettier": "prettier --cache --list-different .",
2626
"lint:js": "eslint --cache .",
27-
"lint:spelling": "cspell \"**/*.*\"",
27+
"lint:spelling": "cspell --cache --no-must-find-files --quiet \"**/*.*\"",
2828
"lint": "npm-run-all -l -p \"lint:**\"",
2929
"fix:js": "npm run lint:js -- --fix",
3030
"fix:prettier": "npm run lint:prettier -- --write",
@@ -45,46 +45,46 @@
4545
"webpack": "^5.0.0"
4646
},
4747
"dependencies": {
48-
"cosmiconfig": "^8.3.5",
48+
"cosmiconfig": "^9.0.0",
4949
"jiti": "^1.20.0",
5050
"semver": "^7.5.4"
5151
},
5252
"devDependencies": {
5353
"@babel/cli": "^7.23.0",
54-
"@babel/core": "^7.23.0",
55-
"@babel/preset-env": "^7.22.20",
56-
"@commitlint/cli": "^17.7.2",
57-
"@commitlint/config-conventional": "^17.7.0",
54+
"@babel/core": "^7.23.7",
55+
"@babel/preset-env": "^7.23.8",
56+
"@commitlint/cli": "^18.4.4",
57+
"@commitlint/config-conventional": "^18.4.4",
5858
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
5959
"babel-jest": "^29.7.0",
6060
"cross-env": "^7.0.3",
61-
"cspell": "^6.31.2",
62-
"cssnano": "^6.0.0",
63-
"del": "^6.1.1",
61+
"cspell": "^8.3.2",
62+
"cssnano": "^6.0.3",
63+
"del": "^7.1.0",
6464
"del-cli": "^5.1.0",
65-
"eslint": "^8.50.0",
66-
"eslint-config-prettier": "^8.9.0",
67-
"eslint-plugin-import": "^2.28.1",
65+
"eslint": "^8.56.0",
66+
"eslint-config-prettier": "^9.1.0",
67+
"eslint-plugin-import": "^2.29.1",
6868
"husky": "^8.0.3",
6969
"jest": "^29.7.0",
7070
"less": "^4.2.0",
71-
"less-loader": "^11.1.0",
72-
"lint-staged": "^13.2.3",
73-
"memfs": "^3.4.13",
71+
"less-loader": "^12.0.0",
72+
"lint-staged": "^15.2.0",
73+
"memfs": "^4.6.0",
7474
"midas": "^2.0.3",
7575
"npm-run-all": "^4.1.5",
76-
"postcss": "^8.4.29",
77-
"postcss-dark-theme-class": "^0.7.3",
78-
"postcss-import": "^15.1.0",
76+
"postcss": "^8.4.33",
77+
"postcss-dark-theme-class": "^1.1.0",
78+
"postcss-import": "^16.0.0",
7979
"postcss-js": "^4.0.1",
80-
"postcss-load-config": "^4.0.1",
80+
"postcss-load-config": "^5.0.2",
8181
"postcss-nested": "^6.0.1",
8282
"postcss-short": "^5.0.0",
83-
"prettier": "^2.8.7",
84-
"sass": "^1.69.0",
85-
"sass-loader": "^13.2.2",
83+
"prettier": "^3.2.2",
84+
"sass": "^1.69.7",
85+
"sass-loader": "^14.0.0",
8686
"standard-version": "^9.3.2",
87-
"strip-ansi": "^6.0.0",
87+
"strip-ansi": "^7.1.0",
8888
"sugarss": "^4.0.1",
8989
"ts-jest": "^29.1.0",
9090
"ts-node": "^10.9.1",

src/index.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ export default async function loader(content, sourceMap, meta) {
5252
if (!implementation) {
5353
callback(
5454
new Error(
55-
`The Postcss implementation "${options.implementation}" not found`
56-
)
55+
`The Postcss implementation "${options.implementation}" not found`,
56+
),
5757
);
5858

5959
return;
@@ -66,7 +66,7 @@ export default async function loader(content, sourceMap, meta) {
6666
loadedConfig = await loadConfig(
6767
this,
6868
configOption,
69-
options.postcssOptions
69+
options.postcssOptions,
7070
);
7171
} catch (error) {
7272
callback(error);
@@ -78,7 +78,7 @@ export default async function loader(content, sourceMap, meta) {
7878
const { plugins, processOptions } = await getPostcssOptions(
7979
this,
8080
loadedConfig,
81-
options.postcssOptions
81+
options.postcssOptions,
8282
);
8383

8484
const useSourceMap =
@@ -137,7 +137,7 @@ export default async function loader(content, sourceMap, meta) {
137137
// is used to make the condition body run once.
138138
const packageJSONDir = findPackageJSONDir(
139139
process.cwd(),
140-
this.fs.statSync
140+
this.fs.statSync,
141141
);
142142

143143
if (packageJSONDir) {
@@ -146,7 +146,7 @@ export default async function loader(content, sourceMap, meta) {
146146
try {
147147
bufferOfPackageJSON = this.fs.readFileSync(
148148
path.resolve(packageJSONDir, "package.json"),
149-
"utf8"
149+
"utf8",
150150
);
151151
} catch (_error) {
152152
// Nothing
@@ -168,8 +168,8 @@ export default async function loader(content, sourceMap, meta) {
168168
this.emitWarning(
169169
new Error(
170170
"Add postcss as project dependency. postcss is not a peer dependency for postcss-loader. " +
171-
"Use `npm install postcss` or `yarn add postcss`"
172-
)
171+
"Use `npm install postcss` or `yarn add postcss`",
172+
),
173173
);
174174
} else {
175175
hasExplicitDependencyOnPostCSS = true;
@@ -212,7 +212,7 @@ export default async function loader(content, sourceMap, meta) {
212212
message.file,
213213
message.content,
214214
message.sourceMap,
215-
message.info
215+
message.info,
216216
);
217217
}
218218
}

src/utils.js

+14-13
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ async function loadConfig(loaderContext, config, postcssOptions) {
147147
loaders[".ts"] = tsLoader;
148148

149149
const explorer = cosmiconfig(moduleName, {
150+
searchStrategy: "global",
150151
searchPlaces,
151152
loaders,
152153
});
@@ -207,7 +208,7 @@ function loadPlugin(plugin, options, file) {
207208
return loadedPlugin(options);
208209
} catch (error) {
209210
throw new Error(
210-
`Loading PostCSS "${plugin}" plugin failed: ${error.message}\n\n(@${file})`
211+
`Loading PostCSS "${plugin}" plugin failed: ${error.message}\n\n(@${file})`,
211212
);
212213
}
213214
}
@@ -294,7 +295,7 @@ async function tryRequireThenImport(module) {
294295
async function getPostcssOptions(
295296
loaderContext,
296297
loadedConfig = {},
297-
postcssOptions = {}
298+
postcssOptions = {},
298299
) {
299300
const file = loaderContext.resourcePath;
300301

@@ -333,14 +334,14 @@ async function getPostcssOptions(
333334
if (processOptionsFromConfig.from) {
334335
processOptionsFromConfig.from = path.resolve(
335336
path.dirname(loadedConfig.filepath),
336-
processOptionsFromConfig.from
337+
processOptionsFromConfig.from,
337338
);
338339
}
339340

340341
if (processOptionsFromConfig.to) {
341342
processOptionsFromConfig.to = path.resolve(
342343
path.dirname(loadedConfig.filepath),
343-
processOptionsFromConfig.to
344+
processOptionsFromConfig.to,
344345
);
345346
}
346347

@@ -349,14 +350,14 @@ async function getPostcssOptions(
349350
if (processOptionsFromOptions.from) {
350351
processOptionsFromOptions.from = path.resolve(
351352
loaderContext.rootContext,
352-
processOptionsFromOptions.from
353+
processOptionsFromOptions.from,
353354
);
354355
}
355356

356357
if (processOptionsFromOptions.to) {
357358
processOptionsFromOptions.to = path.resolve(
358359
loaderContext.rootContext,
359-
processOptionsFromOptions.to
360+
processOptionsFromOptions.to,
360361
);
361362
}
362363

@@ -382,22 +383,22 @@ async function getPostcssOptions(
382383
} catch (error) {
383384
loaderContext.emitError(
384385
new Error(
385-
`Loading PostCSS "${processOptions.parser}" parser failed: ${error.message}\n\n(@${file})`
386-
)
386+
`Loading PostCSS "${processOptions.parser}" parser failed: ${error.message}\n\n(@${file})`,
387+
),
387388
);
388389
}
389390
}
390391

391392
if (typeof processOptions.stringifier === "string") {
392393
try {
393394
processOptions.stringifier = await tryRequireThenImport(
394-
processOptions.stringifier
395+
processOptions.stringifier,
395396
);
396397
} catch (error) {
397398
loaderContext.emitError(
398399
new Error(
399-
`Loading PostCSS "${processOptions.stringifier}" stringifier failed: ${error.message}\n\n(@${file})`
400-
)
400+
`Loading PostCSS "${processOptions.stringifier}" stringifier failed: ${error.message}\n\n(@${file})`,
401+
),
401402
);
402403
}
403404
}
@@ -408,8 +409,8 @@ async function getPostcssOptions(
408409
} catch (error) {
409410
loaderContext.emitError(
410411
new Error(
411-
`Loading PostCSS "${processOptions.syntax}" syntax failed: ${error.message}\n\n(@${file})`
412-
)
412+
`Loading PostCSS "${processOptions.syntax}" syntax failed: ${error.message}\n\n(@${file})`,
413+
),
413414
);
414415
}
415416
}

test/__snapshots__/postcssOptions.test.js.snap

+4-4
Original file line numberDiff line numberDiff line change
@@ -448,19 +448,19 @@ exports[`"postcssOptions" option should work with the "config" options and use p
448448
}
449449
450450
@media (prefers-color-scheme: dark) {
451-
:root:not(.is-light) { /* :root is <html> for HTML documents */
451+
:root:where(:not(.is-light)) { /* :root is <html> for HTML documents */
452452
--text-color: white
453453
}
454-
html:not(.is-light) body {
454+
:where(html:not(.is-light)) body {
455455
background: black
456456
}
457457
}
458458
459-
:root.is-dark { /* :root is <html> for HTML documents */
459+
:root:where(.is-dark) { /* :root is <html> for HTML documents */
460460
--text-color: white
461461
}
462462
463-
html.is-dark body {
463+
:where(html.is-dark) body {
464464
background: black
465465
}"
466466
`;

0 commit comments

Comments
 (0)