linkedin / css-blocks

High performance, maintainable stylesheets.
http://css-blocks.com/
BSD 2-Clause "Simplified" License
6.33k stars 152 forks source link

BEM_UNIQUE degrades dev-time build performance #357

Closed chriseppstein closed 4 years ago

chriseppstein commented 4 years ago

The BEM_UNIQUE output mode purposely changes the class names associated with a block file across process restarts. The motivation behind this was to prevent people from targeting elements with those classnames with selectors that are not from a CSS Blocks file.

Unfortunately, this means that build results cannot be reliably cached across process restarts which degrades the start up time for builds. In large ember applications, this will force every handlebars template to be recompiled with every build watcher restart because there's no API to invalidate the cache of only those templates that have been ported to CSS Blocks.

Instead of randomizing per process, I propose that we randomize based on some value that changes frequently at scale but is stable from a single developer's perspective. Because caches are not portable across machines, this means that we can reliably cache build results.

Some ideas for what to use for caching: