-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Transpiling external react modules causes multiple react copies #3102
Comments
Might be related to evanw/esbuild#475 (comment) |
I think it might be using the react installation from the local package, instead of the one from the main node_modules |
Oh yeah that does seem like esbuild has issues with duplicate packages, independently of Remix. I think the Remix team should seriously consider providing a fallback compilation strategy that uses webpack and allows users to opt-out of the non-configurable esbuild setup. This is what Nextjs does. They offer a fast and shiny SWC compiler (also non-configurable), and for those who prioritize configurability over speed, the build will automatically use the webpack/babel compiler if it detects a babel.config.js. This is necessary for using universal component libraries from react-native, that also work on web. Take this https://docs.nativebase.io/install-next as an example |
duplicate of #2987 |
Closing in favor of #2987 |
This seems related to #1423
What version of Remix are you using?
1.4.3
Steps to Reproduce
Here is a sample repository with the below steps: https://github.com/jaschaio/remix-bug
Create a new directory
Create a new package directory within it
Within the packages directory create a new
remix
projectChoose "Just the basics" and "Express Server" (this doesn't matter) and install the dependencies.
Create another directory within the
/packages
directoryRun
npm init
, name the package@local/controls
and addreact
andreact-dom
aspeerDependencies
into thepackage.json
Create a React Component, for example
Text.js
within the/packages/controls
directory. The important thing is that you use some hook likeuseCallback
:Go back to the
/packages/website
directory and install the other local package via:Add it as a dependency to the
serverDependenciesToBundle
within the/packages/website/remix.config.js
:Within the
/packages/website/app/routes/index.jsx
directory, import the component, remove the default content and place the Component within it:Run
npm run dev
from within the/packages/website
directoryWhen visiting
localhost:3000
you will get the Following error:Expected Behavior
Using react components from other modules should work without throwing errors.
Actual Behavior
I can't use hooks within other react modules that are added to
serverDependenciesToBundle
The text was updated successfully, but these errors were encountered: