-
-
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
Nextjs Cannot Import Parallax #627
Comments
It looks like react-spring is using the ESM version of var _extends = _interopDefault(require('@babel/runtime/helpers/esm/extends')); nextjs doesn't transpile node_modules so you end up with As @giovannibonin describes: |
Is there no solution to this problem for nextjs?
…On Wed, Apr 10, 2019 at 2:54 AM Clemens Stolle ***@***.***> wrote:
It looks like react-spring is using the ESM version of @babel/runtime in
its output bundle:
var _extends = ***@***.***/runtime/helpers/esm/extends'));
nextjs doesn't transpile node_modules so you end up with import/export
syntax in node.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#627 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/Ati53FTQ-l0o0E_I-NI-KwIbeOftodjYks5vfbTvgaJpZM4ci7vf>
.
|
You can downgrade to react-spring 7 until it will be fixed |
This is still an issue. Why is it closed without reference @aleclarson |
Sorry. The In v9, you can do The OP was trying to import { Spring } from 'react-spring/renderprops'
const { Spring } = require('react-spring/renderprops.cjs') |
@aleclarson how does one import addons in 9 (yes seems to work for spring) as this thread is talking about addons specifically. |
The next v9-beta will work like this: import { Parallax } from '@react-spring/addons' The current v9-beta works just like v8. import { Parallax } from 'react-spring/renderprops-addons'
const { Parallax } = require('react-spring/renderprops-addons.cjs') |
@aleclarson This is actually still an issue In 9 (and also 8)
fails with |
I've spent some time confirming this is still infact an issue and should be addressed. The compiled renderprops-addons.cjs.js references the wrong (non cjs) renderprops file so you get the un "babelized" version of it, which makes it explode. If you change the require line on line 11 from
It works in both 8 and 9 |
It's all working in the next v9-beta, which I'm trying to publish asap. Anyone who wants v8 to work, please send a PR. Here's a good place to start looking: https://github.com/react-spring/react-spring/blob/f2cfad54f77aad26736c56e4f944c474b8d5cbda/rollup.config.js#L110 I'm keeping this closed since it's an issue with an old version. |
I tried it in 9 and it fails with the same reasoning when doing
or
If you mean that it will work once you publish support for
Then I understand and will wait until it's done :-) |
Yes, exactly! Sorry for not being clear before. |
@aleclarson ok carry on thank you for being so patient! :-D |
This still seem to be an issue regardless of Next.js or spring versions, e.g The error is different, but I believe it's the same issue? |
@deioo I check this weekly and yes react-spring 9 still does not work with NextJS. I believe when @aleclarson gets closer the build will change and it will start working. If you jump all the way back to 7.x it will work but there's no hooks support in 7. It's effectively the same issue. It's because it's loading the non-transpiled version of react-spring. |
Using next This is only an issue on next. It does work as intended on a regular project (code sandbox). Tried importing with each of the following, unsuccessfully: const {
Parallax,
ParallaxLayer,
} = require('react-spring/renderprops-addons.cjs')
// also tried...
const {
Parallax,
ParallaxLayer,
} = require('react-spring/renderprops-addons.cjs.js')
// and this:
import { Parallax, ParallaxLayer } from 'react-spring/renderprops-addons.cjs.js'
// and others, including:
import { Parallax, ParallaxLayer } from 'react-spring/renderprops-addons' And I'm getting this error: (I changed the paths to /path/to) Unexpected token export
/path/to/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js:1
export default function _objectWithoutPropertiesLoose(source, excluded) {
^^^^^^
SyntaxError: Unexpected token export
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/path/to/node_modules/react-spring/renderprops.js:7:53)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/path/to/node_modules/react-spring/renderprops-addons.cjs.js:11:19) Thanks for your attention! |
@nandorojo Can you try with the latest canary? Thanks 👍 import { Parallax, ParallaxLayer } from 'react-spring/addons' |
@aleclarson Thanks so much for the quick response! Really appreciate your time. Unfortunately still getting an error. I updated: package.json "react-spring": "^9.0.0-canary.808.4.e67bf81", And imported like this: import { Parallax, ParallaxLayer } from 'react-spring/addons' I'm getting this error in the server logs:
And in the browser, I'm seeing this error: Failed to compile
./node_modules/react-spring/node_modules/@react-spring/addons/index.js
Module not found: Can't resolve 'shared' in '/path/to/node_modules/react-spring/node_modules/@react-spring/addons' I am using typescript with next, could that be related to the issue? Thanks again. |
@nandorojo Try installing without a caret range:
|
@aleclarson Updated:
Still getting the same error as the previous comment. Let me know if there's anything else you think I should try. Thanks! |
Did you try with the
If that doesn't work, please make a git repository that I can debug. 👍 |
I did, still same error. Happy to make a git repo. Here you go: https://github.com/nandorojo/react-spring-next-issue
|
@nandorojo Fixed in Example repo here. import { Parallax, ParallaxLayer } from '@react-spring/parallax' |
@aleclarson Ah, yes!! Thanks so much, updated my project and it's working. Really appreciate your taking the time for me. |
This is good, except I have one issue with this, which is that it's wanting the props I just manually hid it by passing the styles, overflowY: 'hidden' |
@honglish I also have the same issue, I am wondering if everything else works fine for you ? |
@aleclarson i used the 9.0.0-canary.808.8.4a87fcb version you suggested to @nandorojo and the suggested import, however I'm getting the following error: |
check your dependencies... should be : "@react-spring/parallax": "9.0.0-canary.808.8.4a87fcb", |
hi, i added the latest beta version, but also can't seem to be able to add the parallax on Next.js. Any suggestions or news if this was fixed? |
How is this issue still "Closed" can someone reopen this? |
Same problem happens with react-spring 8.0.27 and also with current react-spring@next version. I was able to solve it transpiling react-spring 8.0.27 using next-transpile-modules. On next.js.config:
and then
Credits to @Jessidhia #374 (comment) |
Simply do |
This is still not working on "next": "13.4.12", "react-spring": "^9.7.2". Check the render method of |
I've had this issue that others seem to be having when using Nextjs, that I cannot import Parallax. It seems that by changing how renderprops is imported on react-spring/renderprops-addons.cjs.js fixes the issue. I.e:
change to
var renderprops = require(react-spring/renderprops.cjs');
from
var renderprops = require(react-spring/renderprops');
Would that break something else or is there a reason this hasn't been PR'd yet?
Related: #278
The text was updated successfully, but these errors were encountered: