Webpack + babel issues
See original GitHub issueHi, I’m trying to use your library in our project with webpack + babel setup but I’ve come into several issues.
a) When I try to import it as suggested in README:
import Cleave from 'cleave.js/react';
I get following error in web console: Uncaught SyntaxError: Unexpected token import in react.js:1
b) And when I try to include the dist directly:
import Cleave from 'cleave.js/dist/cleave-react';
I get webpack error:
WARNING in ./~/cleave.js/dist/cleave-react.js
Critical dependencies:
1:113-120 This seems to be a pre-built javascript file. Though this is possible, it's not recommended. Try to require the original source to get better results.
@ ./~/cleave.js/dist/cleave-react.js 1:113-120
Thank you, Michael
Issue Analytics
- State:
- Created 7 years ago
- Reactions:9
- Comments:17 (6 by maintainers)
Top Results From Across the Web
babel-loader - webpack
This package allows transpiling JavaScript files using Babel and webpack. Note: Issues with the output should be reported on the Babel Issues tracker....
Read more >Babel Loader ignores webpack resolve config for its own plugins
This is expected, the babel plugin is not loaded by webpack, instead it is resolved using node require.resolve so it is not and...
Read more >webpack with Babel not working - Stack Overflow
Your webpack config has one error in it. Inside module, the keyword needs to be rules instead of loaders. const path = require('path'); ......
Read more >Issues for Webpack Babel | Drupal.org
Issues for Webpack Babel ; Add support for Drupal9, Needs review, Major ; Update src/Plugin/Webpack/ConfigProcessors/Babel.php (apply Drupal Coding standards ...
Read more >Lessons Learned From a Year of Fighting With Webpack and ...
Favor using babel.config.js to configure Babel over .babelrc . If you want to transpile node_modules (which is now becoming a very common case ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Final improvement in v0.5.2: It’s not
dist/cleave-react.webpack
anymore, just usedist/cleave-react
.Turns out
Browserify
project works well with bundledWebpack
script. So we just use webpack to build react bundle.It should work for all the cases you need. Also updated doc here: https://github.com/nosir/cleave.js/blob/master/doc/reactjs-component-usage.md:
With a create-react-app app the following import worked for me:
Note that I dropped the
.webpack
suffix mentioned above.