Skip to content

Commit

Permalink
[change] Add generated Flow files to package dist
Browse files Browse the repository at this point in the history
Fix #1684
Close #1982
  • Loading branch information
comp615 authored and necolas committed Apr 20, 2021
1 parent 4e77aeb commit c4e2d7a
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"compile": "npm-run-all clean -p \"compile:* {@}\" --",
"compile:commonjs": "cd packages/react-native-web && cross-env BABEL_ENV=commonjs babel --root-mode upward src --out-dir dist/cjs --ignore \"**/__tests__\"",
"compile:es": "cd packages/react-native-web && babel --root-mode upward src --out-dir dist --ignore \"**/__tests__\"",
"compile:flow": "gen-flow-files packages/react-native-web/src --out-dir packages/react-native-web/dist",
"benchmarks": "cd packages/benchmarks && yarn dev",
"benchmarks:build": "cd packages/benchmarks && yarn build",
"benchmarks:release": "yarn benchmarks:build && git checkout gh-pages && rm -rf ./docs/benchmarks && mv packages/benchmarks/dist ./docs/benchmarks && git add -A && git commit -m \"Deploy benchmarks\" && git push origin gh-pages && git checkout -",
Expand Down Expand Up @@ -52,6 +53,7 @@
"eslint-plugin-react": "^7.22.0",
"eslint-plugin-react-hooks": "^4.2.0",
"flow-bin": "^0.148.0",
"gen-flow-files": "^0.4.11",
"glob": "^7.1.6",
"husky": "^4.3.8",
"inline-style-prefixer": "^6.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ module.exports = {

### Flow

[Flow](https://flow.org) can be configured to understand the aliased module. You may also need to include a custom libdef ([example](https://gist.github.com/paularmstrong/f60b40d16fc83e1e8e532d483336f9bb)) in your config.
[Flow](https://flow.org) can be configured to understand the aliased module and pull types from Reac Native Web's source code. To do this, you can alias the name as below. You will also need to tell flow to use the `module` field of RNW's `package.json` or it may not find the flow types.

```yml
[options]
module.system.node.main_field=module
module.system.node.main_field=main
module.name_mapper='^react-native$' -> 'react-native-web'
```

Expand Down
1 change: 1 addition & 0 deletions packages/react-native-web/src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @flow strict
export { default as unstable_createElement } from './exports/createElement';
export { default as findNodeHandle } from './exports/findNodeHandle';
export { default as processColor } from './exports/processColor';
Expand Down
35 changes: 33 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,14 @@
"@babel/helper-create-class-features-plugin" "^7.12.13"
"@babel/helper-plugin-utils" "^7.12.13"

"@babel/plugin-proposal-throw-expressions@^7.7.4":
version "7.12.13"
resolved "https://registry.npmjs.org/@babel/plugin-proposal-throw-expressions/-/plugin-proposal-throw-expressions-7.12.13.tgz#48a6e4a5988041d16b0a2f1568a3b518f8b6c1d4"
integrity sha512-zhItTJGy2xLYneBdOk9CeyuEXWJt9J+pwTEIDl+A/VKMCq6E9ij3l1RRuTYBwtktTO9bCcIfA4/+d0HibVWSEA==
dependencies:
"@babel/helper-plugin-utils" "^7.12.13"
"@babel/plugin-syntax-throw-expressions" "^7.12.13"

"@babel/plugin-proposal-unicode-property-regex@^7.12.13", "@babel/plugin-proposal-unicode-property-regex@^7.4.4":
version "7.12.13"
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.12.13.tgz#bebde51339be829c17aaaaced18641deb62b39ba"
Expand Down Expand Up @@ -746,7 +754,7 @@
dependencies:
"@babel/helper-plugin-utils" "^7.8.3"

"@babel/plugin-syntax-flow@^7.12.13":
"@babel/plugin-syntax-flow@^7.12.13", "@babel/plugin-syntax-flow@^7.7.4":
version "7.12.13"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-flow/-/plugin-syntax-flow-7.12.13.tgz#5df9962503c0a9c918381c929d51d4d6949e7e86"
integrity sha512-J/RYxnlSLXZLVR7wTRsozxKT8qbsx1mNKJzXEEjQ0Kjx1ZACcyHgbanNWNCFtc36IzuWhYWPpvJFFoexoOWFmA==
Expand Down Expand Up @@ -823,6 +831,13 @@
dependencies:
"@babel/helper-plugin-utils" "^7.8.0"

"@babel/plugin-syntax-throw-expressions@^7.12.13":
version "7.12.13"
resolved "https://registry.npmjs.org/@babel/plugin-syntax-throw-expressions/-/plugin-syntax-throw-expressions-7.12.13.tgz#bb02bfbaf57d71ab69280ebf6a53aa45ad4c3f1a"
integrity sha512-vbpx/IxHR3qqWEfYeiVLq4+RFj2F4GjsMzoXEx/YU/pgmTA6o7T92DQHWIeetg7msKQFnyG1PwmPLWMlAn+Fmg==
dependencies:
"@babel/helper-plugin-utils" "^7.12.13"

"@babel/plugin-syntax-top-level-await@^7.12.13", "@babel/plugin-syntax-top-level-await@^7.8.3":
version "7.12.13"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.12.13.tgz#c5f0fa6e249f5b739727f923540cf7a806130178"
Expand Down Expand Up @@ -5421,6 +5436,22 @@ gauge@~2.7.3:
strip-ansi "^3.0.1"
wide-align "^1.1.0"

gen-flow-files@^0.4.11:
version "0.4.11"
resolved "https://registry.npmjs.org/gen-flow-files/-/gen-flow-files-0.4.11.tgz#ace4934f529aa6a40c83337f21494ed6dc57ac4e"
integrity sha512-88WjoL6gaxTaJtSal6Nsw9LerVKRVjQEAJy330VOmCS1k+lu2h1HJEJyU9LhviaphZBNG088j6JigA6YiP0xGQ==
dependencies:
"@babel/core" "^7.7.5"
"@babel/generator" "^7.7.4"
"@babel/parser" "^7.7.5"
"@babel/plugin-proposal-throw-expressions" "^7.7.4"
"@babel/plugin-syntax-flow" "^7.7.4"
"@babel/traverse" "^7.7.4"
"@babel/types" "^7.7.4"
glob "^7.1.6"
mkdirp "^0.5.1"
yargs "^15.0.2"

gensync@^1.0.0-beta.1:
version "1.0.0-beta.1"
resolved "https://registry.yarnpkg.com/gensync/-/gensync-1.0.0-beta.1.tgz"
Expand Down Expand Up @@ -11492,7 +11523,7 @@ [email protected]:
y18n "^5.0.5"
yargs-parser "^20.2.2"

yargs@^15.3.1, yargs@^15.4.1:
yargs@^15.0.2, yargs@^15.3.1, yargs@^15.4.1:
version "15.4.1"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-15.4.1.tgz#0d87a16de01aee9d8bec2bfbf74f67851730f4f8"
integrity sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==
Expand Down

0 comments on commit c4e2d7a

Please sign in to comment.