Replies: 6 comments 5 replies
-
I was able to resolve by aliasing these dependencies in
Although this solution worked, is this really necessary? Why couldn't it use the local node_modules react dependencies without having to alias the imports? |
Beta Was this translation helpful? Give feedback.
-
I believe this is a common setup issue. The "easiest" way to resolve is to link It is better solved using a workspace setup instead, which will hoist React and other common dependencies to the top level that will be shared across your workspaces (your app and component lib in this case). No need for symlinking manually. Without any special config, moving these two into a common directory you are able to just add one extra file: // package.json
{
"name": "my-workspace",
"private": true,
"workspaces": ["app", "components"],
"scripts": { "dev": "cd app && yarn dev" }
} Where This could be further optimized to reduce the developer feedback loop in development. Hope this helps! |
Beta Was this translation helpful? Give feedback.
-
I'm getting the same problem, though I'm using I control a component library folks should be able to use in Next.js v12, however even using React 18 it doesn’t work out of the box because What are React component library maintainers meant to do about this? |
Beta Was this translation helpful? Give feedback.
-
Most likely Next.js can't do a lot about the issue.
|
Beta Was this translation helpful? Give feedback.
-
Anyone make any progress on this? Also having issues pulling in a component library and getting transpilation to work correctly. |
Beta Was this translation helpful? Give feedback.
-
I'd consider this a bug in the // next.config.js
module.exports = {
experimental: {
externalDir: true,
},
webpack: (
config,
{ buildId, dev, isServer, defaultLoaders, nextRuntime, webpack }
) => {
// Important: return the modified config
return {
...config,
resolve: {
...config.resolve,
fallback: {
"react/jsx-dev-runtime": path.resolve(
__dirname,
"node_modules/react/jsx-dev-runtime.js"
),
react: path.resolve(__dirname, "node_modules/react"),
},
},
};
},
}; |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Run
next info
(available from version 12.0.8 and up)What version of Next.js are you using?
12.0.10
What version of Node.js are you using?
v14.18.1
What browser are you using?
Chrome
What operating system are you using?
macOS
How are you deploying your application?
next start
Describe the Bug
We have a component library that we're developing using Storybook, TailwindCSS, React, and using Rollup to bundle. We bundle our library using
rollup -c
, then we use yarn link to symlink our bundle to our NextJS repository. We're seeing the following issue when attempting to utilize this library in our next project:Here's our rollup config:
Our component library specifies React and ReactDOM as peerDependencies, which is necessary to avoid multiple versions of React conflicting with each other in the host project. If we link our component library in a Create-React-App project, everything works just fine. The issue seems to only present itself in our NextJS repository.
Expected Behavior
We should be able to use our bundled component library in NextJS, as we're able to in a create-react-app.
To Reproduce
I can put up the component library in a Github repo if this is necessary to reproduce.
Beta Was this translation helpful? Give feedback.
All reactions