Tuesday, 2 October 2018

Can't get babel loader to apply to dependency

A dependency of my project is using arrow functions and I cannot seem to get babel-loader to transpile the external dependency.

My module section looks like

module: {
        rules: [
            {test: /\.(js|jsx)$/, loader: 'babel-loader'}
        ]
    }

I originally had exclude: /node_modules/(?!superagent)/ in the rules object but removed it to make sure it was not a regex issue.

.babelrc

{
  "presets": [
    "@babel/env",
    "@babel/react"
  ]
}

index.js

import superagent from 'superagent'

superagent.get('http://www.google.com')
    .then(result=>console.log('done'))
    .catch(e=>console.error(e));

The offending dependency in this case is superagent

I created a minimal repo with the config that shows the issue https://github.com/ksmith97/WebpackIssue

I am not sure what else there is to try here



from Can't get babel loader to apply to dependency

No comments:

Post a Comment