Commit Graph

1037 Commits

Author SHA1 Message Date
Christoph Pojer 37b91a63c7 Fix flow errors
Reviewed By: davidaurelio

Differential Revision: D4619990

fbshipit-source-id: 80355b8f0d0c3f84691098a05cdf2ba136c4bf53
2017-02-27 14:04:57 -08:00
Gabe Levi 4a60be62bc Deploy v0.40.0
Reviewed By: yungsters

Differential Revision: D4612331

fbshipit-source-id: 3eaa2f99d3181227166064cbee29b9245401a775
2017-02-24 12:45:56 -08:00
Christoph Pojer 2a3fe0625d Fix a bunch of flow annotations
Reviewed By: jeanlauliac

Differential Revision: D4611846

fbshipit-source-id: c2fe468e34a3b1eba7fcd2596020aad136285363
2017-02-24 11:17:48 -08:00
Christoph Pojer cf627fbdac Fix typo in ResolutionRequest
Reviewed By: davidaurelio

Differential Revision: D4605569

fbshipit-source-id: 5cd942e35faa8c653c4b709edb026eac0636a32a
2017-02-23 10:46:05 -08:00
Bhuwan Khattar e11b9d832a Remove @providesModule from polyfills
Summary:
These are not modules and don't need a `providesModule` annotation.

`sed -i -e '/providesModule/d' packager/src/Resolver/polyfills/*.js`

Reviewed By: cpojer

Differential Revision: D4605374

fbshipit-source-id: 5045a9664bc105dab15936f408d373da8d9322fe
2017-02-23 09:16:16 -08:00
Jean Lauliac 4a4dddbfdc packager: node-haste: do not expose HasteMap
Reviewed By: davidaurelio

Differential Revision: D4598085

fbshipit-source-id: d993be8e3bdcfda018a898b4adb32b53c1f0a948
2017-02-23 03:46:10 -08:00
David Aurelio 3a1af41a5d Discard protocol, host, and port of URLs in bundle options
Summary:
HTTP request URLs don’t include protocol, host and port. Stack frames URLs, on the other hand, contain full URLs. These full URLs are used to get the correct bundle to build the source map from.

The method that creates option objects from URLs therefore now discards leading protocol, host and port to ensure that cached bundles can be reused for symbolication rather than triggering rebuilds.

Reviewed By: jeanlauliac, cpojer

Differential Revision: D4598077

fbshipit-source-id: 262df187bcdf7099011371e8b55ae692c6e1a942
2017-02-23 02:44:59 -08:00
Christoph Pojer 13edf6da2b Add dependencies to package.json
Summary:
I extracted all the dependencies (using jest-haste-map) and copied them from the package.json in react-native to RNP. There is some duplication here for now but we can later go back and remove the duplicated dependencies from react-native that aren't needed there.

I also removed a mock file that hasn't been in use for a long time.

Reviewed By: jeanlauliac

Differential Revision: D4598155

fbshipit-source-id: 850b6dfa6fc2eec138ebdd7208cd34bee21f7927
2017-02-22 11:33:04 -08:00
Jean Lauliac ac29f45679 packager: cleanup node-haste/index.js opts
Reviewed By: cpojer

Differential Revision: D4591599

fbshipit-source-id: d1906b0b9a80f173f2a07174304dabe30985a5bc
2017-02-22 04:00:06 -08:00
Jean Lauliac a7d3940de6 GlobalTransformCache: increase timeout
Reviewed By: davidaurelio

Differential Revision: D4589052

fbshipit-source-id: 7eaec58a196db7f89b3039afbda4620889c9bcef
2017-02-20 10:46:04 -08:00
Jean Lauliac 564126f2bf packager: BatchProcessor: use Promise for processBatch()
Reviewed By: cpojer

Differential Revision: D4572495

fbshipit-source-id: 4a18b6ae16ea588104c337f2085707be07609005
2017-02-20 08:45:21 -08:00
Jean Lauliac bac576c433 packager: BatchProcessor: use Promise for queue()
Reviewed By: cpojer

Differential Revision: D4572181

fbshipit-source-id: 34c3824f05efd93847df9ba5931b0735c6711c28
2017-02-20 08:45:19 -08:00
Jean Lauliac 1a5b56d070 packager: introducing async/await, return of the yarn
Summary:
The first time I tried to commit this changeset, it was causing many new packages to be installed, because the dependency would depend on newer versions that what we have installed. So, I had made a diff so upgrade all the babel packages. Unfortunately this caused some problem as the newer versions of Babel are more strict on some syntaxes. Of course, these have to be addressed, but I don't want this changeset to be coupled with Babel upgrades and the issues that arise from it.

So instead, I decided to install the slightly older version of the async-to-generator module. At first I tried with just doing:

    yarn add babel-plugin-transform-async-to-generator@6.16.0

But, `yarn` is stubborn: because this module depends on a caret version of `babel-helper-remap-async-to-generator`, it installs the very last version of it, that itself needs more recent versions of other Babel modules. So, instead, I add to install a slightly older version of the dependency manually, then then the plugin:

    yarn add babel-helper-remap-async-to-generator@6.16.0
    yarn add babel-plugin-transform-async-to-generator@6.16.0

This allows us to have a `yarn.lock` with only a minimal amount of changes, and uncouple this change from any Babel upgrades. Because we only have a few new modules, the `node_modules` folder also stays the same, 133M, and it gives us confidence this will not cause significant startup time regressions.

Reviewed By: cpojer

Differential Revision: D4578733

fbshipit-source-id: deb0f720b895b7196aaf432adec3e56f18663940
2017-02-20 08:45:18 -08:00
Jean Lauliac 8be2a27aab Revert D4559167: packager: introducing async/await
Differential Revision: D4559167

fbshipit-source-id: de887a737ad1d02ef07a431ee0713d0bad65eb85
2017-02-16 10:59:57 -08:00
Jean Lauliac 26304dacf1 packager: introducing async/await
Summary:
allow-large-files

By using async/await the code is (1) less nested, (2) more compact and (3) more robust (no exceptions running away, and much less risks of forgetting to call the callback/resolve, or mistakenly calling it twice). I now tend to think we could switch to it for all the callsites that are not in a perf-critical path.

I switched from 'request' to 'node-fetch' because 'request' has an annoying callback with 2 arguments. So it's simpler to use an interface that's (1) already returning a Promise and (2) that is becoming standard.

This changeset was a way for me to start experiment with introducing async/await in packager codebase, and it looks pretty good so far.

Reviewed By: cpojer

Differential Revision: D4559167

fbshipit-source-id: 89a328c5766c2ba890e9d0e67a81a38dac6cfc73
2017-02-15 13:47:52 -08:00
Jean Lauliac e56b5be904 packager: JSONReporter: expose errors correctly
Reviewed By: cpojer

Differential Revision: D4536721

fbshipit-source-id: d8969a42e844da809bd167cbc1bae2cb11f1db57
2017-02-10 09:30:08 -08:00
Jean Lauliac 57010d63b6 packager: cleanup build status reporting
Reviewed By: cpojer

Differential Revision: D4521560

fbshipit-source-id: 8943e179192522da5145e4f14f0b648d3548cc36
2017-02-09 04:20:41 -08:00
Christoph Pojer fc60f5948a Change `transformCacheKey` to `getTransformCacheKey`
Reviewed By: jeanlauliac

Differential Revision: D4506459

fbshipit-source-id: cd42cb4f09c0130d08c27e3a097710b91c5dc6ba
2017-02-09 04:03:17 -08:00
Christoph Pojer a4d7a7835f Remove baseTransformer
Reviewed By: jeanlauliac

Differential Revision: D4506124

fbshipit-source-id: 642f06dffe4ea710113e8e8426915bf1b40d4611
2017-02-09 04:03:17 -08:00
Jhen ee6adf817e Fix resolveNodeDependency for Windows
Summary:
Related to https://github.com/zalmoxisus/remote-redux-devtools/issues/62, we got the wrong resolved path on Windows, should use `path.sep` instead of `'/'`.
Closes https://github.com/facebook/react-native/pull/12206

Differential Revision: D4513338

fbshipit-source-id: 17814920986d091a6c6deae648f951f7be1cb688
2017-02-07 12:45:50 -08:00
Alexey Kureev f30ab35e92 Add default option for Platform.select
Summary:
satya164 asked me to take over fixes for [this PR](https://github.com/facebook/react-native/pull/11608), so here we go!
Closes https://github.com/facebook/react-native/pull/12218

Differential Revision: D4515285

Pulled By: davidaurelio

fbshipit-source-id: 8987c518401fc67093dfe93bbbb63b934c20f6f9
2017-02-07 04:30:16 -08:00
Jean Lauliac 75c14e3674 packager: fix uncaught rejection
Summary: I figured out that the uncaught rejection that happens on transform error originated from a "fork" along the chain, where we both "then" on a promise, and return that promise. In that case Node.js, legitimately I think, identifies this as an uncaught rejection case. One solution, in this changeset, is to do the side-effects as part of the promise chain instead of "forking". Another option would be to add an explicit error handler to the additional "then", but it seems we don't have to handle that case here.

Reviewed By: davidaurelio

Differential Revision: D4515592

fbshipit-source-id: 17d813cfdbc76685b6273b8d94e97d948fd68674
2017-02-06 11:01:11 -08:00
Bhuwan Khattar d8694a258f refactor Module.js
Reviewed By: davidaurelio

Differential Revision: D4507868

fbshipit-source-id: 8b845bf8a484f494af1900eaf36454a8f3f78a9f
2017-02-06 08:28:36 -08:00
Bhuwan Khattar 4e96b3aec5 Random @providesModule related fixes
Reviewed By: jeanlauliac

Differential Revision: D4507885

fbshipit-source-id: 34d1a7be26febf7d93b65ba8fff635ab44e6459d
2017-02-06 07:58:40 -08:00
Jean Lauliac 242ced150c packager: reestablish changes reverted by d63f9c
Reviewed By: cpojer

Differential Revision: D4514889

fbshipit-source-id: de5d1350cbcea7a26395e532fefd78a816167b4a
2017-02-06 06:58:27 -08:00
Bhuwan Khattar d82f2553fb Replace @provides with @providesModule
Reviewed By: davidaurelio

Differential Revision: D4494624

fbshipit-source-id: 192cc77126a99b3a3baeb806ed605c2194c4713a
2017-02-02 08:58:33 -08:00
Christoph Pojer a2c84d14ce Remove `react-packager` indirection.
Summary:
This moves the `src` directory one level up and removes the `react-packager` folder. Personally, I always disliked this indirection. I'm reorganizing some things in RNP, so this seems to make sense.

Not sure if I forgot to update any paths. Can anyone advice if there are more places that need change?

Reviewed By: jeanlauliac

Differential Revision: D4487867

fbshipit-source-id: d63f9c79d6238300df9632d2e6a4e6a4196d5ccb
2017-02-02 05:44:15 -08:00
Jean Lauliac fd1a1325f3 packager: JSTransform cleanup: remove options object
Summary: We can simplify as there's only one option, and it seems to me we can also make it required, as otherwise the `JSTransformer` is essentially doing nothing. I don't believe we still have use cases where no transform happens at all, even in OSS?

Reviewed By: davidaurelio

Differential Revision: D4481723

fbshipit-source-id: b2e3830b206d56242d298ff3a7b5f4587ecfd29a
2017-01-31 05:28:35 -08:00
Jean Lauliac b6f494c313 packager: JSTransform cleanup: remove opts.methods
Summary: It's not used from any callsite as far as I can see.

Reviewed By: davidaurelio

Differential Revision: D4481708

fbshipit-source-id: 2c503fb7ef20f9370a950c315832f3ace4709739
2017-01-31 03:58:42 -08:00
Jean Lauliac 7bc25f5ece packager: JSTransform cleanup: remove opts.worker
Summary: it's not used from any callsite as far as I can see.

Reviewed By: davidaurelio

Differential Revision: D4481699

fbshipit-source-id: 4cf63ef7953d6cfc58e7ef4f22ecb99bf51e76a0
2017-01-31 03:58:42 -08:00
Jean Lauliac a10824c9c7 packager: JSTransform cleanup: remove transformTimeoutInterval
Summary: It's not used in any callsite.

Reviewed By: cpojer

Differential Revision: D4481683

fbshipit-source-id: 3fa55693f5f56b4fb6c455ad77d7780f69be81a9
2017-01-31 03:58:42 -08:00
Jean Lauliac a28f1536c8 packager: json reporter
Summary: The idea is to make it easier to interact with tools consuming the packager's output. For example, Nuclide. Do you think that'd work well?

Reviewed By: davidaurelio

Differential Revision: D4482041

fbshipit-source-id: 6c64d7963195a4d786ed8902640f9e9f279f5f83
2017-01-31 03:58:42 -08:00
Jean Lauliac bf930e473a packager: simplify ScribeLogger-test
Reviewed By: cpojer

Differential Revision: D4481570

fbshipit-source-id: 27beae850806d8d7f526a3196b2962a18e514007
2017-01-30 07:43:31 -08:00
Jean Lauliac abf75fa23c packager: add utilities to log errors internally
Reviewed By: davidaurelio

Differential Revision: D4468471

fbshipit-source-id: 10deb5014d06e4d3bb9d3122eef362c09f74d044
2017-01-27 11:13:27 -08:00
Jean Lauliac 5af697b3bb packager: backticks for module names
Reviewed By: cpojer

Differential Revision: D4468850

fbshipit-source-id: 281064a81ff1262094711f4e800effcd17fb7e4d
2017-01-26 10:43:31 -08:00
Jean Lauliac 48b86022fb packager: remove rogue terminal.log()
Reviewed By: cpojer

Differential Revision: D4468825

fbshipit-source-id: 29320f50cabc6002401e470a9ac278e9cb6673d3
2017-01-26 10:43:31 -08:00
Jean Lauliac 3ab9137b9e packager: add BatchProcessor-test
Reviewed By: davidaurelio

Differential Revision: D4468735

fbshipit-source-id: 8d20b44ef20aa24e72cd53182dbc34139a10df41
2017-01-26 09:43:32 -08:00
Jean Lauliac a9dbe6a439 packager: server/runServer.js: @flow
Reviewed By: davidaurelio

Differential Revision: D4462611

fbshipit-source-id: 22f4cc299e2a30fe260dbe8d4c67323ceb8178e8
2017-01-26 03:43:33 -08:00
Jean Lauliac 50168b7d6e packager: server/server.js: @flow
Reviewed By: davidaurelio

Differential Revision: D4462520

fbshipit-source-id: dc08aef691a78acb571a4da8038343184019d09f
2017-01-26 03:43:33 -08:00
Jean Lauliac be490d2f0c Backed out changeset 35b573bece59
Reviewed By: davidaurelio

Differential Revision: D4461681

fbshipit-source-id: f5c45f713f2fe68443986a2822aa325b01dd5075
2017-01-26 03:43:33 -08:00
Liu Zhanhong 0623a47ecd Sync with Resolver/polyfills/require.js
Summary:
I don't know which version is better, but it should sync with `Resolver/polyfills/require.js: 168`
```js
    // keep args in sync with with defineModuleCode in
    // packager/react-packager/src/Resolver/index.js
    // and packager/react-packager/src/ModuleGraph/worker.js
    factory(global, require, moduleObject, exports, dependencyMap);
```
Closes https://github.com/facebook/react-native/pull/12033

Differential Revision: D4461635

Pulled By: davidaurelio

fbshipit-source-id: 1a17e6cbac5525dc09609b658bef82a23574b00c
2017-01-25 03:58:30 -08:00
Jing Chen 7cb5b6e523 Revert stacked revisions on packager that causes packager to instacrash
Reviewed By: fkgozali, bestander

Differential Revision: D4456911

fbshipit-source-id: 35b573bece59c59c0700ef2d8ab26c0b7150d3cf
2017-01-24 11:43:36 -08:00
David Aurelio a116dbf4a4 Add tests for source map generator
Summary: This adds test for our high-perf source map generator.

Reviewed By: cpojer

Differential Revision: D4455547

fbshipit-source-id: 293bfe09c9c020259ae3daa4fa52f829248cca3c
2017-01-24 08:58:42 -08:00
Jean Lauliac f8b37b7d24 packager: extract BatchProcessor module
Reviewed By: davidaurelio

Differential Revision: D4449820

fbshipit-source-id: f54e6dd53ba4d211694e0bdc955af846d25778b8
2017-01-24 03:43:36 -08:00
Jean Lauliac 7b6272c952 packager: move error handling from Module to GlobalTransformCache
Reviewed By: davidaurelio

Differential Revision: D4449685

fbshipit-source-id: 4f57cfe132036f476e36933bd2ffcb9f23c42ccc
2017-01-24 03:43:36 -08:00
Jean Lauliac ccf94aa65a packager: GlobalTransformCache: remove global variable
Reviewed By: davidaurelio

Differential Revision: D4449333

fbshipit-source-id: b9546b90d2fd5ddca9c1ee2719c6c454b60bdfa4
2017-01-24 03:43:36 -08:00
David Aurelio 2ab7988cbe add tests
Summary: Tests for things introduced over the last 10 weeks

Reviewed By: cpojer

Differential Revision: D4442404

fbshipit-source-id: cf7a14f237360fde083b7e2ffcd9d70aafd0ced6
2017-01-23 03:58:24 -08:00
Radek Czemerys f521e992cc Fix typo in ResolutionRequest.js
Summary:
Small fix:
Fix typo in error message - should be `npm start --reset-cache`
Closes https://github.com/facebook/react-native/pull/11983

Reviewed By: AsyncDBConnMarkedDownDBException

Differential Revision: D4443749

Pulled By: hramos

fbshipit-source-id: eeaa531180c58a85df482fe3162b2a0b2169c891
2017-01-20 17:43:27 -08:00
David Aurelio cec787563a amend babel definitions to allow inline plugins without configuration
Summary: Updates babel flow defs to allow for inline plugins without configuration arguments.

Reviewed By: jeanlauliac

Differential Revision: D4442217

fbshipit-source-id: 1b4392bf13977d97984c72cff65b28e62f602300
2017-01-20 10:43:29 -08:00
David Aurelio 3b3d294a6b Even faster source map generation
Summary:
This replaces a polymorphic method with three separate methods that support the different used invocations.

In isolation, this leads to a 25% speedup.

Shoutout to trueadm for teaching me about this.

Reviewed By: trueadm

Differential Revision: D4436781

fbshipit-source-id: 3dce83556debf19d5305c4566a56b9e9565e85bc
2017-01-20 07:13:26 -08:00
Gabe Levi e2ce98b7c6 Fix the suppress comment regex for react_native
Reviewed By: davidaurelio

Differential Revision: D4435640

fbshipit-source-id: c680aee6931979859f04c0dca47037ba6f6cba73
2017-01-19 10:28:28 -08:00
Gabe Levi a4bfac907e Deploy v0.38.0
Reviewed By: jeffmo

Differential Revision: D4428858

fbshipit-source-id: 10dc69349a2b563e1fa444a8b0612e3b2d4ccd1c
2017-01-18 11:13:30 -08:00
David Aurelio 09072b9d77 Fix loading minified bundle over HTTP
Summary: Sets `generateSourceMaps` to true when requesting a bundle in non-dev mode or minified.

Reviewed By: bestander, cpojer

Differential Revision: D4415492

fbshipit-source-id: 9b4dcbd577a535dab143bb7a067210fbd831bf1a
2017-01-13 10:43:27 -08:00
David Aurelio 9a4e4e8ee8 Fix packager breakages on node4
Summary:
This fixes issues that only surface when running with node4 / npm2.
Closes https://github.com/facebook/react-native/pull/11888

Differential Revision: D4415021

Pulled By: bestander

fbshipit-source-id: 8672cd892c9dae41cc7b5b7b3227eb24dd780d22
2017-01-13 09:28:41 -08:00
Andrew Imm 09a83f976e Allow project-specific config for RN CLI using providesModuleNodeModules
Reviewed By: davidaurelio

Differential Revision: D4409046

fbshipit-source-id: 5af0d08542935a784f4737653ccac49fd7517aff
2017-01-12 21:13:36 -08:00
David Aurelio 0849f84df2 create better debuggable source maps
Summary:
Introduces a new mechanism to build source maps that allows us to use real mapping segments instead of just mapping line-by-line.

This mechanism is only used when building development bundles to improve the debugging experience in Chrome.

The new mechanism takes advantage of a new feature in babel-generator that exposes raw mapping objects. These raw mapping objects are converted to arrays with 2, 4, or 5 for the most compact representation possible.
We no longer generate a source map for the bundle that maps each line to itself in conjunction with configuring babel generator to retain lines.

Instead, we create a source map with a large mappings object produced from the mappings of each individual file in conjunction with a “carry over” – the number of preceding lines in the bundle.

The implementation makes a couple of assumptions that hold true for babel transform results, e.g. mappings being in the order of the generated code, and that a block of mappings always belongs to the same source file. In addition, the implementation avoids allocation of objects and strings at all costs. All calculations are purely numeric, and base64 vlq produces numeric ascii character codes. These are written to a preallocated buffer objects, which is turned to a string only at the end of the building process. This implementation is ~5x faster than using the source-map library.

In addition to providing development source maps that work better, we can now also produce individual high-quality source maps for production builds and combine them to an “index source map”. This approach is unfeasable for development source maps, because index source map consistently crash Chrome.

Better production source maps are useful to get precise information about source location and symbol names when symbolicating stack traces from crashes in production.

Reviewed By: jeanlauliac

Differential Revision: D4382290

fbshipit-source-id: 365a176fa142729d0a4cef43edeb81084361e54d
2017-01-12 14:28:41 -08:00
Jean Lauliac d12d0b4c53 packager: do not try to fetch uncached files
Reviewed By: davidaurelio

Differential Revision: D4403623

fbshipit-source-id: 8319e6bac365fe5fcebefd4f338faf145f662ecb
2017-01-12 10:43:32 -08:00
David Aurelio 7ca5316562 High-perf source map builder
Summary:
Adds a high performance source map builder that has certain restrictions compared to the `'source-map'` package:

- mappings have to be in the order of the generated source
- source files have to be started/ended separately on the generator. That means building up mappings is optimized for blocks of mappings that all belong to the same source file (or no file)

The implementation avoids allocation of complex value, i.e. strings and objects as much as possible by preallocating a buffer and using numeric character values throughout. The buffer is converted to a string only at the end.

This implementation is ~5✕ faster than using `'source-map'`.

Reviewed By: jeanlauliac

Differential Revision: D4392260

fbshipit-source-id: 406381302d951b919243a2b15e8bb75981e9f979
2017-01-09 11:43:28 -08:00
Jean Lauliac e2a5bc1a35 packager: socket timeout for global cache
Reviewed By: davidaurelio

Differential Revision: D4393059

fbshipit-source-id: 23c0c9ab69388ffd6de136d07728d44d1d8a947a
2017-01-09 11:13:32 -08:00
Jean Lauliac 4f60ac40fc packager: disable global cache stdout
Reviewed By: davidaurelio

Differential Revision: D4392486

fbshipit-source-id: bc1c33c781335b4af2d735596bbcdf7520312777
2017-01-09 10:13:33 -08:00
Jean Lauliac ff50420b0f packager: create the reporter higher in the stack
Reviewed By: davidaurelio

Differential Revision: D4392283

fbshipit-source-id: 4cd470ca0cbddcbb515407b5249272a758849b82
2017-01-09 10:13:33 -08:00
Jean Lauliac 8f87ab648c packager: remove validateOpts for Bundler class
Reviewed By: davidaurelio, cpojer

Differential Revision: D4380831

fbshipit-source-id: e3b5b2c39e83bf0b49028820e0f17daef27d7b3c
2017-01-06 06:13:54 -08:00
Jean Lauliac 446995306a packager: remove validateOpts for Server class
Summary: Remove the validateOpts() that prevents full Flow typing. In turn, having full Flow typing will allow us to remove 'defaults' across the codebase, that are source of inconsistencies.

Reviewed By: davidaurelio, cpojer

Differential Revision: D4377823

fbshipit-source-id: 8bb0a6b5069de64a9bb9d63892cd08854da91777
2017-01-06 06:13:54 -08:00
Jean Lauliac 207776107d packager: enable @flow in react-packager/index.js
Reviewed By: cpojer

Differential Revision: D4377411

fbshipit-source-id: 300d239d8e2818f0488549feafc98fd3451e452d
2017-01-06 06:13:54 -08:00
Jean Lauliac 28f1c67ced packager: centralize babelRegisterOnly callsites
Reviewed By: davidaurelio

Differential Revision: D4380987

fbshipit-source-id: db34e56b2025fb072798ef2cc3e52f3d1cb7c33c
2017-01-06 06:13:54 -08:00
Chris Hopman da59258372 Add --sourcemap-sources-root to RN packager
Reviewed By: davidaurelio

Differential Revision: D4357122

fbshipit-source-id: dc19474aa54ea4684a6b1c586a9d1e5da0980327
2017-01-04 20:58:33 -08:00
David Aurelio 78118d5023 Revamp debug logging
Summary:
- Switch namespace prefix from `ReactNativePackager:` to `RNP:`
- Add logging for handled requests
- Log transform cache key
- Add logging for transform cache hits/misses

Reviewed By: jeanlauliac

Differential Revision: D4377867

fbshipit-source-id: 9ec2060432f8c5e68561d3fe8ec7127f76c4a081
2017-01-04 07:13:32 -08:00
David Aurelio ea752b9655 Use `version` from `packager/package.json` for cache key
Reviewed By: jeanlauliac

Differential Revision: D4380910

fbshipit-source-id: 25d980bdf46046c3d53a4b2e120fd86a5534af6a
2017-01-04 06:58:35 -08:00
Jean Lauliac d54f702532 packager: enable @flow in node-haste types.js
Reviewed By: cpojer

Differential Revision: D4377132

fbshipit-source-id: 5a1c0fb34c85974135c326065fd0c54f44282286
2017-01-04 05:28:42 -08:00
Jean Lauliac 26a8da898d packager: AssetModule: @flow
Reviewed By: cpojer

Differential Revision: D4377137

fbshipit-source-id: 991619c0a42319a3bb4bf28dab4dd0fe1a474def
2017-01-03 09:58:35 -08:00
Jhen 2249af16b7 Fix the `path.sep` replacement of node-haste for Windows
Summary:
Fix the `path.sep` replacement for Windows, currently it just replace one segment:

```js
// Result: './lib/random\random-byte.js'
'./lib\\random\\random-byte.js'.replace(path.sep, '/')
```

Change to regex will work fine:

```js
// Result: './lib/random/random-byte.js' (correct)
'./lib\\random\\random-byte.js'.replace(new RegExp('\\' + path.sep, 'g'), '/')
```
Closes https://github.com/facebook/react-native/pull/11641

Differential Revision: D4368402

fbshipit-source-id: 46f456359d1cd2ca790881773e8a76af8616cd21
2016-12-27 14:43:32 -08:00
Chris Hopman a8affb838d make the RN packager output more deterministic
Reviewed By: davidaurelio

Differential Revision: D4357109

fbshipit-source-id: bc9ef04d81223299fe7708aeb0fe654647330ab7
2016-12-22 15:58:30 -08:00
Jean Lauliac 3d12ddb1db packager: TerminalReporter: properly reporting bundle updates
Reviewed By: cpojer

Differential Revision: D4357298

fbshipit-source-id: 89c70bb4bee103ad5a6301ac2b0c8712f190ba73
2016-12-21 05:58:32 -08:00
Jean Lauliac 04fdf40c61 packager: TerminalReporter: remove underline/emoji
Reviewed By: cpojer

Differential Revision: D4357225

fbshipit-source-id: 05d6b4fd9b79616a68e5fa3c4700aeac2f3552a9
2016-12-21 05:58:32 -08:00
Jean Lauliac efc12cd5bf packager: Fix typing of more Resolver options
Reviewed By: davidaurelio

Differential Revision: D4351879

fbshipit-source-id: aab3eb031ae3137d43d88ad1853aa7e6f5d165c5
2016-12-21 03:43:36 -08:00
Jean Lauliac b1132a91ab packager: Fix typing of Resolver options
Summary:
`declareOpts` is weakly typed. Since the callsite of Resolver constructor is itself flowifyed, we can get rid of `declareOpts`, and this provides us with much better typing.

Eventually I'd like to get rid of most of the defaults in the packager's inner code (ex. `watch` being false, `dev` being true). The reason is that defaults everywhere are prone to causing inconsistencies (for ex. some other code could have `dev` as false by default), problems that cannot be caught by Flow. Instead of having non-required options, I believe it is more sensible to provide helper functions that build sets of default options.

Reviewed By: davidaurelio, cpojer

Differential Revision: D4351874

fbshipit-source-id: 38653063f8939b4282c7c27cb6d5e3f3a25a9484
2016-12-21 03:43:36 -08:00
Connor McEwen ab89b7195d Fix babelHelpers.typeof is not a function
Summary:
We started encountering the error described in #5747 (`babelHelpers.typeof is not a function) after switching from npm to yarn. [This comment](https://github.com/facebook/react-native/issues/5747#issuecomment-192356656) led to [this comment](https://github.com/facebook/react-native/issues/4844#issuecomment-191282653) which contains a solution we've been using successfully in our production app.

Maybe I didn't look in the right place but it doesn't seem anyone had actually PR'd this change before (if so and I didn't find it, I apologize).

An alternative solution it seems is to add a [different .babelrc](http://stackoverflow.com/questions/35563025/new-react-native-app-has-typeerror-babelhelpers-typeof-is-not-a-function-ios), but this seems easier to me.
Closes https://github.com/facebook/react-native/pull/11093

Differential Revision: D4353977

fbshipit-source-id: 3e45de29ef5d0e046219a32df6530dcf838b9fd9
2016-12-20 15:28:29 -08:00
Jean Lauliac 2f1d1bdfe8 packager: Module: remove too-many-misses codepath
Summary:
This code is a bit sloppy, I need to rethink about it. So I prefer to remove it altogether for now.
The problem with this is that it is disabling the global cache "put" operations at the same time, so the script supposed to update the cache actually doesn't do the job past the fist few hundred files. This defeats the purpose of the global cache.

Reviewed By: cpojer

Differential Revision: D4346927

fbshipit-source-id: 5b668e66b1909f53783772c613781753ac605546
2016-12-20 03:13:32 -08:00
Jean Lauliac ede04abf8f packager: make output simpler, more legible
Reviewed By: cpojer

Differential Revision: D4339417

fbshipit-source-id: f174ee11bc220de5e8da1d8227e9a9ceb5319e8d
2016-12-19 10:58:32 -08:00
David Aurelio 2cc587f3f4 Improve source map quality when inserting numeric module IDs
Summary:
This changes the way that module identifiers are replaced with numeric ids so that ids are padded with spaces on the right to take up the same space as the original string literal.
By doing this, we keep the mappings for the generated source line intact.

```
// original source
const React = require('react');
// old replacement
const React = require(12 /* react */);
// new replacement
const React = require(12     ); // 12 = react
```

The remaining edge case are module names that are replaced with numeric IDs that are longer than the replaced string, e.g.:

```
const Q = require('q');
const Q = require(1234);
```

Reviewed By: cpojer

Differential Revision: D4346092

fbshipit-source-id: ef3bb879495f388c4a7448a2f810b83c204e8984
2016-12-19 06:13:29 -08:00
Cristian Carlesso a69b480cae Update RN to Jest 18
Reviewed By: cpojer

Differential Revision: D4335580

fbshipit-source-id: c48b6882b89aa20f9f58783b5a17edf94df22223
2016-12-19 04:43:30 -08:00
Alan Norbauer 4aabf4b6b3 Replace jest.resetModuleRegistry() with jest.resetModules()
Reviewed By: cpojer

Differential Revision: D4344961

fbshipit-source-id: 45453ec7ee3211743946ab9156f51430322b5832
2016-12-18 17:13:38 -08:00
David Aurelio 4308b9ea2c Add `deps` param to `js_library`
Reviewed By: cpojer

Differential Revision: D4334383

fbshipit-source-id: 96f0d6ba5ed8ddab25087edd6381a6e6449ff63a
2016-12-16 11:13:35 -08:00
Jay Caines-Gooby c93643c079 REACT_NATIVE_DIR needs quoting to retain spaces
Summary:
${REACT_NATIVE_DIR} needs to be quoted as "${REACT_NATIVE_DIR}" otherwise projects paths with spaces in, will fail to build.

e.g. a project in `/home/me/some folder` will fail to build with:

```
../node_modules/react-native/packager/react-native-xcode.sh: line 37: cd: /home/me/some: No such file or directory
```
Closes https://github.com/facebook/react-native/pull/11487

Differential Revision: D4336281

Pulled By: lacker

fbshipit-source-id: c5d19fbd21978714c7af44c305ba854477118e1d
2016-12-15 23:43:41 -08:00
Adam Miskiewicz 781480dc53 Resolve single flow error in node-haste
Summary:
Makes flow pass.
Closes https://github.com/facebook/react-native/pull/11465

Differential Revision: D4328094

Pulled By: ericvicenti

fbshipit-source-id: 5eb60831145ade00eb2d504f4958f0a683eef686
2016-12-15 00:28:31 -08:00
Jean Lauliac db63537eb5 packager: slightly more complete progress message.
Reviewed By: cpojer

Differential Revision: D4326391

fbshipit-source-id: 134e09f1db6e21165c4af78a9e1266d7f9d046c8
2016-12-14 10:13:29 -08:00
Jean Lauliac 1f07e89538 packager: don't keep on using global cache forever if it misses
Summary:
Keep track of the number of cache misses. If we have a series of misses but then we
start seeing hits, then we progressively reset the counter. If there are too many misses, we just give up on the global cache.

Reviewed By: cpojer

Differential Revision: D4326689

fbshipit-source-id: 5606fc860cbb9d7e9e877c0d1dc4e6a6a1cbcd98
2016-12-14 08:28:42 -08:00
Jean Lauliac 26ed94c0fd packager: Terminal abstraction to manage TTYs
Reviewed By: cpojer

Differential Revision: D4293146

fbshipit-source-id: 66e943b026197d293b5a518b4f97a0bced8d11bb
2016-12-14 05:14:06 -08:00
Jeff Morrison d926aecd77 fbsource
Reviewed By: samwgoldman

Differential Revision: D4314897

fbshipit-source-id: fbe11da4c63bf34d010220d74177cb3ca4cbee6d
2016-12-13 18:58:34 -08:00
Christoph Pojer 3e6d762ab7 Remove `pit` and `mockImpl`
Reviewed By: dmitriiabramov

Differential Revision: D4321635

fbshipit-source-id: 460889a1f956f3733e7e49883dd97c9a8a561b86
2016-12-13 15:13:39 -08:00
David Aurelio 194604f0a1 install `node_modules` into `buck-out`
Reviewed By: cpojer

Differential Revision: D4312220

fbshipit-source-id: 1449a194c557071bb5f0be6bc00dccef26c62b47
2016-12-13 09:13:39 -08:00
David Aurelio f3a9decebc Add `bundle` command
Summary: This adds the machinery necessary to create a bundling function, and adds different reusable parts around generating code and maps for bundles. Used for the new integration with Buck

Reviewed By: cpojer

Differential Revision: D4299272

fbshipit-source-id: 59ebe39a454ebf56c2159717c2881088d6d3308a
2016-12-13 07:28:31 -08:00
Jean Lauliac f0ca55aee8 packager: Resolver&co: @flow
Reviewed By: davidaurelio

Differential Revision: D4285448

fbshipit-source-id: ec9bc6fd3c6d6eae89347762bff8b5b24662394b
2016-12-08 05:13:40 -08:00
David Aurelio 6786cbd3e4 Add fbjs definitions to flow config
Reviewed By: zertosh

Differential Revision: D4291805

fbshipit-source-id: 3dcb8ffe6132bd04a3048edae64e9d273c2dcae4
2016-12-08 02:43:25 -08:00
David Aurelio cf3ae6c32a Use absolute paths from repo root
Summary: Rather than using relative paths from the build root, this switches all paths to absolute paths from the build root. This makes integration with a lot of tooling easier.

Reviewed By: jeanlauliac

Differential Revision: D4285474

fbshipit-source-id: 80d20e0f6dc61a310e72112b9654628bff81a4f0
2016-12-06 16:58:33 -08:00
David Aurelio 2ab5d2809f Add bundle building logic
Summary: Adds the necessary functionality to serialize a series of `Module`s to a bundle and a source map in the context of the new Buck/Packager integration

Reviewed By: cpojer

Differential Revision: D4265867

fbshipit-source-id: f2d3e4ffed64a3dca817101faad7bced9f16edc7
2016-12-05 16:43:45 -08:00
David Aurelio 27e818fa69 Support relative paths in haste map
Summary: Since all paths are relative when building with the new Buck integration, `HasteMap` needed support for these.

Reviewed By: cpojer

Differential Revision: D4265888

fbshipit-source-id: 2d454bfd3866028d8d2c268c0fd318b148951dc9
2016-12-05 16:43:45 -08:00
David Aurelio c18373f438 Add source map helper
Summary: Adds a helper to produce index source maps for Buck builds

Reviewed By: cpojer

Differential Revision: D4265911

fbshipit-source-id: 9ca3c49876df5db039bae823c0458c98e6e05619
2016-12-05 16:43:45 -08:00
David Aurelio 67c9fe0b75 Don’t use spaces when amending module wrapper
Summary: since we use the same module wrapper amendment function for dev and prod builds, and code is already minified at this point, we minify ourselves by leaving out space.

Reviewed By: cpojer

Differential Revision: D4265967

fbshipit-source-id: 719a3bbfbc02c9af1bb3fa08317b2f1b92c141a5
2016-12-05 16:43:45 -08:00
David Aurelio 0336be8918 ModuleGraph: Also call back with module objects of entry points
Summary:
This changes the callback value of `Graph` function so that it also contains a separate property with `Module` instances of the entry points.

Having references to the entry point modules allows to e.g. create require calls to them dynamically to kick of bundle execution.

The commit also contains a refactoring of the `Graph` function and its helpers that reduces the need for extensive parameter passing and long nested functions.

Reviewed By: cpojer

Differential Revision: D4250772

fbshipit-source-id: 2edca77bbef2308d3176a62123b8cecd70e2c8c7
2016-12-05 16:43:45 -08:00
Jean Lauliac 3bb6ee4bac packager: Server/index.js: moar @flow
Summary:
Let's continue to bring Flow goodness to the codebase, as it will facilitate future refactorings.

I fixed a few of the typing issues by changing the local logic at times, but in a way that should not cause any difference globally.

Reviewed By: cpojer

Differential Revision: D4265347

fbshipit-source-id: a2a7afd7d93cf00ba58e8c9879a9bb6d5bf30358
2016-12-02 10:58:31 -08:00
Andrew Imm 67828a52bd Allow custom platforms for the RN Packager on a per-project basis
Reviewed By: cpojer

Differential Revision: D4255979

fbshipit-source-id: bf900b67ee30e2f994e96c9a6103ed2e53a87f88
2016-12-02 09:43:31 -08:00
Jean Lauliac e5de8bce61 packager: make legocastle script to write to the global cache
Reviewed By: davidaurelio

Differential Revision: D4251001

fbshipit-source-id: bde1e50c82c2cb8f2c2577139061498c809aa37e
2016-12-02 06:58:29 -08:00
Janic Duplessis 56fb3db693 Fix packager asset requests on windows
Summary:
6554ad5983 broke assets on windows, this fixes it and add a test to avoid regressions.

Ideally we'd run all the Dependency graph tests on both posix and win32 filesystems but that would probably require doing some sort of factory function to create the tests because I don't think we want to duplicate every test (file is big enough already :)). So for now I just copied that one test and changed the paths manually.

**Test plan**
Run the new test without the fix -> fails
Run the new test with the fix -> succeeds
Closes https://github.com/facebook/react-native/pull/11254

Differential Revision: D4265157

Pulled By: cpojer

fbshipit-source-id: 511470276bd950c2943e94c2dce6840df0fe6d69
2016-12-02 04:58:34 -08:00
Charles Dick 48d3cd7d26 Pull aggrow from facebookincubator/tracery-prerelease
Reviewed By: bnham

Differential Revision: D4250937

fbshipit-source-id: b5f2cfdeb06c04399670e463b8b2498e2fe0074b
2016-11-30 12:58:35 -08:00
Christoph Pojer b1fd7bd641 kill `shouldThrowOnUnresolvedErrors` option
Summary: Removes the `shouldThrowOnUnresolvedErrors` option, as now it is only ever `() => true`

Reviewed By: davidaurelio

Differential Revision: D4237711

fbshipit-source-id: 9460f0f0c50dc0d08d17cb7bdeb995825f7051f3
2016-11-30 10:13:36 -08:00
Jean Lauliac 59873d7a2b packager: Module: gives global cache more retries
Reviewed By: cpojer

Differential Revision: D4250880

fbshipit-source-id: c2d215d4dad10705bc24bec758aed85ef13607ba
2016-11-30 07:43:42 -08:00
Jean Lauliac cb254d1e35 packager: GlobalTransformCache: globalized keyOf
Reviewed By: davidaurelio

Differential Revision: D4243863

fbshipit-source-id: 917a8a116baf67c838c062b7b713dd4660d9f673
2016-11-30 07:43:42 -08:00
Jean Lauliac 9b9fd2f2f0 packager: GlobalTransformCache: better aggregation
Reviewed By: davidaurelio

Differential Revision: D4238279

fbshipit-source-id: 3b79a3e87d0eb975efce6adc11b13862c7138e1b
2016-11-30 07:43:42 -08:00
Jean Lauliac 6740207b9f packager: Bundler: hash all the cache key components
Reviewed By: davidaurelio

Differential Revision: D4238061

fbshipit-source-id: 2ad79a85a5da3026afd508557b3b29457f472bb2
2016-11-30 07:43:42 -08:00
Christoph Pojer 6554ad5983 Kill fastfs
Summary:
This kills fastfs in favor of Jest's hasteFS. It gets rid of a ton of code, including the mocking code in ResolutionRequest which we don't need any more. Next step after this is to rewrite HasteMap, ModuleCache, Module/Package. We are getting closer to a nicer and faster world! :)

Here is what I did:
* Use Jest's HasteFS instead of fastfs. A fresh instance is received every time something changes on the FS.
* HasteFS is not shared with everything any more. Only one reference is kept in DependencyGraph and there are a few smaller functions that are passed around (getClosestPackage and dirExists). Note: `dirExists` now does fs access instead of an offline check. This sucks but stat calls aren't slow and aren't going to be a bottleneck in ResolutionRequest, I promise! When it is time to tackle a ResolutionRequest rewrite with jest-resolve, this will go away. "It gets worse before it gets better" :) The ModuleGraph equivalent does *not* do fs access and retains the previous way of doing things because we shouldn't do online fs access there.
* Add flow annotations to ResolutionRequest. This required a few tiny hacks for now because of ModuleGraph's duck typing. I'll get rid of this soon.
* Updated ModuleGraph to work with the new code, also created a mock HasteFS instance there.
* I fixed a few tiny mock issues for `fs` to make the tests work; I had to add one tiny little internal update to `dgraph._hasteFS._files` because the file watching in the tests isn't real. It is instrumented through some function calls, therefore the hasteFS instance doesn't get automatically updated. One way to solve this is to add `JestHasteMap.emit('change', …)` for testing but I didn't want to cut a Jest release just for that. #movefast

