From c4e2d7a9190537806af8f9a2f12f681901417460 Mon Sep 17 00:00:00 2001 From: Charlie Croom Date: Thu, 8 Apr 2021 19:10:33 -0400 Subject: [PATCH] [change] Add generated Flow files to package dist Fix #1684 Close #1982 --- package.json | 2 ++ .../docs/getting-started/multi-platform.md | 4 ++- packages/react-native-web/src/index.js | 1 + yarn.lock | 35 +++++++++++++++++-- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 5daa8f713..7c0a67406 100644 --- a/package.json +++ b/package.json @@ -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 -", @@ -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", diff --git a/packages/docs/src/pages/docs/getting-started/multi-platform.md b/packages/docs/src/pages/docs/getting-started/multi-platform.md index 10629b41a..949752bd7 100644 --- a/packages/docs/src/pages/docs/getting-started/multi-platform.md +++ b/packages/docs/src/pages/docs/getting-started/multi-platform.md @@ -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' ``` diff --git a/packages/react-native-web/src/index.js b/packages/react-native-web/src/index.js index 7487e823a..c7d8aacb1 100644 --- a/packages/react-native-web/src/index.js +++ b/packages/react-native-web/src/index.js @@ -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'; diff --git a/yarn.lock b/yarn.lock index 622c25c53..9dd5f65fb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" @@ -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== @@ -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" @@ -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" @@ -11492,7 +11523,7 @@ yargs@16.2.0: 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==