GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Remove global babelHelpers and regenerator by janicduplessis · Pull Request #21283 · react/react-native

Conversation

@janicduplessis

@janicduplessis janicduplessis commented Sep 24, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Follow up to react/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:

  • Run RN tester and make sure it works fine for screens using async functions.
  • Inspect the generated bundle to make sure helpers and regenerator are imported from @babel/runtime
  • Made sure the global babelHelpers and the old regenerator-runtime are not in the generated bundle.
  • Run jest tests

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 24, 2018
@pull-bot

This comment has been minimized.

Sign in to view
janicduplessis referenced this pull request in react/metro Sep 24, 2018
@janicduplessis @facebook-github-bot
Use babel runtime instead of relying on global babelHelpers and regen…
8932a9c
…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 react/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
@react-native-bot react-native-bot added Core Team labels Sep 24, 2018
@rafeca

rafeca commented Sep 24, 2018

Copy link
Copy Markdown
Contributor

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 😄

newyankeecodeshop reacted with hooray emoji
All reactions
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rafeca

rafeca commented Sep 24, 2018

Copy link
Copy Markdown
Contributor

I've just published [email protected] with the change. Can you test that things are working fine? In the meantime I'm importing the PR to do the internal checks

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

facebook-github-bot
facebook-github-bot reviewed Sep 24, 2018
View reviewed changes

@facebook-github-bot facebook-github-bot left a comment

Copy link
Copy Markdown
Contributor

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
newyankeecodeshop
newyankeecodeshop reviewed Sep 24, 2018
View reviewed changes
Comment thread Libraries/Core/InitializeCore.js Outdated

@newyankeecodeshop newyankeecodeshop Sep 24, 2018

Copy link
Copy Markdown

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?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@janicduplessis janicduplessis Sep 24, 2018

Copy link
Copy Markdown
Contributor Author

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
janicduplessis added 2 commits September 24, 2018 13:50
@janicduplessis
Remove global babelHelpers and regenerator
fc5f4a2
@janicduplessis
Add @babel/runtime dependency
d9f7588
@janicduplessis
janicduplessis force-pushed the remove-polyfills branch from b9798d6 to d9f7588 Compare September 24, 2018 17:57
@janicduplessis
janicduplessis requested a review from hramos as a code owner September 24, 2018 17:57
@janicduplessis janicduplessis changed the title [DONTMERGE] Remove global babelHelpers and regenerator Remove global babelHelpers and regenerator Sep 24, 2018
@janicduplessis
Move regenerator to dev deps since its used only for tests
957c5b4
@janicduplessis

janicduplessis commented Sep 24, 2018

Copy link
Copy Markdown
Contributor Author

@rafeca I was able to tests it, the only change missing was to add @babel/runtime to RN deps.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@janicduplessis

janicduplessis commented Sep 24, 2018

Copy link
Copy Markdown
Contributor Author

@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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@janicduplessis

janicduplessis commented Sep 24, 2018

Copy link
Copy Markdown
Contributor Author

Also CI seems to be failling because of metro package that isn't published properly

error Couldn't find any versions for "metro-cache" that matches "0.46.0"
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Error: Couldn't find any versions for "metro-cache" that matches "0.46.0"
    at MessageError.ExtendableBuiltin (/opt/yarn-v1.9.4/lib/cli.js:243:66)
    at new MessageError (/opt/yarn-v1.9.4/lib/cli.js:272:123)
    at Function.<anonymous> (/opt/yarn-v1.9.4/lib/cli.js:51264:13)
    at Generator.next (<anonymous>)
    at step (/opt/yarn-v1.9.4/lib/cli.js:92:30)
    at /opt/yarn-v1.9.4/lib/cli.js:103:13
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
Exited with code 1
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sunnylqm sunnylqm mentioned this pull request Sep 25, 2018
Module @babel/runtime/helpers/interopRequireDefault does not exist in the Haste module map #21310
Closed
@kelset

kelset commented Sep 25, 2018

Copy link
Copy Markdown
Contributor

@janicduplessis I think it has been published now (or, at least, running npm view metro-cache says that 0.46.0 is out), could you re-trigger the CI (maybe via a new commit?).

woivreq and janicduplessis reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

matthargett
matthargett approved these changes Sep 25, 2018
View reviewed changes
@hramos hramos mentioned this pull request Sep 25, 2018
Fix RNTester build failure in CI #21304
Closed
facebook-github-bot
facebook-github-bot reviewed Sep 25, 2018
View reviewed changes

@facebook-github-bot facebook-github-bot left a comment

Copy link
Copy Markdown
Contributor

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@janicduplessis

janicduplessis commented Sep 25, 2018

Copy link
Copy Markdown
Contributor Author

This might conflict with 1323acd, I think @babel/runtime should be a dependency and not devDependency.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kelset

kelset commented Sep 26, 2018

Copy link
Copy Markdown
Contributor

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@facebook-github-bot facebook-github-bot closed this in 458d56c Sep 26, 2018
@react-native-bot

react-native-bot commented Sep 26, 2018

Copy link
Copy Markdown
Collaborator

@janicduplessis merged commit 458d56c into facebook:master.


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 master tag, it is not yet part of a release.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@react react locked as resolved and limited conversation to collaborators Sep 26, 2018
@react-native-bot react-native-bot added the Merged This PR has been merged. label Sep 26, 2018
grabbou pushed a commit that referenced this pull request Oct 2, 2018
@janicduplessis @grabbou
Remove global babelHelpers and regenerator (#21283)
5627616
Summary:
Follow up to react/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
aleclarson pushed a commit to aleclarson/react-native-macos that referenced this pull request Mar 26, 2019
@janicduplessis @aleclarson
Remove global babelHelpers and regenerator (#21283)
d94ba38
Summary:
Follow up to react/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: react/react-native#21283

Reviewed By: mjesun

Differential Revision: D10010963

Pulled By: rafeca

fbshipit-source-id: da5e23dd901f8f8940d46816b4fc9290d0e28c76
t-nanava pushed a commit to microsoft/react-native-macos that referenced this pull request Jun 17, 2019
@janicduplessis @facebook-github-bot
Remove global babelHelpers and regenerator (react#21283)
e787af1
Summary:
Follow up to react/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: react#21283

Reviewed By: mjesun

Differential Revision: D10010963

Pulled By: rafeca

fbshipit-source-id: da5e23dd901f8f8940d46816b4fc9290d0e28c76
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@hramos hramos Awaiting requested review from hramos
3 more reviewers
@newyankeecodeshop newyankeecodeshop newyankeecodeshop left review comments
@facebook-github-bot facebook-github-bot facebook-github-bot left review comments
@matthargett matthargett matthargett approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

8 participants

@janicduplessis @pull-bot @rafeca @kelset @react-native-bot @newyankeecodeshop @matthargett @facebook-github-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.