animatedjs / animated

Declarative Animations Library for React and React Native
MIT License
1.85k stars 102 forks source link

React Native Babel Preset Required #61

Open kwelch opened 7 years ago

kwelch commented 7 years ago

I am getting the following error, on a fresh install of animated in a web app. I have no react-native code to this point and I didn't see any documentation and says it needed to be a RN project.

ERROR in ./~/animated/lib/index.js
Module build failed: Error: Couldn't find preset "react-native" relative to directory 

Once I installed babel-preset-react-native the project built and functioned as expected. I am not really sure why this is happening but I wanted to raise the flag. Simple fix would be to move the preset to be a peerDependency, but I would not expect a packaged lib to need a babel preset.

Stacktrace below

"/Users/welchk/_git/you-pick/node_modules/animated" at /Users/welchk/_git/you-pick/node_modules/babel-core/lib/transformation/file/options/option-manager.js:293:19 at Array.map (native) at OptionManager.resolvePresets (/Users/welchk/_git/you-pick/node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20) at OptionManager.mergePresets (/Users/welchk/_git/you-pick/node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10) at OptionManager.mergeOptions (/Users/welchk/_git/you-pick/node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14) at OptionManager.init (/Users/welchk/_git/you-pick/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12) at File.initOptions (/Users/welchk/_git/you-pick/node_modules/babel-core/lib/transformation/file/index.js:212:65) at new File (/Users/welchk/_git/you-pick/node_modules/babel-core/lib/transformation/file/index.js:135:24) at Pipeline.transform (/Users/welchk/_git/you-pick/node_modules/babel-core/lib/transformation/pipeline.js:46:16) at transpile (/Users/welchk/_git/you-pick/node_modules/babel-loader/lib/index.js:46:20) at Object.module.exports (/Users/welchk/_git/you-pick/node_modules/babel-loader/lib/index.js:163:20) @ ./src/components/App/index.js 13:16-35 @ ./src/index.js @ multi (webpack)-dev-server/client?http://localhost:8080 babel-polyfill react-hot-loader/patch ./src/index.js
browniefed commented 7 years ago

This library is intended to be used for both react-native and react for the web. However the one issue is that the web / react-native versions don't have separate builds just separate entry points.

This could definitely be improved however at the moment this isn't actively maintained.

kwelch commented 7 years ago

Understandable, I will leave this open so it maintains visibility.

souporserious commented 7 years ago

I keep running into this issue 😞 is there any guidance on how this can be fixed? I'd be happy to put together a PR.