-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
[Discussion] Upgrade to Babel 6 breaks parts of the package ecosystem #4062
Comments
Probably no way around this besides to get those packages to add
There's a bug in the latest version where it'll stop looking for parent |
Awesome. Thanks for the clarification. I'll open up issues on the various affected repos to stop publishing .babelrc, and will let the Babel team take care of honoring the root .babelrc. |
I've been testing master with Babel 6 for a few days and am arriving at the conclusion that we need to make a couple changes to Babel for RN 0.16. I think I have a pretty clear idea of the issues at hand:
|
@ide When this is resolved, it would help the community if you'd post the solution here. It seems quite a lot of people are confused on how to configure babel in a react-native project. |
+1. I can't upgrade to v0.15 and use Redux because of the Babel 5/6 issues But that's not as bad as the way v0.16.0rc blows up Xcode with compiler errors. |
@adrian-social-prod Regarding the compiler errors, make sure you are using the latest version of Xcode. |
@ide This might sound a bit crazy.. I'll probably be offered up to the open source gods, but.. Seeing that things are a bit broken with RN + Babel at the moment, perhaps rolling back to Babel 5 would help in the short run until Babel has been patched to support decorators (officially or unofficially) and to ignore node_module .babelrc files? |
+1. I'm blocked on migrating to Babel 6 due to both issues covered here: decoration and old .babelrc format. |
Had the issue here #4516 - I'm using |
Latest versions of react-native use Babel 6, which tries to read the options from .babelrc in the installed reindex-js package and fails because it has options for Babel 5. As a fix to this, remove .babelrc from the published package by adding it to .npmignore. (See: facebook/react-native#4062)
I'm in the same boat as @adriansprod #4062 (comment) -- decorators and old Currently exploring workarounds to use Babel 5 with |
One temporary workaround would be, to delete all {
...
"scripts": {
"postinstall": "find node_modules -type f -name .babelrc | grep -v /react-native/ | xargs rm"
}
...
} |
This was mine -
Yours is a little easier to parse :-p |
@skevy Haha, that's nasty 😂 |
Thanks for sharing @satya164, I think I'm going to go with that approach for now over #4062 (comment) |
As a bit of a side-note, I can't help but think something is wrong when we have a separate GitHub repo for one tiny source file, with reams of extraneous files lying around, and no one bats an eye. It was always possible not to pollute the global namespace with wild abandon, but the front-end hive-mind decided that no one should need to be able to arrange his And here we are. Every front-end project is littered with "standard" configuration files for extraneous tools that are not related to the actual software being delivered. We're supposed to write some JavaScript, and have browsers load and run it. It's not that complicated. |
gulp task for fixing that import gulp from 'gulp';
import del from 'del';
gulp.task('native-fix', async () => {
// github.com/facebook/react-native/issues/4062#issuecomment-164598155
// This is a very long term issue. We can't fix whole npm.
await del(['node_modules/**/.babelrc', '!node_modules/react-native/**']);
}); It's from https://github.com/este/este |
Installed from npm, this package doesn't work with React Native, because although the released code is transpiled, .baberc is also published to npm. Fixed by adding the `files` property in package.json to prevent .babelrc from being published. See: facebook/react-native#4062
Processing npm modules with babel is a bug and will break many packages. This is not how any of the rest of the node.js/JavaScript ecosystem operates. This problem exclusively affects react-native. |
@ForbesLindesay I think it's actually really important for npm consumers to do transpilation. That doesn't preclude authors from transpile as well (just do both) but there are a lot of benefits to transpiling |
There are times when you want to transpile things in node_modules, but this should be done under the assumption that the code in node_modules is pure, standards compliant JavaScript code. It should not make use of .babelrc files, and it should not add strict mode if the file wasn't already in strict mode. Running babel in its default mode on node_modules is highly risky and should be avoided. Having the ability to run carefully chosen transforms against node_modules may be useful in the future, but it is a pretty specialised use case. |
…kager The react-native packager searches through all directories and parses .babelrc config files if it finds any. This breaks the builds if these .babelrc files are either for babel 5 or if they contain plugins unknown to the parent project. @see: facebook/react-native#4062
With the upgrade to Babel 6, two things changed:
Before, you could configure .babelrc in your project root and Babel would compute something like the union of .babelrc + the options passed to
transform()
, and it would apply all those options to everything under node_modules. But now it seems not to apply the options specified in .babelrc to each npm package, so perhaps each package needs to ship with its own .babelrc and list its plugins in the package.jsondependencies
.cc @sebmck you're probably the best person to comment on the state of things
The text was updated successfully, but these errors were encountered: