wp-build: Salt data-wp-hash to prevent cross-pipeline CSS module collisions#76743
wp-build: Salt data-wp-hash to prevent cross-pipeline CSS module collisions#76743
data-wp-hash to prevent cross-pipeline CSS module collisions#76743Conversation
|
Size Change: +2 B (0%) Total Size: 7.66 MB
ℹ️ View Unchanged
|
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Flaky tests detected in bc51e9f. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/23367578746
|
Description
Closes #76738
Salt the
data-wp-hashvalue with a build-tool identifier ('@wordpress/wp-build') so that different build pipelines never produce the same hash for the same CSS source file.Why?
@wordpress/wp-builddeduplicates injected<style>tags using adata-wp-hashattribute derived fromSHA1(rawCSS). Since the hash is computed from the raw (untransformed) CSS, two independent build pipelines processing the same.module.csssource will produce the same hash but different CSS module class names. Whichever bundle loads first wins the dedup check, and the other bundle's class names silently have no matching styles.This is uncommon today, but will become more likely as
@wordpress/uiadoption grows and consumers build the same simple source files with different CSS module tools.How?
Prepend the string
'@wordpress/wp-build'to the hash input. Within a single pipeline, all bundles still use the same salt and dedupe as before. Across pipelines, the salt differs, so each pipeline injects its own styles independently.Testing Instructions
This is a build-time change with no runtime UI to test. To verify the hash output changed:
.module.cssfile in a package that uses@wordpress/wp-builddata-wp-hashvalue in the generated JS module is differentUse of AI Tools
Authored with Cursor (Claude).