postcss-modules 9.1.3 → 9.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 9.1.4
4
+
5
+ ### Fixed
6
+
7
+ - Use synchronous Node module hooks where available so the CSS loader runs without the Node 26 `module.register` deprecation warning, while retaining support for Node 20.6.
8
+
9
+ ### Internal
10
+
11
+ - Update vulnerable and outdated development dependencies, and use Node 26 for the default Docker build.
12
+
3
13
  ## 9.1.3
4
14
 
5
15
  ### Fixed
package/README.md CHANGED
@@ -185,7 +185,7 @@ declare module "*.css" {
185
185
  - **ESM only.** `require("./x.css")` is not supported; the underlying transform is async and cannot be expressed through `require.extensions`. Use a `.mjs` entrypoint, or `"type": "module"` in `package.json`.
186
186
  - **Tokens only, no CSS output.** The loader returns the class-name map but does not emit the transformed CSS. SSR setups that need the stylesheet should use a bundler or call `postcss([require("postcss-modules")(...)]).process(...)` directly to capture both.
187
187
  - **No HMR, no watch mode** — by design. Use a bundler for those.
188
- - **Node ≥ 20.6.** `module.register` stabilized there.
188
+ - **Node ≥ 20.6.** The loader uses `module.registerHooks` where available and falls back to `module.register` on older Node releases.
189
189
 
190
190
  ### Generating scoped names
191
191
 
package/build/loader.mjs CHANGED
@@ -1,3 +1,8 @@
1
- import { register } from "node:module";
1
+ import * as nodeModule from "node:module";
2
+ import { load } from "./loaderHooksSync.mjs";
2
3
 
3
- register("./loaderHooks.mjs", import.meta.url);
4
+ if (typeof nodeModule.registerHooks === "function") {
5
+ nodeModule.registerHooks({ load });
6
+ } else {
7
+ nodeModule.register("./loaderHooks.mjs", import.meta.url);
8
+ }
@@ -1,22 +1,10 @@
1
- import { readFile } from "node:fs/promises";
2
- import { fileURLToPath } from "node:url";
3
- import { processCSS } from "./processCSS.js";
4
- import { loadConfig } from "./loadConfig.mjs";
5
-
6
- let configPromise;
7
- function getConfig() {
8
- if (!configPromise) configPromise = loadConfig();
9
- return configPromise;
10
- }
1
+ import { loadCSS } from "./loaderRuntime.mjs";
11
2
 
12
3
  export async function load(url, context, nextLoad) {
13
4
  if (!url.startsWith("file:") || !url.endsWith(".css")) {
14
5
  return nextLoad(url, context);
15
6
  }
16
- const filename = fileURLToPath(url);
17
- const source = await readFile(filename, "utf8");
18
- const opts = await getConfig();
19
- const tokens = await processCSS(source, filename, opts);
7
+ const tokens = await loadCSS(url);
20
8
  return {
21
9
  format: "module",
22
10
  source: `export default ${JSON.stringify(tokens)};\n`,
@@ -0,0 +1,12 @@
1
+ const runtimeUrl = new URL("./loaderRuntime.mjs", import.meta.url).href;
2
+
3
+ export function load(url, context, nextLoad) {
4
+ if (!url.startsWith("file:") || !url.endsWith(".css")) {
5
+ return nextLoad(url, context);
6
+ }
7
+ return {
8
+ format: "module",
9
+ source: `import { loadCSS } from ${JSON.stringify(runtimeUrl)};\nexport default await loadCSS(${JSON.stringify(url)});\n`,
10
+ shortCircuit: true,
11
+ };
12
+ }
@@ -0,0 +1,17 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import { fileURLToPath } from "node:url";
3
+ import { processCSS } from "./processCSS.js";
4
+ import { loadConfig } from "./loadConfig.mjs";
5
+
6
+ let configPromise;
7
+ function getConfig() {
8
+ if (!configPromise) configPromise = loadConfig();
9
+ return configPromise;
10
+ }
11
+
12
+ export async function loadCSS(url) {
13
+ const filename = fileURLToPath(url);
14
+ const source = await readFile(filename, "utf8");
15
+ const opts = await getConfig();
16
+ return processCSS(source, filename, opts);
17
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postcss-modules",
3
- "version": "9.1.3",
3
+ "version": "9.1.4",
4
4
  "description": "PostCSS plugin to use CSS Modules everywhere",
5
5
  "main": "build/index.js",
6
6
  "types": "index.d.ts",
@@ -43,20 +43,20 @@
43
43
  "postcss": "^8.0.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@eslint/js": "^9.39.4",
46
+ "@eslint/js": "^9.39.5",
47
47
  "@swc/cli": "^0.8.1",
48
- "@swc/core": "^1.15.43",
48
+ "@swc/core": "^1.16.22",
49
49
  "@swc/jest": "^0.2.39",
50
- "autoprefixer": "^10.5.2",
51
- "eslint": "^9.39.0",
50
+ "autoprefixer": "^10.7.0",
51
+ "eslint": "^9.39.5",
52
52
  "eslint-plugin-import": "^2.32.0",
53
- "eslint-plugin-jest": "^29.15.4",
54
- "globals": "^17.7.0",
53
+ "eslint-plugin-jest": "^29.17.1",
54
+ "globals": "^17.14.0",
55
55
  "husky": "^9.1.7",
56
- "jest": "^30.4.2",
57
- "lint-staged": "^17.0.8",
56
+ "jest": "30.4.2",
57
+ "lint-staged": "^17.6.2",
58
58
  "postcss": "^8.5.16",
59
- "prettier": "^3.9.4"
59
+ "prettier": "^3.10.1"
60
60
  },
61
61
  "engines": {
62
62
  "node": ">=20.6"
@@ -66,8 +66,11 @@
66
66
  "prepare": "husky || true"
67
67
  },
68
68
  "overrides": {
69
- "glob": "^12.0.0",
70
- "file-type": "^22.0.0"
69
+ "glob": "^14.0.6",
70
+ "file-type": "^22.0.0",
71
+ "@swc/cli": {
72
+ "minimatch": "^11.0.9"
73
+ }
71
74
  },
72
75
  "lint-staged": {
73
76
  "*.{json,md}": [