-
Notifications
You must be signed in to change notification settings - Fork 41
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
On including node_modules in Babel transpilation #3
Comments
Sorry for the delayed reply; I must have missed the notification for this...
Have you tried this with Babel 7? I've heard many issues with transpiling dependencies have been fixed in Babel 7. In fact, create-react-app started doing this as well. |
No worries, and thanks for getting back to me! Yes, that plugin I linked is based on the Babel 7 beta. What I've ended up doing for now is just maintaining a list of packages that will break if re-transpiled. Ultimately, it'd probably be better to do some sort of inspection (e.g. whether the package's entry file is the "main" or "module" in package.json) and only transpile if it isn't the "main" - assuming that "main" would be an already transpiled UMD module. That said, I haven't messed with it in a month or so since I got it working with the "ignore" list. Also, some other things I've learned since I original posted are that there's I was planning on revisiting shortly anyhow to see how Webpack 4 could make things better - I haven't played with the new version yet, but the ES module support sounds promising! |
@philipwalton - update! big refactoring for Webpack 4 - instead of generating multiple compilations, it actually splits the entries for each browser target. Would love to get some feedback on the implementation! https://github.com/DanielSchaffer/webpack-babel-multi-target-plugin/tree/feature/webpack4 |
First off: I love this idea. However, I've been playing around with it a bit, and have not had much luck with allowing Babel to transpile several common dependencies. Attempting to transpile apps with dependencies on
lodash
,moment
, orcore-js
resulted in runtime errors likeCannot assign to read only property 'exports' of object '#<Object>'
. For what it's worth,angular
andrxjs
work fine.I've started a plugin that makes some of the legwork required to make this work a little easier, which has several example projects with different dependencies:
https://github.com/DanielSchaffer/babel-multi-target-plugin
You can reproduce the transpilation issues by commenting out the relevant
exclude
line in thewebpack.config.js
file in any of thetypescript-lodash
,typescript-moment
, orangular-five
example projects. Do these packages just need to excluded from transpilation for now, or am I doing something wrong?The text was updated successfully, but these errors were encountered: