Skip to content

CSS Modules doesn't error on missing composes #16075

@privatenumber

Description

@privatenumber

Describe the bug

When composing a class from another file in CSS Modules, an error is not emitted if the class is not found.

This is akin to not erroring when trying to import a missing export from another JS file, and can lead to bugs.

This is fixed by #16018, but wanted to file it for tracking purposes since this seems like a pretty major issue that wasn't reported.

(Originally reported in privatenumber/vite-css-modules#2)

Reproduction

https://stackblitz.com/edit/vitejs-vite-w9i5ct?file=src%2Fstyle.module.css

Steps to reproduce

  1. In style.modules.css, observe that large-text is imported from ./utils.module.css
  2. In utils.module.css, observe that it's an empty file
  3. In the DOM, observe that undefined is passed in as a class:
    Screenshot 2024-03-02 at 5 09 02 PM

System Info

N/A

Used Package Manager

npm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions