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-loader config is not transpiling npm modules.

See original GitHub issue

I’m trying to get the babel-loader plugin to compile npm installed modules. Here is a simple example of my issue. https://github.com/johnwebbcole/vue-webpack-bable-issue

This is a fresh vue init webpack testwp and adding pretty-bytes which is written in ES6.

In order to run on IE 11 I need to transpile the node_modules/pretty-bytes/index.js file. The default config does not appear to do this.

image

My research indicates that the babel-loader plugin should be handling this, but different configurations to webpack.base.conf.js and .babelrc file have failed to fix the issue. Many issues seem to be with all of the node_modules files getting transpiled and it needing to be in the excludes list. Doing the opposite, adding it to the include array did not fix the issue.

image pretty-bytes is still using arrow-functions.

Does anyone have some suggestions to get the node_modules files to be transpiled. Thanks!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

14reactions
KagamiChancommented, Jul 28, 2017

IMO published packages are assumed to be transpiled, for your case you may add this package in you babel-loader’s config here https://github.com/johnwebbcole/vue-webpack-bable-issue/blob/master/build/webpack.base.conf.js#L47

12reactions
johnwebbcolecommented, Jul 28, 2017

@KagamiChan I understand that has been typical in the past, but it appears that some module maintainers are deciding to leave that up to the bundler. See https://github.com/sindresorhus/ama/issues/446 or https://github.com/facebookincubator/create-react-app/issues/1125#issuecomment-264217076

Apparently this can no longer be assumed.

Also, as stated in the issue, adding a node_module to the include array does not fix the issue. If you believe this is a webpack bug, I’ll open a ticket there, but I was hoping this was a configuration issue. Since it appears that none of the node_module files are being transpiled by babel-loader without anything in the excludes: [] section, I was wondering if there was a configuration somewhere removing all of the node_module entries, even if they are in include.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack and Babel not transpiling a dependency inside ...
Ok, it turns out to process files inside node_modules you need to use babel.config.js rather than .babelrc as explained here and here:.
Read more >
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 >
How to transpile node_modules with babel and webpack in a ...
We do not transpile the contents of our node_modules folder, to reduce the size of our bundle and avoid extremely long build times....
Read more >
How to transpile ES modules with webpack and Node.js
The babel-loader loads ES2015+ code and transpiles it to ES5 using Babel. As you can also see in the config file, we have...
Read more >
next-transpile-modules - npm
If you get a transpilation error when using a custom Babel configuration, make sure you are using a babel.config.js and not a .babelrc...
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 Hashnode Post

No results found