How to customize parcel config?

Hi everyone, I am trying to use a react-native based library called react-native-reanimated. This library has some components that are also supported for the web, and they write 2 files, for example a measure component will have measure.tsx and measure.web.tsx file. When I use this library in a nextJS project, it bundles the correct file for web, which is measure.web.tsx, however with plasmo, it seems like it only bundles the files with extensions .ts or .js etc..., and skips the equivalent .web.* file. How do I make parcel make the files that end in .web.* take precendence over .js|ts(x) files?
9 Replies
Arcane
Arcane•9mo ago
@LoXatoR has reached level 1. GG!
LoXatoR
LoXatoROP•9mo ago
This one has code specific for react-native, and doesn't work on the web but the web file is not bundled
No description
LoXatoR
LoXatoROP•9mo ago
In the nextJS app you can see that it bundles the .web.js file
No description
LoXatoR
LoXatoROP•9mo ago
any idea bout this @lab ?
lab
lab•8mo ago
We recently merged a thing for this: https://github.com/PlasmoHQ/plasmo/pull/890
GitHub
feat: Support custom .parcelrc config by mathieudutour · Pull Reque...
Details This PR introduces support for a custom .parcelrc at the root of the project. It will warn the user if the config doesn't extend Plasmo's one. This serves as an escape hatch for thi...
LoXatoR
LoXatoROP•8mo ago
Yes, I tried to follow that by introducing a custom .parcelrc , was wondering if you had an idea on how to solve the above issue (I am not 100% sure if a custom parcel config would solve it)
lab
lab•8mo ago
Generally, I'd just do a common index.ts file and import per platform based on a .env variable That'd help parcel cherry pick the file for you The internal resolver is not react-native aware, the current example is simply exploiting the fact that looks up the index file FYI, plasmo also looks up browser target specific files like index.chrome.ts etc... But for your issue, I'd just use index.ts with an env, and lazy load your component as needed
LoXatoR
LoXatoROP•8mo ago
Thanks for answering, I will give it a shot!
Ymir
Ymir•8mo ago
@lab with-custom-parcel example ( & mention in docs ) would be really helpful here! 🙂
Want results from more Discord servers?
Add your server