question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Webpack + babel issues

See original GitHub issue

Hi, 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:closed
  • Created 7 years ago
  • Reactions:9
  • Comments:17 (6 by maintainers)

github_iconTop GitHub Comments

5reactions
nosircommented, Jul 27, 2016

Final improvement in v0.5.2: It’s not dist/cleave-react.webpack anymore, just use dist/cleave-react.

Turns out Browserify project works well with bundled Webpack 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:

2reactions
hitchcockwillcommented, May 2, 2017

With a create-react-app app the following import worked for me:

import Cleave from 'cleave.js/dist/cleave-react'
import CleavePhone from 'cleave.js/dist/addons/cleave-phone.us'

Note that I dropped the .webpack suffix mentioned above.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found