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
ES Modules in node_modules. How to transpile? #2902
Comments
Webpack 2 should transpile ES module for you automatically. |
@swernerx Do you already have something like If so, your loader test for
to
|
Webpack does not transpile ES6 module syntax to commonjs modules, or even transpile commonjs; what it does is convert code using those respective module systems to use webpack's module system instead. If the code pointed to inside the @wegry don't use |
Yep that seems to work without. I was just confused by the problem that not all jsnext:main packages are correctly pre-transpiled. When these dependencies are ES5+modules then it works indeed fine together with webpack2. Thanks. |
@Kovensky I still don't understand how Webpack manages to {
test : /\.js$/,
include :
[
// `node_modules` not included
path.resolve(frontend_root_folder, 'code')
],
loader: 'babel-loader'
} And it seems that it possibly does it wrong: |
@swernerx did you manage to solve? I really do not understand what's the current status in Webpack to transpile dependencies in node_modules, can anyone please clarify? I tried to stick to every issue opened here.
My situation:
In my dependency package.json I tried:
Neither is working without removing |
I don't get it: 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? |
I finally got a node_modules package to compile with The problem was that the package had it's own
My solution is to set var readPackageJson = require('read-pkg')
var babelOptions = readPackageJson.sync().babel
babelOptions.babelrc = false
// ... rest of config
{
test: /\.js$/,
loader: 'babel-loader',
include: [path.join(__dirname, '..', 'node_modules/vue-match-media')],
options: babelOptions,
}, |
I am using Webpack 2 beta21 in some setup where I am trying to combine
System.import
auto chunks + HMR + SSR React. I am currently struggle with how to use modules in es2015 module syntax (as suggested bymodule
/jsnext:main
entries). As far as I understand I have to transpile that code. But normally we do not transpile any code fromnode_modules
, correct? So how can I do that "basic" transpilation that I have a non-module output from all these different sources?The text was updated successfully, but these errors were encountered: