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

[Async] Enable async/await and update UIExplorer and tests #1765

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
5 participants
@ide
Collaborator

ide commented Jun 27, 2015

  • Enables async/await in .babelrc and transformer.js
  • Adds regenerator to package.json. Users still need to explicitly require the regenerator runtime -- this is so that you only pay for what you use.
  • Update AsyncStorage examples in UIExplorer to use async/await
  • Update promise tests in UIExplorer to use async/await in addition to the promise API

Test Plan: AsyncStorage demo in UIExplorer works as expected. UIExplorer tests pass.

ide added some commits Jun 24, 2015

[npm] Add the semver caret to package.json deps
The caret is standard for `npm --save` and makes it easier to get bugfixes from package maintainers.

As I understand it, Facebook pins the versions since the packages are manually downloaded. One issue with this is that the dependencies of dependencies aren't pinned so what probably makes the most sense for Facebook is to use `npm shrinkwrap` which recursively pins the versions of all dependencies. How this works is:

1. Someone at Facebook manually downloads the latest version of an npm package they want to use
2. They add the entry to package.json using the caret, ex: `"babel": "^5.6.5"`
3. They run `npm shrinkwrap` to generate npm-shrinkwrap.json so the exact versions of the packages are recorded and if you were to run `npm install` then it would know to get those specific versions (example npm-shrinkwrap.json: https://gist.github.com/ide/a2f6e6818802e39978d5)
4. package.json is synced out to GitHub but npm-shrinkwrap.json is not
5. External users run `npm install` and get the latest compatible versions of all packages

Test Plan: Ran UIExplorer and tested the Chrome debugger.
[Async] Enable async/await and update UIExplorer and tests
- Enables async/await in .babelrc and transformer.js
- Adds regenerator to package.json. Users still need to explicitly require the regenerator runtime -- this is so that you only pay for what you use.
- Update AsyncStorage examples in UIExplorer to use async/await
- Update promise tests in UIExplorer to use async/await in addition to the promise API

Test Plan: AsyncStorage demo in UIExplorer works as expected. UIExplorer tests pass.
@sophiebits

This comment has been minimized.

Show comment
Hide comment
@sophiebits

sophiebits Jun 30, 2015

Member

Naive question: is there a way we can have regenerator required automatically but only when you use async/await?

Member

sophiebits commented Jun 30, 2015

Naive question: is there a way we can have regenerator required automatically but only when you use async/await?

@ide

This comment has been minimized.

Show comment
Hide comment
@ide

ide Jun 30, 2015

Collaborator

@spicyj sort of -- Babel's "runtime" option says that it pulls in babel-runtime/regenerator only when needed. The thing is "runtime" also pulls in core-js which polyfills Map, Set, and other ES6 features that RN already polyfills (or that JSC already provides if you're targeting iOS 8+).

Collaborator

ide commented Jun 30, 2015

@spicyj sort of -- Babel's "runtime" option says that it pulls in babel-runtime/regenerator only when needed. The thing is "runtime" also pulls in core-js which polyfills Map, Set, and other ES6 features that RN already polyfills (or that JSC already provides if you're targeting iOS 8+).

@sahrens

This comment has been minimized.

Show comment
Hide comment
@sahrens

sahrens Jul 15, 2015

Contributor

AsyncStorage example looks good to me - @frantic, can you import and make sure everything else works internally?

Contributor

sahrens commented Jul 15, 2015

AsyncStorage example looks good to me - @frantic, can you import and make sure everything else works internally?

@@ -45,36 +45,37 @@
"react-native-start": "packager/packager.sh"

This comment has been minimized.

@frantic

frantic Jul 16, 2015

Contributor

are changes in this file related?

@frantic

frantic Jul 16, 2015

Contributor

are changes in this file related?

This comment has been minimized.

@ide

ide Jul 16, 2015

Collaborator

Yeah -- Babel has this hack where it patches ast-types and I needed to update the dependencies in RN's package.json to get things working.

@ide

ide Jul 16, 2015

Collaborator

Yeah -- Babel has this hack where it patches ast-types and I needed to update the dependencies in RN's package.json to get things working.

@ide ide closed this in 47e1d1a Aug 13, 2015

@ide ide deleted the ide:my-body-is-ready branch Aug 27, 2015

cpojer pushed a commit to facebook/metro that referenced this pull request Jan 26, 2017

[Async] Enable async/await and update UIExplorer and tests
Summary:
- Enables async/await in .babelrc and transformer.js
- Adds regenerator to package.json. Users still need to explicitly require the regenerator runtime -- this is so that you only pay for what you use.
- Update AsyncStorage examples in UIExplorer to use async/await
- Update promise tests in UIExplorer to use async/await in addition to the promise API

Closes facebook/react-native#1765
Github Author: James Ide <ide@jameside.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment