You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a react vite web-app in /apps , I also have a react component library that uses vite as a bundler, lets call it package-a, in /packages. I want package-a to be buildable to take advantage of nx's caching etc. If package-a uses an external library, for example zod, when building the package it includes zod in the output. I can avoid this by specifying zod in the rollupOptions.external array. This means for every package that uses an external dependency aside from react, I have to keep this external array updated. NX doesn't seem to offer any automated way of handling this. It also doesn't strip out workspace packages either. So if package-a imports package-b that is also included in the vite bundled output. I've had to create a hacky workaround to fix this:
And also overwrite the react/vite generators using patch-package so new packages also have this change.
I hate having to do this, but don't see any other way. It doesn't seem like buildable libraries are catered for properly in my use case, which is likely to be how lots of others are using them. Am I missing something here?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have a react vite web-app in
/apps
, I also have a react component library that uses vite as a bundler, lets call itpackage-a
, in/packages
. I wantpackage-a
to be buildable to take advantage of nx's caching etc. Ifpackage-a
uses an external library, for examplezod
, when building the package it includes zod in the output. I can avoid this by specifying zod in therollupOptions.external
array. This means for every package that uses an external dependency aside from react, I have to keep this external array updated. NX doesn't seem to offer any automated way of handling this. It also doesn't strip out workspace packages either. So ifpackage-a
importspackage-b
that is also included in the vite bundled output. I've had to create a hacky workaround to fix this:And also overwrite the react/vite generators using patch-package so new packages also have this change.
I hate having to do this, but don't see any other way. It doesn't seem like buildable libraries are catered for properly in my use case, which is likely to be how lots of others are using them. Am I missing something here?
Beta Was this translation helpful? Give feedback.
All reactions