Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support CSS Modules #20

Closed
nvh95 opened this issue Apr 5, 2022 · 1 comment · Fixed by #40
Closed

Support CSS Modules #20

nvh95 opened this issue Apr 5, 2022 · 1 comment · Fixed by #40
Labels
feature request Request a new feature help wanted Extra attention is needed

Comments

@nvh95
Copy link
Owner

nvh95 commented Apr 5, 2022

Why

  • jest-preview currently doesn't support CSS Modules, and given the popularity of CSS Modules, jest-preview should support it out of the box.

How

  • Not sure how to implement this feature, we may need to explore how CSS Modules works and mimic the behaviors. One possible solution is through a transform
  • How create react app currently handle CSS Modules in jest:
    • They use identity-obj-proxy which transform imported className to string
import { sidebar } from './style.module.css' // => sidebar === 'sidebar'

<div className={sidebar} ></div> // => <div class="sidebar" ></div>

Reference:
https://github.com/facebook/create-react-app/blob/63bba07d584a769cfaf7699e0aab92ed99c3c57e/packages/react-scripts/scripts/utils/createJestConfig.js#L58

When

  • 0.1.x/ 0.2.x
@nvh95 nvh95 added feature request Request a new feature help wanted Extra attention is needed labels Apr 5, 2022
@nvh95
Copy link
Owner Author

nvh95 commented Apr 6, 2022

@nvh95 nvh95 linked a pull request Apr 9, 2022 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Request a new feature help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant