Commit Graph

1232 Commits

Author SHA1 Message Date
Jean Lauliac c1a2a5e942 packager: get rid of type `any` in ResolutionRequest
Summary:
One of my changeset broke the "ModuleGraph" code without warning earlier because we are using `any`, that equivalent to having no typing at all. This changeset fixes the types so that `ResolutionRequest` is exactly what it actually is: a class usable for any `Module`-looking class, including the normal one, and the "ModuleGraph" one used for Buck builds. That way, the ModuleGraph's `Module` is typechecked against `Moduleish`.

Concretely this change mostly migrates the `Module` to its generic parameter counterpart `TModule` inside `ResolutionRequest`.

Reviewed By: kentaromiura

Differential Revision: D4826256

fbshipit-source-id: fcd7ca08ac6c35e4e9ca983e2aab260e352bcb4e
2017-04-04 07:07:33 -07:00
Jean Lauliac fc8c5130be packager: GlobalTransformCache: retry 502 and 503 HTTP statuses
Reviewed By: davidaurelio

Differential Revision: D4818997

fbshipit-source-id: b31b004939f9e83c8a3a8c34b07c8b1ae2d4d17e
2017-04-04 04:07:41 -07:00
David Aurelio 6bdc5e9f21 Adapt interface of node-haste duplicates
Summary: Adapts mocked / duplicated functionality from `node-haste` to match the new synchronous return types in the original.

Reviewed By: jeanlauliac

Differential Revision: D4819137

fbshipit-source-id: 183316adc3fae161ad9999bf72bccb8218ef8941
2017-04-03 10:07:44 -07:00
David Aurelio 015700ea7c Fix file indentation
Reviewed By: jeanlauliac

Differential Revision: D4819078

fbshipit-source-id: 76bdc2381e479396ef11144236817ffd590f1039
2017-04-03 08:51:45 -07:00
Mike Grabowski 850ed35845 Make CLI executable configurable
Summary:
Follow up to #13248 for iOS.

This pull request allows changing the default path to `cli` when running from Xcode environment. That is especially useful when debugging from a different location or... running `Haul`.

Set `export CLI_PATH=./node_modules/react-native/local-cli/cli.js` and run. Should use new path provided.
Closes https://github.com/facebook/react-native/pull/13264

Differential Revision: D4819059

Pulled By: ericvicenti

fbshipit-source-id: 4a6241823c0bc8f1fa16869bc872bdbe04df510f
2017-04-03 08:37:49 -07:00
Jean Lauliac a6bcbd61e6 packager: TransformCache: use sha1 instead of murmurhash
Reviewed By: davidaurelio

Differential Revision: D4809941

fbshipit-source-id: 33b6c56b4c48eca88d8c1922f52ed29a728d1173
2017-04-03 05:51:32 -07:00
Jean Lauliac 83e38fe2ca packager: TransformCache: do not rehash transformOptions every single time
Reviewed By: davidaurelio

Differential Revision: D4809963

fbshipit-source-id: 9d3ac907e822596567ee7af4427bcd24f1bac73f
2017-04-03 04:51:51 -07:00
Tim Yung 5ded44cdc1 RN: Options to Preload Bundles on Startup
Reviewed By: achen1

Differential Revision: D4809513

fbshipit-source-id: a9a4196b72b241faf7c788e26b9e6880cecebb3e
2017-04-02 08:38:53 -07:00
Jean Lauliac 87c7e781a2 packager: sync Module#read()
Reviewed By: davidaurelio

Differential Revision: D4802783

fbshipit-source-id: c6309bcae6ad48bea2350de04353f694be6eea2f
2017-03-31 10:21:36 -07:00
Brent Vatne b9bfe3b85d Move packager initialization events to reporter
Summary:
This PR depends on #13172

