felixakiragreen / react-kronos

A fast, intuitive, and elegant date and time picker for React.
https://felixakiragreen.github.io/react-kronos/
MIT License
89 stars 28 forks source link

Babel 7/React 16/Webpack 3 #67

Closed Metroninja closed 6 years ago

Metroninja commented 6 years ago

Our team was using this library in a babel 7 project and ran into webpack bundling issue on node 8. I forked the repo and got it building by upgrading relevant files to the latest webpack/react16/babel 7 beta.40 but still had integration issues with lodash. The final fix that got everything working again was to move lodash as a peer dependency.

XXXXXXXX     | ERROR in ./node_modules/react-kronos/node_modules/lodash/_apply.js
XXXXXXXX      | Module build failed: Error: Cannot find module 'babel-preset-react' from '/src/node_modules/react-kronos'
XXXXXXXX      | - If you want to resolve "react", use "module:react"
XXXXXXXX       | - Did you mean "@babel/react"?

Following changes were made

This will likely break anything pre babel 7, so this release should be tagged as babel 7+. This should save you the trouble of having to upgrade everything and verify it once babel 7 is widely released. In the meant time people using babel 7 can use my fork. Having this PR visible should make it easier for people with said issues to find.

Metroninja commented 6 years ago

Found some deeper issues, will reopen once fixed.

Metroninja commented 6 years ago

So I initially attempted to update moment and moment-range to the latest versions but this broke the library as there appears to be some deprecated code in later versions. I didn't have time to validate all of the changes so I rolled back and this is a fully working version featuring what I set out to do - get this working for codebases using latest versions of babel/react/webpack

felixakiragreen commented 6 years ago

Hey @Metroninja, thanks for the PR! I will check this out as soon as I can, test it, and then release it. Look for an update in the next few days.

felixakiragreen commented 6 years ago

@Metroninja having trouble getting your branch up and running. I'm getting this error: Error: Cannot find module 'babel-plugin-react-transform'. I thought it was because @babel/plugin-transform-react-jsx wasn't added to .babel_rc but that didn't fix it. I'll spent some more time on it soon, but any input is appreciated.

Metroninja commented 6 years ago

@dubert - sorry for the delay today, had a lot on my plate. Is your error running npm run-script build or is it attempting to use my branch in a project to test it out? if you are using this branch, the root project MUST be babel 7 ready. I know I can build without issue on my local box (just did) so I'm assuming you are attempting to use my branch and running into issues. Again, my PR is meant for people using projects with react/webpack latest AND babel 7 together, the key being Babel 7 for the main project.

If you are having issues simply building on my PR let me know, I'll try greenfielding my branch again if that's the case.

felixakiragreen commented 6 years ago

Updated, using a modified version of your branch.