-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Remove the need for allowTopLevelThis in transform-es2015-modules-commonjs #6255
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
Conversation
By analyzing the blame information on this pull request, we identified @sahrens, @janicduplessis and @frantic to be potential reviewers. |
@@ -24,4 +21,4 @@ var GLOBAL = this; | |||
* that use it aren't just using a global variable, so simply export the global | |||
* variable here. ErrorUtils is originally defined in a file named error-guard.js. | |||
*/ | |||
module.exports = GLOBAL.ErrorUtils; |
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.
strict: Use the global form of "use strict".
c60e319
to
7c749d9
Compare
@janicduplessis updated the pull request. |
LGTM |
Tests are green and this looks safe to me. Mainly it's a question of whether some FB internal code is relying on some subtle behavior that may have changed -- shipping this to send it to the internal test runner. |
@facebook-github-bot shipit |
Thanks for importing. If you are an FB employee go to Phabricator to review. |
/* eslint-disable consistent-this, global-strict */ | ||
|
||
var GLOBAL = this; | ||
/* eslint-disable strict */ |
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.
Also we probably can write "use strict" now... can do that in a future diff.
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 were actually discussing enabling strict mode in modules and maybe remove 'use strict' added manually everywhere so we can leave it as is for now.
👍 |
@davidaurelio @martinbigio I suspect this caused some internal tests to fail -- if this is the case, is it possible for FB to use a custom Babel configuration that extends the RN preset but sets |
@janicduplessis updated the pull request. |
@davidaurelio Is this going to break anything? |
With this change, we can finally use 'es2015' preset instead of writing individual plugins, right? Thanks a lot for working on this. Moving the preset closer towards standard setups is really great. |
Any updates on this? |
@janicduplessis updated the pull request. |
What I think we should do for now is keep the allowTopLevelThis in the preset but still make these changes that allow RN to work without it. The main issue right now is that we transform every library in node_modules with the babel preset so it can cause issues that are hard to fix. Until we can configure the babel preset it's better to keep the transforms as loose a possible. |
I put back the allowTopLevelThis in the babel preset so it should be able to get merged without breaking internal fb tests. |
@facebook-github-bot shipit |
1 similar comment
@facebook-github-bot shipit |
Thanks for importing. If you are an FB employee go to Phabricator to review. |
Flaky CI maybe? @facebook-github-bot shipit |
Thanks for importing. If you are an FB employee go to Phabricator to review. |
Seems the tests are not passing. Some error with code analysis bot. |
@janicduplessis updated the pull request. |
Seems Flow check is failing in the CI |
No idea what causes that. Flow is scanning random buck json files. |
@janicduplessis, no worries, it is some old Circle cache that had buck installed in the project file tree. |
@facebook-github-bot shipit |
Thanks for importing. If you are an FB employee go to Phabricator to review. |
@mkonicek Any idea what caused the internal test failures here? |
…monjs This removes the few places that a top level this was used to refer to the global space. It also clean up the usage of `GLOBAL` to use `global` instead as this is what is used everywhere else in the code base. We still define `GLOBAL` for compatibility with other modules.
5eef7a0
to
8f866c4
Compare
@janicduplessis updated the pull request. |
8f866c4
to
df69741
Compare
@janicduplessis updated the pull request. |
I can't tell what's wrong with the tests actually, a generic Buck failure. Merging again. |
@janicduplessis I’d really like to have this. Would you mind rebasing again? I’ll try to get this in ;-( |
Rebased it yesterday, it should be fine now. |
@facebook-github-bot shipit |
Thanks for importing. If you are an FB employee go to Phabricator to review. |
…monjs Summary: This make the transform behave closer to the standard for modules. This removes the few places that a top level this was used to refer to the global space. It also clean up the usage of `GLOBAL` to use `global` instead as this is what is used everywhere else in the code base. We still define `GLOBAL` for compatibility with other modules. **Test plan** Clear the packager cache to make sure the transforms run again. (node ./local-cli/cli.js start --reset-cache). Run the Movies example (UIExplorer is broken atm) and make sure there are no errors. Closes facebook#6255 Differential Revision: D3037227 Pulled By: mkonicek fb-gh-sync-id: bcf1350ae7a6e92c77d3a87fc9d6e42eb93cb9b9 fbshipit-source-id: bcf1350ae7a6e92c77d3a87fc9d6e42eb93cb9b9
…monjs Summary: This make the transform behave closer to the standard for modules. This removes the few places that a top level this was used to refer to the global space. It also clean up the usage of `GLOBAL` to use `global` instead as this is what is used everywhere else in the code base. We still define `GLOBAL` for compatibility with other modules. **Test plan** Clear the packager cache to make sure the transforms run again. (node ./local-cli/cli.js start --reset-cache). Run the Movies example (UIExplorer is broken atm) and make sure there are no errors. Closes facebook#6255 Differential Revision: D3037227 Pulled By: mkonicek fb-gh-sync-id: bcf1350ae7a6e92c77d3a87fc9d6e42eb93cb9b9 fbshipit-source-id: bcf1350ae7a6e92c77d3a87fc9d6e42eb93cb9b9
…monjs Summary: This make the transform behave closer to the standard for modules. This removes the few places that a top level this was used to refer to the global space. It also clean up the usage of `GLOBAL` to use `global` instead as this is what is used everywhere else in the code base. We still define `GLOBAL` for compatibility with other modules. **Test plan** Clear the packager cache to make sure the transforms run again. (node ./local-cli/cli.js start --reset-cache). Run the Movies example (UIExplorer is broken atm) and make sure there are no errors. Closes facebook#6255 Differential Revision: D3037227 Pulled By: mkonicek fb-gh-sync-id: bcf1350ae7a6e92c77d3a87fc9d6e42eb93cb9b9 fbshipit-source-id: bcf1350ae7a6e92c77d3a87fc9d6e42eb93cb9b9
This make the transform behave closer to the standard for modules.
This removes the few places that a top level this was used to refer to the global space. It also clean up the usage of
GLOBAL
to useglobal
instead as this is what is used everywhere else in the code base. We still defineGLOBAL
for compatibility with other modules.Test plan
Clear the packager cache to make sure the transforms run again. (node ./local-cli/cli.js start --reset-cache).
Run the Movies example (UIExplorer is broken atm) and make sure there are no errors.