Skip to content
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

framer-motion package version not compatible with react-app #104

Closed
JulienGasparLopes opened this issue May 16, 2022 · 6 comments
Closed
Assignees

Comments

@JulienGasparLopes
Copy link

I get this error while installing RSI on a brand new react-app (with create react-app) or when installing on an existing project (pure JS, no TS installed) :

Can't import the named export 'Children' from non EcmaScript module (only default export is available)

Reproduction
Node : v16.15.0
package.json :

"dependencies": {
    "react": "^17.0.2",
    "react-dom": "17.0.2",
    "react-scripts": "^4.0.3",
    "react-spreadsheet-import": "^2.0.3"
  }

Possible Solution
I've already seen this PR that proposed a fix by downgrading framer-motion : #93
I tried it by forking project, changing lib version to 4.1.17 and importing on my project the new builded lib. It works perfectly

More about the error
This is a known issue due to ReactCreateApp not working with ESmodule since version5 :
reactioncommerce/reaction-component-library#399

  • A fix was proposed but still in alpha
  • A workaround is proposed but not really easy and little bit compelling while using RCA out of the box)

Downgrading framer-motion doesn't seems to have impact and may allow to easily install RSI (it should be upgraded when RCA fixed this issue)
I'd be glad to discuss it further / to propose a PR :)

PS : thx for this awesome lib, i'm considering to contribute to it ! Cheers !

@masiulis
Copy link
Contributor

Hey @JulienGasparLopes thanks for creating an issue! I have released a new version (2.0.4) where I have changed framer into a peer dependency with both framer v4 and framer v6 and supported. Let me know if it works!

@JulienGasparLopes
Copy link
Author

Wow thx a lot, I really appreciate your reactivity ;)

Unfortunately it doesn't seems to fix the problem. I'm guessing this is because the error happens on this file :
./node_modules/framer-motion/dist/es/components/AnimatePresence/index.mjs
which is on project's sources. So even if i'm trying to install an other version of framer-motion, the built version of RSI is using the version you installed on projet (^6.x.x by default)

I made RSI working on my projet by changing framer-motion to 4.1.17 and building it. But I can understand it's a little bit tricky to change this on the RSI project. :)
Until RCA fixes this problem I can use my own fork of the lib

@masiulis
Copy link
Contributor

@JulienGasparLopes thanks for trying it out! The built RSI version does not include node_modules. A fresh module install should resolve to "framer-motion": "4.1.17", maybe removing package-lock/yarnlock would help? (I am testing on a fresh CRA with dependencies you have listed and I got the v4)

@JulienGasparLopes
Copy link
Author

I'll try again, I did remove node_modules and package-lock but I must have missed something !
Thank you again

@JulienGasparLopes
Copy link
Author

Okey I tried again and succeeded ! peerDependencies allows me to select the version I need to install (due to my project stack versions of node and other lib I'm unable to use peerDependency auto-installation but works fine by defining versions I need in dependencies)

@masiulis
Copy link
Contributor

masiulis commented Jun 1, 2022

@JulienGasparLopes Awesome! Glad it works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants