lightningcss icon indicating copy to clipboard operation
lightningcss copied to clipboard

Match CSS modules hashing with PostCSS

Open marvinhagemeister opened this issue 1 year ago • 3 comments

I'm currently exploring adding support for CSS Modules natively in Deno via lightningcss. In doing so I noticed that the hash segment is a different value then the one calculated by PostCSS. It seems like PostCSS is using a hex digest of the xxhash64 hash of the root relative file path compared to lightningcss which uses rust's default SipHash-1-3 algorithm.

To make native CSS Modules support in Deno useful, the hash value needs to match whatever users may be using to generate browser bundles with. Would folks be open to the idea to change the hashing function here to match the one from PostCSS? I'd be happy to make a PR for that.

marvinhagemeister avatar Nov 24 '23 11:11 marvinhagemeister

Why would the exact hash matter? Isn't the point of hashing css modules so that they contain an unpredictable value that won't conflict?

devongovett avatar Dec 28 '23 17:12 devongovett

For example, to use with https://github.com/VKCOM/swc-plugin-css-modules

SevereCloud avatar Mar 08 '24 16:03 SevereCloud

Rather than lightningcss changing the internal hash function, it might be better to allow customizing the hash, so that Deno can do it in userland.

See #491 and #503

mayank99 avatar Mar 28 '24 17:03 mayank99