(Note: I will likely land this in 1.5 weeks from now after my vacation and I have yet to fully test all the product flows. Please give me feedback so I can make sure this is solid!)

Reviewed By: davidaurelio

Differential Revision: D4204082

fbshipit-source-id: d6dc9fcb77ac224df4554a59f0fce241c01b0512
2016-11-30 04:28:32 -08:00
David Aurelio eda09f89c9 Add utilities for bundle creation
Summary: Adds utilities needed for bundle creation: `completeModuleWrapper` appends numeric IDs for the module itself and its dependencies to a module wrapped. `createGetModuleId` returns a function that returns sequential numeric IDs for strings, and is idempotent.

Reviewed By: cpojer

Differential Revision: D4240334

fbshipit-source-id: c165482ebcf0e81ebb83ba6ff634de095ffb6bf0
2016-11-30 03:13:40 -08:00
David Aurelio da079f7433 change `isPolyfill` to `type = 'module' | 'script'`
Summary: When building, we will process modules in a special way, *not* polyfillys. We will also add more types of (virtual) files that are not modules. That’s why a “type” property makes more sense.

Reviewed By: cpojer

Differential Revision: D4244583

fbshipit-source-id: 92a0b4a0a2026d0b97ba88034483a6ce4e0c1ebb
2016-11-30 03:13:40 -08:00
David Aurelio 021b313d88 Fix double callback invocation in `ModuleGraph/Graph`
Summary:
The logic in `ModuleGraph/Graph` allowed the callback to be invoked twice, if two invocations of `resolve` call back with errors asynchronously.