Packager events are mostly logged through the TerminalReporter by default (#13172 makes this configurable). But there are a few things that aren't passed through TerminalReporter.

- We [log a banner with some information about the port and what's going on](8c7b32d5f1/local-cli/server/server.js (L22-L32))
- Also [a message about looking for JS files](8c7b32d5f1/local-cli/server/server.js (L34-L38)) (not sure what that is for / if it is useful beyond telling the user what directory root they started the packager in, but that's another thing).
- If the packager fails to start, then [we log an error message](8c7b32d5f1/local-cli/server/server.js (L41-L61)).

This pull request changes those log messages to be handled by TerminalReporter. I tri
Closes https://github.com/facebook/react-native/pull/13209

Differential Revision: D4809759

Pulled By: davidaurelio

fbshipit-source-id: 2c427ec0c1accaf54bf6b2d1da882cd6bfaa7829
2017-03-31 02:22:24 -07:00
Pieter De Baets 67fbd61ebf Remove RelayFBPreloadedModules, error on overlapping modules
Reviewed By: davidaurelio

Differential Revision: D4779671

fbshipit-source-id: f2dfeb696baab457769c22ca7ab28972270e5fc0
2017-03-30 16:36:51 -07:00
Jean Lauliac 6b89f0ac28 packager: GlobalTransformCache: retry keys fetches
Reviewed By: davidaurelio

Differential Revision: D4779641

fbshipit-source-id: 1b156bf075fa2456d9e6b1a3f38855357abc1abb
2017-03-28 10:51:45 -07:00
Jean Lauliac f2340c746b packager: ResolutionRequest.js: resolveDependency() now sync
Reviewed By: davidaurelio

Differential Revision: D4763593

fbshipit-source-id: b3dc95229d040c776833a88c9a156b9168e0cc4c
2017-03-27 09:51:48 -07:00
Jean Lauliac 62c07e39dc packager: ResolutionRequest.js: sync _resolveNodeDependency()
Summary: Moar synchronicity.

Reviewed By: davidaurelio

Differential Revision: D4756495

fbshipit-source-id: 4e0758ba8b55bd25a24d79dcc8ac4ace101e2ae8
2017-03-27 09:51:48 -07:00
Tim Yung 4d9826eb64 RN: Cleanup Flow / Jest / Metro Configs
Reviewed By: kassens

Differential Revision: D4777088

fbshipit-source-id: d07f4d1dd019a814c8bee4caeb57fc1dd3721c27
2017-03-26 16:08:57 -07:00
Lee Byron 81af8f341f Move classic relay into oss packages
Reviewed By: kassens

Differential Revision: D4769497

fbshipit-source-id: 0144456a82c3969b399a4a0b37814b5627d191c5
2017-03-24 11:23:51 -07:00
Jean Lauliac 1b898cba22 packager: TerminalReporter: stop reporting global cache errors
Summary: At FB we log errors into the error infra, and these errors are not actionnable for end users, so let's reduce the noise generated on the terminal. In the OSS case, people can simply add a handler in a TerminalReporter decorator, the same way we do internally (anyhow, I do not know of anyone using the global cache in OSS for now).

Reviewed By: davidaurelio

Differential Revision: D4762858

fbshipit-source-id: 880c02e175ae551df11b7ce273acc318222c46bf
2017-03-23 12:37:58 -07:00
Jean Lauliac a9589df976 packager: ResolutionRequest.js: sync _resolveHasteDependency()
Summary: Some more synchronicity, one step at a time.

Reviewed By: davidaurelio

Differential Revision: D4756542

fbshipit-source-id: 0c56dbca61b3da764aa8d28e29c0e20b54de091e
2017-03-23 11:09:38 -07:00
Jean Lauliac aec6307c4c packager: ResolutionRequest.js: sync _resolveFileOrDir
Reviewed By: davidaurelio

Differential Revision: D4754138

fbshipit-source-id: d19792a726220a673dead1c8c6cdf487e34a6808
2017-03-23 11:09:38 -07:00
Jean Lauliac 25c82f2e8c packager: ResolutionRequest.js: _loadAsDir and _loadAsFile sync
Reviewed By: davidaurelio

Differential Revision: D4754090

fbshipit-source-id: 84ad1d988bf097d3094d90f3738ce64cc523879c
2017-03-23 11:09:37 -07:00
Jean Lauliac 9bd757822e packager: Module.js: cover the error cases
Summary: We want any exception thrown by `_getHasteName` to be captured by the promise instead of breaking the outer stack.

Reviewed By: davidaurelio

Differential Revision: D4754825

fbshipit-source-id: 173c7c8867da73efb198ed3159704d6fd0e7b87d
2017-03-22 12:08:50 -07:00
Jean Lauliac ba88046c24 packager: Package.js: cover the error cases
Summary: In case the sync function throws, it wouldn't be handled through the promise anymore, that is not what we want. So we revert that in this changeset.

Reviewed By: davidaurelio

Differential Revision: D4754740

fbshipit-source-id: 4da360f4b629bbdf9cd284389060429cc9259c2c
2017-03-22 11:51:48 -07:00
Jean Lauliac 51b44a5b52 packager: Module.js: make read()-based API sync
Reviewed By: davidaurelio

Differential Revision: D4746218

fbshipit-source-id: 1a36bd00a47a6b871cc77433b2325a11e90035b2
2017-03-22 08:33:58 -07:00
Jean Lauliac ebd732784b packager: Package.js: make read()-based API sync
Reviewed By: davidaurelio

Differential Revision: D4745885

fbshipit-source-id: 3d327e5ca91fcbe7ec1d30ff8e6135b415074aa4
2017-03-22 07:05:35 -07:00
Jean Lauliac fc95a312b9 packager: GlobalTransformCache-test: disable non-deterministic test
Reviewed By: davidaurelio

Differential Revision: D4751434

fbshipit-source-id: 1be748387abe9ca0ce030bd2423827dfe5c2a146
2017-03-22 06:21:49 -07:00
Brent Vatne e3daf33ed8 Lock version to 2.7.5 to avoid breakage like #12772
Summary:
As per uglify-js maintainer kzc's comment in https://github.com/mishoo/UglifyJS2/issues/1573#issuecomment-284940371 we should be locking our version to prevent issues like #12772 from happening again.

No test plan needed, people are already using this version of uglify-js (it's the latest).
Closes https://github.com/facebook/react-native/pull/12802

Differential Revision: D4749853

Pulled By: javache

fbshipit-source-id: 866a19cb2c1add31b55e14d0f4dadb7f68fda64c
2017-03-22 05:53:50 -07:00
Jean Lauliac 28952d2475 packager: clear cache
Reviewed By: davidaurelio

Differential Revision: D4746429

fbshipit-source-id: 1a49a4b6db75658749346f0fd94dad68ff084203
2017-03-21 11:38:20 -07:00
Jean Lauliac 7357a916c3 packager: GlobalTransformCache: reduce asynchronicity for non-cached bundles
Reviewed By: davidaurelio

Differential Revision: D4745595

fbshipit-source-id: 3126fdcc11dd1c8085316457ead0cabae633d0db
2017-03-21 06:06:11 -07:00
Jean Lauliac 112a177399 packager: GlobalTransformCache: ignore errors related to fetching
Reviewed By: davidaurelio

Differential Revision: D4745584

fbshipit-source-id: 2c9b2451d3525c90308fb88784945462cd827d1f
2017-03-21 06:06:11 -07:00
Jean Lauliac 2a9b50c529 packager: GlobalTransformCache: add unit test
Summary: Finally adding some unit test to increase confidence in the correctness of that piece of code.

Reviewed By: davidaurelio

Differential Revision: D4721543

fbshipit-source-id: 56776290d61f2b51c69d7eeae09663e3bc892b50
2017-03-21 06:06:11 -07:00
Marc Horowitz 2bec70bf7d Don't swallow the error if a module require fails
Reviewed By: davidaurelio

Differential Revision: D4733269

fbshipit-source-id: 2cca14c023b148b62cf24f204cdb355f8d2f3590
2017-03-20 13:05:58 -07:00
David Aurelio e5197e940e Use verbose module name when requiring module that errored
Summary: When requiring a module that has previously errored, the implementation of `require` only used the numerical module ID. In this diff, we enable usage of the verbose module name if present.

Reviewed By: bestander

Differential Revision: D4737723

fbshipit-source-id: 1c2d3906435a637f3e440e57f904489d84495bd2
2017-03-20 08:27:00 -07:00
David Aurelio f19e5215cf Allow flow-declared variables when inlining
Summary: The logic of the `inline` babel transform regarded identifiers as global if no binding exists for them. We extend that logic to also accept flow-declared variables.

Reviewed By: arcanis

Differential Revision: D4737620

fbshipit-source-id: e71cfdf77c7b7751265cfa4412430b4f29e9e853
2017-03-20 08:09:09 -07:00
David Aurelio 80faeb9034 Fix indentation of polyfills/require.js
Summary: Fixes the messed-up indentation of `polyfills/require.js`. Over half of the lines were indented with an odd number of spaces.

Reviewed By: arcanis, bestander

Differential Revision: D4737435

fbshipit-source-id: a5b9baf0a27f236a4d3d6b6c1c5a92f52859f62c
2017-03-20 05:36:30 -07:00
Kevin Cooper bbd4669180 Fix suggestion to "npm start -- --reset-cache"
Summary:
As discussed in https://github.com/facebook/react-native/pull/11983. The double dash is necessary to pass through the argument to node. Based on the comments [here](https://github.com/facebook/react-native/issues/1924#issuecomment-249861004), it looks like most people use the double dash; it's unclear whether it would do anything at all if the dashes were omitted. If anyone else has better insight, let me know!
Closes https://github.com/facebook/react-native/pull/13003

Differential Revision: D4731566

Pulled By: hramos

fbshipit-source-id: 62562536db7589a03a511762117cbf0e36d3aafb
2017-03-18 12:58:05 -07:00
Jean Lauliac b6ebb8010e packager: DependencyGraph-test: add broken use case
Summary:
This changeset adds a test that verifies that the duplicate modules use case is broken. The goal is to acknowledge the problem for now, and when we update `jest-haste`, we'll simply fix what needs to be fixed in that test.

See also, https://github.com/facebook/jest/pull/3107

Reviewed By: davidaurelio

Differential Revision: D4673431

fbshipit-source-id: 05e09bdf61a2eddf2e9d1e32a33d32065c9051f1
2017-03-16 13:51:54 -07:00
Jean Lauliac e3274bdef3 packager: FBGlobalTransformCache: move the retry/error logic
Reviewed By: davidaurelio

Differential Revision: D4713585

fbshipit-source-id: 6a83f858692b8a1f6326051f3a3f4a3a549e4027
2017-03-16 13:51:43 -07:00
Jean Lauliac 62d4c6e275 packager: GlobalTransformCache: finish conversion to async/await
Reviewed By: davidaurelio

Differential Revision: D4713456

fbshipit-source-id: f65c45439d1657872e28a296f13a73ee2032ea93
2017-03-16 09:23:39 -07:00
Jean Lauliac 457966760a packager: Resolver/polyfills/require: fix nit error message
Reviewed By: davidaurelio

Differential Revision: D4713066

fbshipit-source-id: 35f09ded85472191a3f1c36b5879acee55c60b8b
2017-03-15 07:52:05 -07:00
Jean Lauliac 737bf8cffe packager: attachHMRServer.js: Flow
Summary:
The breakage fixed by changeset [1] could have been identified earlier if we had typing on `attachHMRServer`, so I spent some time on that. This has revealed in turn a few functions across the codebase that were incorrectly typed, and that are now fixed.

[1] packager: attachHMRServer.js: fix callsite of Server#getModuleForPath()

Reviewed By: davidaurelio

Differential Revision: D4706241

fbshipit-source-id: fc4285245921ae45d5781a47d626fc0559dba998
2017-03-15 06:18:00 -07:00
Liu Zhanhong d8bd24fc39 BREAKING: Remove @provides support from packager
Summary:
see d82f2553fb
Closes https://github.com/facebook/react-native/pull/12355

Differential Revision: D4710001

Pulled By: davidaurelio

fbshipit-source-id: 1c2225fa3bd2881c3eaedfd02514c29b920948b6
2017-03-14 19:25:07 -07:00
David Aurelio 300fa5b723 Update worker to match command line args passed by Buck
Reviewed By: cpojer

Differential Revision: D4673955

fbshipit-source-id: 1886cef97a96efbe0e90b02b98f03544d5f3f155
2017-03-14 15:05:33 -07:00
Alexey Lang 4a90d1178f Use performanceNow to calculate __BUNDLE_START_TIME__
Reviewed By: javache

Differential Revision: D4706142

fbshipit-source-id: aa983d9e5d5324f97ae34ec0190b1fc988d012c8
2017-03-14 13:54:38 -07:00
Jean Lauliac 79c488b9f7 packager: fix buildBundle() options
Summary: The problem with `bundleOpts` is that it discards Flow typing, so it prevents reinforcing the integration of `Bundler` into `Server`. This changeset removes the `bundleOpts` to solve that issues. Instead, it makes the options explicit so that there is less uncertaintly. I love making options explicit, because they force callsites to take a consicious decision about what is really needed, making them more robust. They also expose oddities that probably needs refatoring, for example having a `resolutionRequest` in the bundle options does not seem correct, it should be an implementation details. Likewise, `onProgress` should probably be exposed differently, as it does not affect the content of the bundle itself.

Reviewed By: davidaurelio

Differential Revision: D4697729

fbshipit-source-id: d543870ba024e7588c10b101fa51429c77cc5ddc
2017-03-14 11:07:35 -07:00
Jean Lauliac 2f208f714a packager: react-packager.js: reinforce the typing at API boundary
Reviewed By: davidaurelio

Differential Revision: D4698256

fbshipit-source-id: 7a42e9b79744f599e92b5d3d91c41cdd0de2ece5
2017-03-14 11:07:34 -07:00
Jean Lauliac 915ab18d53 packager: Server: make buildBundle() async
Summary: Also remove the unnecessary await of the resolver, because `_bundler.bundle()` already does that.

Reviewed By: davidaurelio

Differential Revision: D4689448

fbshipit-source-id: 3b4fd73b1368f8b00c6eb7483e751387d9856ce9
2017-03-13 06:20:43 -07:00
Jean Lauliac bdacb9595b packager: Bundler: refactor the maxWorkerCount
Summary: The function giving the worker count was duplicated, let's just pass it down from a central place, the Bundler. Also, I simplified the function to use a simple formula rather than arbitrary ranges (it's still arbitrary, just a tad bit less :D ).

Reviewed By: davidaurelio

Differential Revision: D4689366

fbshipit-source-id: fe5b349396f1a07858f4f80ccaa63c375122fac8
2017-03-13 05:21:26 -07:00
Jean Lauliac 4e106d45c3 packager: verify validity of TTY before using it
Reviewed By: mkonicek

Differential Revision: D4689779

fbshipit-source-id: 9bc2c1447bd64ec392adef772b1189a782f83545
2017-03-10 10:51:34 -08:00
Jean Lauliac da94f5e5af packager: Resolver: remove opt defaults, simplify load()
Summary: Not having default everywhere (keeping them at the top level instead) makes for a code that is easier to understand, and more robust as different pieces of code cannot default to different values. This changeset also unifies the option types (ex. `platform`).

Reviewed By: cpojer

Differential Revision: D4688882

fbshipit-source-id: b5f407601386336f937a0ac1f68c666acc89dfd8
2017-03-10 08:36:24 -08:00
Jean Lauliac e1a2633f69 packager: node-haste: async load()
Reviewed By: cpojer

Differential Revision: D4673384

fbshipit-source-id: 816529f8947079b4003c8e91443e221184fd589d
2017-03-10 04:06:34 -08:00