Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsnext:main transpiling #488

Closed
damianobarbati opened this issue Jul 6, 2017 · 5 comments
Closed

jsnext:main transpiling #488

damianobarbati opened this issue Jul 6, 2017 · 5 comments

Comments

@damianobarbati
Copy link

damianobarbati commented Jul 6, 2017

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!

webpack/webpack#2902

@danez
Copy link
Member

danez commented Jul 22, 2017

babel-loader/babel is only transpiling what you tell it to transpile.

webpack is respecting the module field in package.json, but the definition of the module field is not to be ES2018, but rather parseable by node or browser except that it uses import/export. This is then used to do tree shaking in webpack, but not to transpile node_modules.

@danez danez closed this as completed Jul 22, 2017
@sibelius
Copy link

sibelius commented Jan 4, 2019

can we have an option to enable transpiling all jsnext:main and module on node_modules?

@loganfsmyth
Copy link
Member

@sibelius That is something you'd set up in your Webpack config, not as part of babel-loader.

@sibelius
Copy link

sibelius commented Jan 5, 2019

I think it makes sense to have something like this in a helper or as an option

@loganfsmyth
Copy link
Member

@sibelius It is not something a loader can effect. Webpack decides how to process things like that, not Babel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants