-
-
Notifications
You must be signed in to change notification settings - Fork 79
fix: map autoProcessPaths values to platform path #920
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
Conversation
On Windows, setting the autoProcessPaths react-native-unstyles/plugin config does not work, meaning importing 3rd party component libraries that use react-native-unistyles are not transformed. This is a fix for that, using the already built-in `toPlatformPath` function to ensure windows paths are converted correctly (i.e use backslashes instead of forward slashes).
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe change updates the sequence of operations used to determine if a file should be processed with the Changes
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🧰 Additional context used🧬 Code Graph Analysis (2)plugin/index.js (2)
plugin/src/index.ts (1)
🔇 Additional comments (2)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Great catch! Thank you for the PR |
On Windows, setting the autoProcessPaths react-native-unstyles/plugin config does not work, meaning importing 3rd party component libraries that use react-native-unistyles are not transformed. This is a fix for that, using the already built-in
toPlatformPath
function to ensure windows paths are converted correctly (i.e use backslashes instead of forward slashes).Summary
While trying to install an npm package I made that uses Unistyles under the hood to style components, I noticed the components were not properly being transform when they implemented a StyleSheet. As you would expect, files in the
node_modules
were not by default being transformed - but the documentation specifies a workaround for this: https://www.unistyl.es/v3/other/babel-plugin#autoprocesspaths.The problem was, I could not get it working. So I looked at the plugin code, and noticed that while I was defining my paths as
@somepackage/components
, the plugin'sstate.filename
was in this format:C:\someproject\node_modules\@somepackage\components
. The plugin already had a utility function (toPlatformPath
) that converted the paths in theREPLACE_WITH_UNISTYLES_PATHS
to support Windows paths, but this was not applied to theautoProcessPaths
values.This PR simply ensures both the
REPLACE_WITH_UNISTYLES_PATHS
andautoProcessPaths
are converted to the correct format on Windows.Just an aside, I really love Unistyles! Thank you for such a wonderful project.
Summary by CodeRabbit