This fixes that problem by always calling `queue.kill()` on the asynchronous queue, and only invoke the main callback from the `drain` and `error` queue callbacks.

Reviewed By: jeanlauliac

Differential Revision: D4236797

fbshipit-source-id: c30da7bf7707e13b11270bb2c6117997fd35b029
2016-11-30 03:13:40 -08:00
Tim Yung c76f5e1ae5 RN: Move `core` to Shared
Reviewed By: cpojer

Differential Revision: D4250233

fbshipit-source-id: 8c42bed47559c477be039d47e3f4fd1fac503152
2016-11-29 23:13:50 -08:00
Jean Lauliac 188093ae29 packager: Bundler: use stable paths for cache key
Summary: For having a global cache, we need cache keys that are the same from different machines, so we cannot include user/machine-specific information. In that regard, I suggest we consider the paths relatively to the install directory of the React Native instead of being absolute, so that they are more chances they stay stables between different installations, users, machines.

Reviewed By: davidaurelio

Differential Revision: D4237840

fbshipit-source-id: d864b9739550ac2c95d5693db12bd1592411f80a
2016-11-29 11:58:35 -08:00
Jean Lauliac e485f6997d packager: Bundler: use transform module hash instead of mtime
Summary: mtime is a problem for the global cache, because everyone has different times at which they rebased/cloned the repo. Use the actual content instead. Of course, the file could depend on other files we don't take into account... but the mtime solution was already problematic in that regard, so I assume this is a safe change.

Reviewed By: davidaurelio

Differential Revision: D4237826

fbshipit-source-id: 9dc18eb422cddd4d5ed097d1ebeef4b8c361ff39
2016-11-29 11:58:35 -08:00
Jean Lauliac c284e0cd7a packager: Module: better type for transformOptions
Reviewed By: davidaurelio

Differential Revision: D4237808

fbshipit-source-id: 8ca40bc9f8e7ec7cea2aaa8a8562dc63d423cea4
2016-11-29 04:28:36 -08:00
Tim Yung 53741ad020 Packager: Shorter + Consistent-Width Timestamps
Summary: Sets some options on `toLocaleString()` so that the server debug output's timestamps are shorter and have a consistent width (zero-padded).

Reviewed By: cpojer

Differential Revision: D4235074

fbshipit-source-id: 72dcf35ffd182eb70afc20d2b266314787433c4a
2016-11-28 13:13:35 -08:00
Tim Yung 54807ab553 Packager: Print Debug Fields on Separate Lines
Summary:
When printing fields in the packager server debug output, this revision breaks the fields up onto multiple lines.

As it currently exists, the fields are printed immediately after the log entry label which can seem unnecessarily repetitive and unintuitive.

Reviewed By: davidaurelio

Differential Revision: D4235038

fbshipit-source-id: 2d59afa70c74f19afab221dfa58f437913c6dc2c
2016-11-28 13:13:35 -08:00
Gabe Levi bf901d926e Deploy v0.36.0
Reviewed By: zertosh

Differential Revision: D4237912

fbshipit-source-id: cc251884350ffa3c8715a4920f90bd301e8a9b7f
2016-11-28 10:13:31 -08:00
David Aurelio 8ad2ab3b5e BREAKING: expose `getTransformOptions` directly in configuration
Summary:
Instead of exposing a `getTransformOptionsModulePath` function in configurations, we can simply expose a `getTransformOptions` *function*. The necessity of exposing a path comes from the olden days, where we had a server listening on a socket, and a client, talking to that server.

Since that architectural gem no longer exists, we can use functions directly, rather than passing paths to modules around.

Reviewed By: cpojer

Differential Revision: D4233551

fbshipit-source-id: ec1acef8e6495a2f1fd0911a5613c144e8ffd7c3
2016-11-28 07:28:33 -08:00
David Aurelio c197c49123 Simplify contract of `getTransformOptionsModulePath`
Summary:
instead of passing the `Bundler` instance, the transform options module now receives a `getDependencies()` function.
The idea is to make the contract stricter, to integrate more easily with the new `ModuleGraph` system.

Reviewed By: cpojer

Differential Revision: D4233529

fbshipit-source-id: 1c6d462c7dae1c61cbf45fd13989ce77f76e7384
2016-11-28 07:28:33 -08:00
Pieter De Baets 63eb4dfe67 Stop silently failing for requires on Android
Reviewed By: bestander

Differential Revision: D4237195

fbshipit-source-id: 51266664a3693d8e942e97ffd0b0ddc7ada74819
2016-11-28 05:58:27 -08:00
penx 7295d29175 Fix to spelling in error message
Summary: Closes https://github.com/facebook/react-native/pull/11149

Differential Revision: D4234240

fbshipit-source-id: 8664f9950d4ab78a87f1d23c84073e74b21a5126
2016-11-26 14:58:26 -08:00
Jean Lauliac 5d30045211 packager: add GlobalTransformCache
Reviewed By: davidaurelio

Differential Revision: D4175938

fbshipit-source-id: 1f57d594b4c8c8189feb2ea6d4d4011870ffd85f
2016-11-24 09:58:31 -08:00
David Aurelio ca58e0af82 BREAKING kill deprecated asset support
Summary:
This removes support for `require('image!…')`, which has been deprecated for a long time.

It is still possible to use images that are already bundled by the native app using the `nativeImageSource` module.
Check http://facebook.github.io/react-native/docs/images.html for detailed documentation.

Reviewed By: matryoshcow

Differential Revision: D4231208

fbshipit-source-id: 05ec4c1ca0fabdc3fbb652f8ad1acdf240a67955
2016-11-24 05:43:38 -08:00
Ovidiu Viorel Iepure 0c50a5be54 Packager version in logs
Summary: Add Packager version to log entries.

Reviewed By: davidaurelio

Differential Revision: D4212961

fbshipit-source-id: 96036eb2dc70d959108ef5a3a14c58643aba5349
2016-11-24 04:43:26 -08:00
David Aurelio f9d80a451a Bring back programmatic packager API
Summary:
Brings back parts of the programmatic API removed in 7762f374d5. This is used by a few people. Also updates the docs accordingly.

cc akaila

Reviewed By: jeanlauliac

Differential Revision: D4226348

fbshipit-source-id: e5c0794f9c5415f14b54d16c6f35f902eafc3064
2016-11-23 06:28:28 -08:00
alex d196ca70db Caching assets only for production environment
Summary:
**Motivation**

In the context of a webview, one may extract assets (javascript or any types really), and relates to them through the html.

The packager `Server` serves this files correctly but also applies a cache based on time (a year). During development, this cache is actually bad as we need to re-iterate the process of editing/testing quickly.

I don't believe it is necessary to cache, and still wanted to make sure we would if process.env.NODE_ENV is 'production'.

**Test plan**

Run jest on impacted files:
```
node_modules/.bin/jest packager/react-packager/src/Server/__tests__/Server-test.js
```
Closes https://github.com/facebook/react-native/pull/10919

Differential Revision: D4226350

Pulled By: davidaurelio

fbshipit-source-id: d4bbff5b1a5b691aab197bcddb8fa9d2e43caa16
2016-11-23 04:58:31 -08:00
David Aurelio f3779502d3 Add flow types for output modules
Summary: Adds flow types for output functionality for easier maintenance and interop with new code

Reviewed By: matryoshcow

Differential Revision: D4211863

fbshipit-source-id: 591407d3a6d49536054ae94ba31125c18a1e1fa1
2016-11-21 13:28:30 -08:00
Ovidiu Viorel Iepure 27817bed0e Logger API error handling improvement
Summary: Defer Logger calls to the next tick queue so as to avoid potential Logger errors from falling under the purview of Promise error handling, which would degrade development experience by "swallowing" legitimate runtime errors within rejected promises, to the infuriation of us all :D

Reviewed By: davidaurelio

Differential Revision: D4197869

fbshipit-source-id: 10a44904be1404ad2534d06ddc56048c1c24f32b
2016-11-21 05:58:27 -08:00
Tim Yung 23331df5a4 RN: Cleanup OSS JS & Flow Declarations
Reviewed By: vjeux

Differential Revision: D4210763

fbshipit-source-id: 5abaa547100b8badd13bcf311ceffc5b4098d252
2016-11-20 17:58:29 -08:00
David Aurelio a10eee4372 Handle transform problems correctly
Summary: This fixes a piece of promise code that didn’t handle nested rejections. This caused the packager not to recover from transform errors, as the server was waiting for an in-limbo promise forever.

Reviewed By: cpojer

Differential Revision: D4207138

fbshipit-source-id: 8e94ddebd033073f90b79b1c4820c09ac98a4932
2016-11-18 20:43:28 -08:00
David Aurelio 3a52efa614 Updates to node-haste adapter
Reviewed By: matryoshcow

Differential Revision: D4197864

fbshipit-source-id: 31bc4b0fb51ea77fac09fdd0f8180e984e05087a
2016-11-17 11:13:30 -08:00
David Aurelio 07f67fa225 Add tests for worker code
Summary: This adds unit tests for the new buck worker code, including a test for source map generation.

Reviewed By: cpojer

Differential Revision: D4193657

fbshipit-source-id: 06f7bfb5efa4f411178543a728ac7e42511caa3c
2016-11-17 08:58:55 -08:00
David Aurelio c8b463f3b6 add flow
Summary: This adds flow types to new code written for the Buck/Packager integration.

Reviewed By: cpojer

Differential Revision: D4175156

fbshipit-source-id: 38c3d2c9176c7b3cf22b8baed7d445a75d033d04
2016-11-17 08:58:55 -08:00
David Aurelio 242bc6928f Use array lookup for localized dependency IDs
Summary:
The current transform for require calls replaces strings with module-local IDs. That means that each module would need a local require function.
To save hundreds of closure allocations, we can just use an array that maps local IDs to global IDs.

This diff changes the dependency collection and replacement transform to change a call like `require('React')` to something like `require(_dependencyMap[0])` rather than `require(0)`.

Reviewed By: cpojer

Differential Revision: D4153714

fbshipit-source-id: a63455834c6c2a75da6977cacb9aac9f2cb1b3aa
2016-11-17 08:58:55 -08:00
Jean Lauliac eb2cbeac9f packager: DependencyGraphHelpers: @flow
Reviewed By: cpojer

Differential Revision: D4190148

fbshipit-source-id: 320496bb683288a19605bd667de1472c7fc9c6b4
2016-11-17 05:13:27 -08:00
Christoph Pojer a9338d6af1 New file watching implementation
Summary:
This is the next incremental step to rewrite node-haste. I apologize for the size of this diff but there is really no smaller way to do this. The current architecture passes a single file watcher instance into many classes that each subscribe to file changes. It's really hard to keep track of this. The new implementation reduces the listeners to two (will eventually be just one!) - one in DependencyGraph and one in it's parent's parent's parent (ugh! This doesn't make any sense). This should make it much more straightforward to understand what happens when a file changes.

I was able to remove a bunch of tests because jest's watcher takes care of things like ignore patterns. Some of the tests were specifically testing for whether the change events were invoked and they are now much more straightforward as well by manually invoking the `processFileChange` methods.

(Relanding a fixed version of D4161662)

Reviewed By: kentaromiura

Differential Revision: D4194378

fbshipit-source-id: 8c008247a911573f6b5f6b0b374d50d38f62a4f5
2016-11-16 20:13:26 -08:00
Jean Lauliac 79822ea9d3 packager worker: more @flow
Reviewed By: matryoshcow

Differential Revision: D4160528

fbshipit-source-id: 5f43cb47717288c5344c1204cf435ec727ca752e
2016-11-16 10:43:25 -08:00
Martin Konicek 14ac051c19 Revert D4161662: [RNP] New file watching implementation
Differential Revision: D4161662

fbshipit-source-id: 00604387b4f4b808f95275458f1c653981f91b86
2016-11-16 10:28:31 -08:00
Christoph Pojer e8a623a2ab New file watching implementation
Reviewed By: davidaurelio

Differential Revision: D4161662

fbshipit-source-id: 9a2a399304c83b411a8b0b74ea015c18b599fbaf
2016-11-16 01:13:40 -08:00
Christoph Pojer 3bd949cac7 Update Jest + jest-haste-map
Reviewed By: voideanvalue

Differential Revision: D4180887

fbshipit-source-id: f6ee6901e63206824f0639c81b64167b66da2168
2016-11-15 06:58:45 -08:00
Andres Suarez 72157cf991 Remove parse
Reviewed By: davidaurelio

Differential Revision: D4174312

fbshipit-source-id: 024ae3da56c1afd882f808c15a3b90db35627587
2016-11-15 04:59:48 -08:00
Jean Lauliac 2ed588751d packager: JSTransformer/index.js: @flow
Reviewed By: cpojer

Differential Revision: D4167006

fbshipit-source-id: db0deb2262fe2c53735cb46d9de6e6da1b375180
2016-11-15 04:28:53 -08:00
Jean Lauliac 31b4648a8a packager: DependencyGraph-test: require extractDependencies only once
Reviewed By: davidaurelio

Differential Revision: D4182071

fbshipit-source-id: 622cb3e011b67c2a7df0c6308fbcb7a9ea1ebb96
2016-11-15 03:43:42 -08:00
Jean Lauliac 15baa16ada packager: DependencyGraph-test: mock child_process
Reviewed By: cpojer

Differential Revision: D4182064

fbshipit-source-id: e645e6d952e3aeaadaf35e29d6fcaf6395e590a7
2016-11-15 03:43:42 -08:00
Martin Hernan Giachetti c9e5a64940 Update error-guard.js
Summary:
This vars should be let instead of const because they are reassigned.
Closes https://github.com/facebook/react-native/pull/10818

Differential Revision: D4179219

Pulled By: javache

fbshipit-source-id: b09959c5ff31ad1a896d454011dffd915a0a44c4
2016-11-15 00:13:42 -08:00
Gabe Levi 61d1a4fb39 Deploy v0.35.0
Reviewed By: davidaurelio

Differential Revision: D4177391

fbshipit-source-id: c02cf98ed275b7032103b11eab6d0e189f8d8f24
2016-11-14 20:45:17 -08:00