-
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
Remove global babelHelpers and regenerator #21283
Conversation
This comment has been minimized.
This comment has been minimized.
…erator (#198) Summary: **Summary** The RN transformer currently relies on the enviroment providing babelHelpers and regeneratorRuntime as globals by using 'babel-external-helpers'. This wasn't really a problem before since helpers were stable and we could maintain our copy easily but it seems like there are more now with babel 7 and it makes sense to include only those used by the app. This is exactly what babel/transform-runtime does. It will alias all helpers and calls to regeneratorRuntime to files in the babel/runtime package. This will solve issues like this facebook/react-native#20150 caused by missing babelHelpers. This solution also avoids bloating babelHelpers to fix OSS issues like the one linked before. **Test plan** - Updated tests so they all pass. - Tested that it actually works by applying the changes locally in an RN app. - Added a test for async functions, to make sure regenerator is aliased properly and doesn't depend on the global. - Made sure require-test.js still fails if the require implementation contains babel helpers (by adding an empty class in the file). Pull Request resolved: #198 Reviewed By: mjesun Differential Revision: D8833903 Pulled By: rafeca fbshipit-source-id: 7081f769f288ab358ba89ae8ee72a513bb12e225
Thanks @janicduplessis for the PR! I'm planning to release a new version of Metro later today (it's going to be v0.46.0 since the babel runtime change is breaking. With this you're going to be able to test it locally and afterwards I can import it 😄 |
I've just published |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rafeca has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
/* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an | ||
* error found when Flow v0.54 was deployed. To see the error delete this | ||
* comment and run Flow. */ | ||
require('regenerator-runtime/runtime'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also remove regenerator-runtime
from the dependencies in package.json
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still need it for jest tests, I guess I could move it to dev deps
b9798d6
to
d9f7588
Compare
@rafeca I was able to tests it, the only change missing was to add @babel/runtime to RN deps. |
@rafeca I also didn't update the yarn.lock file, for some reason I couldn't generate a clean set of changes to it. It might be out of date already or a different version of yarn was used to generate it. |
Also CI seems to be failling because of metro package that isn't published properly
|
@janicduplessis I think it has been published now (or, at least, running |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rafeca has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
This might conflict with 1323acd, I think |
Yeha I agree, may be worth reversing that in favour of this (which I guess may also just happen during the internal importing, right?) cc @RSNara |
@janicduplessis merged commit 458d56c into Once this commit is added to a release, you will see the corresponding version tag below the description at 458d56c. If the commit has a single |
Summary: Follow up to facebook/metro@8932a9c Babel helpers and regenerator runtime will be imported automatically from `babel/runtime`. We still need to add the global regeneratorRuntime for jest tests since we disable babel-runtime currently. Pull Request resolved: #21283 Reviewed By: mjesun Differential Revision: D10010963 Pulled By: rafeca fbshipit-source-id: da5e23dd901f8f8940d46816b4fc9290d0e28c76
Summary: Follow up to facebook/metro@8932a9c Babel helpers and regenerator runtime will be imported automatically from `babel/runtime`. We still need to add the global regeneratorRuntime for jest tests since we disable babel-runtime currently. Pull Request resolved: facebook#21283 Reviewed By: mjesun Differential Revision: D10010963 Pulled By: rafeca fbshipit-source-id: da5e23dd901f8f8940d46816b4fc9290d0e28c76
Summary: Follow up to facebook/metro@8932a9c Babel helpers and regenerator runtime will be imported automatically from `babel/runtime`. We still need to add the global regeneratorRuntime for jest tests since we disable babel-runtime currently. Pull Request resolved: facebook/react-native#21283 Reviewed By: mjesun Differential Revision: D10010963 Pulled By: rafeca fbshipit-source-id: da5e23dd901f8f8940d46816b4fc9290d0e28c76
Summary: Follow up to facebook/metro@8932a9c Babel helpers and regenerator runtime will be imported automatically from `babel/runtime`. We still need to add the global regeneratorRuntime for jest tests since we disable babel-runtime currently. Pull Request resolved: facebook#21283 Reviewed By: mjesun Differential Revision: D10010963 Pulled By: rafeca fbshipit-source-id: da5e23dd901f8f8940d46816b4fc9290d0e28c76
Follow up to facebook/metro@8932a9c
Babel helpers and regenerator runtime will be imported automatically from
@babel/runtime
. We still need to add the global regeneratorRuntime for jest tests since we disable babel-runtime currently.Test Plan:
Release Notes:
Help reviewers and the release process by writing your own release notes. See below for an example.
[GENERAL] [ENHANCEMENT] [polyfills] - Remove global babelHelpers and regenerator