Skip to content

Report files read through composes and @value as dependencies - #174

Merged
madyankin merged 1 commit into
madyankin:masterfrom
mkantautas:fix/report-composed-dependencies
Nov 14, 2026
Merged

madyankin merged 1 commit into
madyankin:masterfrom
mkantautas:fix/report-composed-dependencies

Conversation

@mkantautas

Copy link
Copy Markdown
Contributor

Fixes #150 (also reported in #81).

Why

postcss-modules reads the files named in composes: ... from "./x.css" and @value ... from "./x.css", but it does not report them in the PostCSS result. Runners that rebuild from PostCSS dependency messages (plugin guidelines, 3.1), such as postcss --watch, then leave the importing files stale when a composed file changes: their output keeps the old class names and rules.

Change

FileSystemLoader exposes the files it read, including nested imports, as dependencies, in the order their CSS is prepended. The plugin adds a dependency message for each one, with the processed file (result.opts.from, or the root's source file when from is not set) as parent. A custom Loader without a dependencies getter reports nothing, as before.

The exposes export tokens for other plugins test now snapshots only the export message: values.css imports a file, and the new message carries an absolute path.

Testing

  • New tests: composes.css reports composes.mixins.css and the nested composes.a.css, values.css reports values.colors.css, and classes.css reports nothing; a root parsed from one path and processed with another from reports the processing path as parent. Both fail on master (7bfccb6) and pass here.
  • make test (eslint, swc, jest: 44 tests, 31 snapshots) passes on Node 22.23.4 and 24.22.1 on Linux and on Node 26.8.2 on macOS. Windows not run.
  • postcss-cli 11.0.1 in --watch mode on a drawer.module.css with @value treeWrap from "./tree.module.css" and composes: treeBase from "./tree.module.css": after editing tree.module.css, master does not rebuild the output, which keeps ._treeWrap_17egg_2 in red; with this change the output is rebuilt with ._treeWrap_g8ssb_2 in blue.

@madyankin
madyankin force-pushed the fix/report-composed-dependencies branch from add6faa to 20fc4d8 Compare November 14, 2026 20:36
@madyankin
madyankin force-pushed the fix/report-composed-dependencies branch from 20fc4d8 to 5d5b789 Compare November 14, 2026 20:39
@madyankin
madyankin merged commit 6513405 into madyankin:master Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Classes imported from another module have the wrong hash when imported file is changed

2 participants