webpack babel jsnext:main and dependencies transpiling

Viewed 1172

I opened the following issues last week but nobody seem to know the answer:

I really do not understand what's the current status in webpack / babel-loader in transpiling dependencies in node_modules, can anyone please clarify? I tried to stick to every issue opened everywhere.

  1. Is webpack / babel-loader transpiling jsnext:main file?
  2. If yes, is webpack / babel-loader transpiling jsnext:main file in node_modules even if node_modules is in exclude key?

My situation:

rules: [{
    test: /\.(js|mjs)$/i,
    exclude: [/node_modules/],
    use: [{
        loader: 'babel-loader', //settings specified in package.json
    },{
        loader: 'eslint-loader', //settings specified in package.json
    }
}]

In my dependency package.json I tried:

"main": "index.js", <= not working (not transpiled)
"jsnext:main": "index.js", <= not working (not transpiled)
"module": "index.js", <= not working (not transpiled)

Neither is working without removing exclude: [/node_modules/], but this can't be used in any medium-to-big sized project because of infinite compilation times.

But then: why is https://github.com/lodash/lodash/blob/es/package.json any different from my https://github.com/damianobarbati/react-create-app/blob/master/package.json? lodash-es is getting transpiled even being in node_modules (and excluded) but my react-create-app is not: HELP!

1 Answers
Related