swc-project / plugins

Plugins for swc, written in rust
Apache License 2.0
334 stars 55 forks source link

fix(emotion): Strip backslashed segments for Windows path #328

Closed iryan2 closed 4 months ago

iryan2 commented 4 months ago

Currently, when @swc/plugin-emotion is used on Windows, it produces invalid CSS class names. Apparently this is an unsolved issue for Rust. In this PR I've updated the calculation of the [filename] labelFormat such that it handles both the Windows path, which includes the full path to the file, including backslashes, and the Unix path (which was working fine to begin with).

I have set up a minimal repo for reproducing the issue and verifying the fix. The issue can be reproduced on the main branch, and the fix can be verified on the fix branch. The fix branch replaces the compiled swc_plugin_emotion.wasm from @swc/plugin-emotion npm package with one I built myself via my fork of this repo.

Before

Screenshot 2024-07-03 at 4 22 41 PM

After

Screenshot 2024-07-04 at 7 07 42 AM

Fixes #327

changeset-bot[bot] commented 4 months ago

🦋 Changeset detected

Latest commit: b1d2e0f7df8a97a8545fa9dbbd1538d79e6f9f02

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ------------------- | ----- | | @swc/plugin-emotion | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

CLAassistant commented 4 months ago

CLA assistant check
All committers have signed the CLA.