lightningcss
lightningcss copied to clipboard
Match CSS modules hashing with PostCSS
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.
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?
For example, to use with https://github.com/VKCOM/swc-plugin-css-modules
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