-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Failed import when using NextJS #374
Comments
@RafalFilipek thx for the reproduction repo. That is exactly the error I get. |
Hi @andreoav. First, Make sure to have React and react-dom 16.7.x installed. Then, import react-spring hooks from import { useSpring, animated } from "react-spring/hooks.cjs"; That makes sure to import the commonJS version, readable by Node.js. Here's a working Sandbox https://codesandbox.io/s/lq7lzp42z. 😉 |
True :) cjs are fine for server side but afaik es modules are preferred for client side bundles. Still, thx for temporary workaround. |
A similar issue happens even in non-SSR projects if you try to write tests for it. You probably need something like this in jest's This also doesn't only affect hooks but anything that doesn't use the top-level import. |
I also encountered this issue and solved this using next-transpile-modules next.config.js module.exports = withTranspileModules({ transpileModules: ['react-spring', '@babel/runtime'] }) |
@cvpcasada that looks like a real solution. does something like this exist with the other SSR/node libs as well, like Gatsby or Jest? I mean, i could also inline babel-helpers, but that would impact the size of the bundle negatively, and that would really suck, given that's what babel-transform is there for after all. |
Just encountered the same issue after upgrading to |
I didn't experience this with NextJS when using |
@aleclarson Still experiencing this issue, especially not fixable for Parallac features atm. |
@StefanSchwartze Please open a new issue with a repro. Thanks! |
I have the following error when I try to import animated in NextJS project.
The code is the following:
The text was updated successfully, but these errors were encountered: