Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

fix(styles-loader): hash css module classes from files in node_modules #613

Merged

Conversation

zacowan
Copy link
Member

@zacowan zacowan commented Feb 22, 2024

Description

  • Updates the logic in the prod bundler to hash class names from css modules located in node_modules.
  • Migrates the above production-specific logic into both the dev and the prod bundler.
  • Applies the same logic in the server bundler.

Motivation

There are two core issues here: deviation from the spec of css modules, and inconsistent behavior between the dev and prod bundler.

When a css file ends in .module.css, this is an indication from the writer of the css that the classes within it should definitely be hashed. In #124, a change was introduced (specifically in the production bundler) that caused any css files imported from within node_modules to not be hashed. Since this change makes no distinction between files ending in .css and .module.css, any css file (including css modules) will result in classes not being hashed.

Additionally, since #124 was introduced this change was not carried over into the dev bundler. This meant that your application would result in different classes depending on which bundler was being used.

Test Conditions

  • Added unit tests for ensuring classes from css modules are hashed

Types of changes

Check boxes that apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (adding or updating documentation)
  • Dependency update
  • Security update

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation and I have updated the documentation accordingly.
  • These changes should be applied to a maintenance branch.
  • I have added the Apache 2.0 license header to any new files created.

@zacowan zacowan marked this pull request as ready for review March 6, 2024 15:16
@zacowan zacowan requested review from a team as code owners March 6, 2024 15:16
@code-forger code-forger requested a review from a team March 7, 2024 07:21
@10xLaCroixDrinker 10xLaCroixDrinker merged commit 4c24846 into main Mar 7, 2024
5 checks passed
@10xLaCroixDrinker 10xLaCroixDrinker deleted the fix/scope-css-module-classes-from-node-modules branch March 7, 2024 12:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants