Commit Graph

676 Commits

Author SHA1 Message Date
David Aurelio 101977eb19 improve options parser
Reviewed By: jeanlauliac

Differential Revision: D4146832

fbshipit-source-id: a54284ccc3fa4d6e1628886b748b21b9b9af2cff
2016-11-08 10:13:40 -08:00
Jean Lauliac 3ae8e44f34 packager ResolutionResponse: @flow
Reviewed By: davidaurelio

Differential Revision: D4146739

fbshipit-source-id: 0b8e65dfaa2f28c4498fb17b8d980da9271fe8d6
2016-11-08 04:58:44 -08:00
Jean Lauliac d25047ebf1 declareOpts: @flow
Reviewed By: cpojer

Differential Revision: D4146711

fbshipit-source-id: edd360b3dd8444c7ec5be5c69db97e1e0906a730
2016-11-08 04:58:44 -08:00
Jean Lauliac f1aba3f63b react-packager/src/Bundler/index.js: @flow
Reviewed By: davidaurelio

Differential Revision: D4139968

fbshipit-source-id: dc77ea6f0971b5d378883d89290a773205f97c18
2016-11-08 04:58:44 -08:00
Jean Lauliac c18d46bd03 JSTransformer/worker: cache transformed code as separate files
Reviewed By: davidaurelio, cpojer

Differential Revision: D4051477

fbshipit-source-id: 0179ce18dd20c00083ae05b5cf5f925659e7c056
2016-11-08 03:43:37 -08:00
Andres Suarez 6212c223ec Remove prepack bundle functionality
Reviewed By: davidaurelio

Differential Revision: D4138495

fbshipit-source-id: 52793fc1a8ef8b2fc461156607c360f34c4cb362
2016-11-07 03:43:37 -08:00
Jean Lauliac 403d4ed721 RM node-haste DependencyGraph: @flow
Summary: In addition to adding flow in that file, I also had to fix `Module.js` and others to make everything compatible together.

Reviewed By: davidaurelio

Differential Revision: D4118829

fbshipit-source-id: 4f6dbc515741c38817cc4c9757e981fabb03915a
2016-11-04 10:43:39 -07:00
David Aurelio dee58678c6 Prepare `__d` fn for Buck integration
Summary:
The new Packager/Buck integration passes module factory functions as first argument, so that the complete call can be amended at the end safely at a later point in time.
The call expression as a whole is covered perfectly by the created source map. Appending to that code later won’t break mappings.

`__d` now also accepts an additional `dependencyMap` parameter, which so far is only used by the new Packager/Buck integration. It enables module-local dependency IDs, thus eliminating the need to insert `correct` module IDs when building a bundle. Advantages are that source maps are no longer affected, and that builds can be quicker.

Reviewed By: cpojer

Differential Revision: D4124333

fbshipit-source-id: 12eba15d0b9d8c6624280a2ba1e7e4bc654bc83d
2016-11-04 05:13:44 -07:00
Jing Chen c296a3ee25 Silently fail for requires on Android again until we can fix loading image assets from both repos
Reviewed By: blairvanderhoof

Differential Revision: D4128218

fbshipit-source-id: d743cdb7a73efc2f46c42217a49c6094fcd3808a
2016-11-04 00:58:48 -07:00
mike qin 957ce4baca increase MAX_WAIT_TIME
Summary:
increase the `MAX_WAIT_TIME` in FileWatcher since live reloading doesn't work for a lot of users on windows when developing android. There may be a better timeout than arbitrarily tripling it, I'm sure the original developer would be able to pick out a good one, but many of us have used this change to finally be able to use RN here on windows.

fixes https://github.com/facebook/react-native/issues/8784 https://github.com/facebook/react-native/issues/7257
Closes https://github.com/facebook/react-native/pull/10690

Differential Revision: D4126110

Pulled By: mkonicek

fbshipit-source-id: 9b6f188fe9d39bcdcc2b38392dfc644a518296b2
2016-11-03 18:13:41 -07:00
David Aurelio b184c45275 Make sure that write streams are closed
Reviewed By: jeanlauliac

Differential Revision: D4117716

fbshipit-source-id: c12f07c6a0e016ac14543878491a8b4160099e21
2016-11-03 13:29:10 -07:00
Ovidiu Viorel Iepure 1ac86b2304 File transform events
Summary: Correctly generate log entries for file transforms and ping telemetry using the new Logger API.

Reviewed By: bestander, cpojer

Differential Revision: D4081325

fbshipit-source-id: 7d50d54eb673a0276512db6ad5ff21c344495612
2016-11-03 07:44:10 -07:00
Ovidiu Viorel Iepure 4d23c1f423 Instrumentation API
Reviewed By: cpojer

Differential Revision: D4074413

fbshipit-source-id: fd2dff17168f426680fd9dc8456f8b1ae3f55318
2016-11-03 07:44:10 -07:00
David Aurelio cda4129dd3 Add flow to require implementation, always warn when modules are accepted by name
Reviewed By: matryoshcow

Differential Revision: D4124228

fbshipit-source-id: 461087caf4add07db376bb71ae5ba42bf3536cd3
2016-11-03 05:58:30 -07:00
Jean Lauliac 4ce09ce88a RM Polyfill.js: @flow
Reviewed By: davidaurelio

Differential Revision: D4118256

fbshipit-source-id: b9d906cd94c0548c28a62fa636c6da7bcf894ba9
2016-11-03 04:58:46 -07:00
Jean Lauliac 4fe80636fb RM fastfs.js: @flow
Reviewed By: cpojer

Differential Revision: D4118175

fbshipit-source-id: ad9d1f98bcde0c1be17d36c74c3662e6e55165f8
2016-11-03 04:58:46 -07:00
Jean Lauliac d730928b0c RN Package.js: @flow
Reviewed By: davidaurelio

Differential Revision: D4118006

fbshipit-source-id: ad8fdcb67351a9e53af0a7acbf16f269daf31f50
2016-11-02 13:43:43 -07:00
Jean Lauliac 1baa2ab893 RN ModuleCache.js: @flow
Reviewed By: davidaurelio

Differential Revision: D4117759

fbshipit-source-id: 158f6e50cb9211f87acce17047ed3e959e6c271f
2016-11-02 13:43:43 -07:00
Alexander Blom 94929b717c Add Console agent
Summary: Adds the Console agent which we hook from our console polyfill. It captures the stack and strips the frames of the polyfill.

Reviewed By: davidaurelio

Differential Revision: D4021502

fbshipit-source-id: 49cb700a139270485b7595e85e52d50c9a620db6
2016-11-02 12:29:15 -07:00
Pieter De Baets 5af2bf17bc Stop silently failing for requires on Android
Reviewed By: bestander

Differential Revision: D4117128

fbshipit-source-id: a11996a322d38e884aad2f095342c1ea723b0d89
2016-11-02 08:58:42 -07:00
David Aurelio 05d53084c1 buck worker tool: catch errors thrown from commands, and respond with errors.
Reviewed By: cpojer

Differential Revision: D4057884

fbshipit-source-id: acfe0cc57b541a534dd640380c69f591c1fb83c6
2016-11-01 05:58:43 -07:00
Jean Lauliac d60ac14fd0 extract-dependencies.js: fix out-of-date comment
Summary: We actually use the AST, not regexes. Fix comment.

Reviewed By: davidaurelio

Differential Revision: D4104797

fbshipit-source-id: e37d168bd541d9d222667d0d168aa6b6099c1275
2016-10-31 11:43:37 -07:00
Jean Lauliac d8aab602b2 Module.js: add @flow
Reviewed By: cpojer

Differential Revision: D4095611

fbshipit-source-id: d87509153eab3d8dbcd65b8c6c6ffb3e5746685f
2016-10-31 04:28:29 -07:00
Pooya Parsa be244f3a72 os.tmpDir() is deprecated
Summary:
According to [5e5ec2cd1e](https://github.com/nodejs/node/commit/5e5ec2cd1e) os.tmpDir() is now deprecated in node.js 7 and `os.tmpdir()` is preferred :)

Current status:
Bundler shows annoying warning every time it runs :)
Closes https://github.com/facebook/react-native/pull/10620

Differential Revision: D4101498

fbshipit-source-id: 0de8cc30f684f1f22191c64fa2c7ce73c5abf9ea
2016-10-29 13:59:01 -07:00
Jean Lauliac 3b0d4f4c33 node-haste/Cache: @flow
Reviewed By: davidaurelio

Differential Revision: D4043681

fbshipit-source-id: 8c82b394f4df9bb0d580f405ce472c69224485f5
2016-10-24 10:29:06 -07:00
Ovidiu Viorel Iepure c253a8ba39 Activity session
Summary: Add session ID to be appended to every event in the current Packager session.

Reviewed By: davidaurelio

Differential Revision: D4029580

fbshipit-source-id: 8c34c1f44ee63f845d15f8f89e491ab5c936fb21
2016-10-24 05:43:43 -07:00
David Aurelio f6f2c6259b Break out defaults, add flow for Config
Summary: In order to make `Config` and defaults available to our new code, I’ve added flow types and put default values into one shared modile

Reviewed By: cpojer

Differential Revision: D4044600

fbshipit-source-id: 875ed3ade69c5b22bb3c1b177e7bad732834d476
2016-10-22 06:13:42 -07:00
David Aurelio 74a5b35802 Add support for relative paths to ResolutionRequest
Summary:
This makes ResolutionRequest stop calling `dirname` when arriving at `"."`, not only at `parse(path).root`.
Needed for Buck integration, as we are using relative paths there

Reviewed By: cpojer

Differential Revision: D4058723

fbshipit-source-id: d1856043193cfad3f750577ba0f63f03f8effe7a
2016-10-22 06:13:42 -07:00
Christoph Pojer 18c4ae81e7 Remove fastpath
Summary: I originally added fastpath to node-haste to speed up `path` operations by an order of magnitude. Now we are exclusively using Node 6 at FB so we don't need to ship this thing any more.

Reviewed By: bestander

Differential Revision: D4029092

fbshipit-source-id: 064cf67f4f79ce4f2774fb4e430d22eef4a95434
2016-10-20 00:14:03 -07:00
David Aurelio c16465a582 Create integration types and code to use module resolution logic from node-haste
Summary:
This creates flow types for the module resolution code in node-haste, and implementations of types used by that code.

The idea is to use that code until we can replace it with something leaner, and provide objects that don’t touch the file system. These objects will be initialized with the static data provided by ModuleGraph/worker.

Reviewed By: cpojer

Differential Revision: D4037372

fbshipit-source-id: 2698dbb630f4122fc1d839d06e414d0963bd6ff2
2016-10-19 06:58:39 -07:00
Jean Lauliac 977e7209ac Bundler.js: @flow
Reviewed By: davidaurelio

Differential Revision: D4036964

fbshipit-source-id: dceb81299d076493d12b2ade13354e927c10ea7c
2016-10-19 04:43:41 -07:00
Konstantin Raev c803b69ce1 Reverted commit D4036668
Reviewed By: cpojer

Differential Revision: D4036668

fbshipit-source-id: 5b75709526c3e87774e0943a76d55cd729c6143d
2016-10-18 12:13:36 -07:00
Jean Lauliac f39821c088 BundleBase.js: @flow
Reviewed By: matryoshcow

Differential Revision: D4036938

fbshipit-source-id: 2c151d98f99ab1e325bb07050d0a2c59ee8f4761
2016-10-18 10:29:30 -07:00
Jean Lauliac 2a1c443a36 react-packager/index.js: @flow
Reviewed By: cpojer

Differential Revision: D4036668

fbshipit-source-id: 286963fd1f18f92389ec642c43dcf4c9d55f19f8
2016-10-18 09:28:45 -07:00
David Aurelio 6ac3ae73a3 entry point: remove unused code
Summary: Removes code that is no longer used

Reviewed By: matryoshcow

Differential Revision: D4021932

fbshipit-source-id: d73dc8450478288afd71eab451a30a505e7de945
2016-10-18 07:28:40 -07:00
Christoph Pojer bfc35d528c Synchronous file reading
Reviewed By: matryoshcow

Differential Revision: D4021460

fbshipit-source-id: 88e4846d4434468d68e6071d05b27e3b7d2ed325
2016-10-16 18:43:38 -07:00
Christoph Pojer f53d694120 Remove `fastfs.readWhile`
Reviewed By: davidaurelio

Differential Revision: D4021265

fbshipit-source-id: 578ad54ea5a81e5b091cecafcb2fe6d08746e7f6
2016-10-16 18:43:38 -07:00
Ovidiu Viorel Iepure 5fe2c32cfc Rate limit HasteMap
Reviewed By: davidaurelio

Differential Revision: D4021676

fbshipit-source-id: 383f9a17ac8ede72f41939192ec25a6277a36864
2016-10-14 12:13:41 -07:00
David Aurelio 9383f292aa Monkey-patch `fs` with graceful-fs before anything else runs
Reviewed By: matryoshcow, kentaromiura

Differential Revision: D4020645

fbshipit-source-id: a7985109476b78b588c3e2a75ae6f25ea8f09237
2016-10-14 11:13:54 -07:00
Konstantin Raev bd5f803982 switched fast-fs to use fs for API calls
Summary:
When debugging graceful-fs I noticed that I don't get close() calls https://github.com/isaacs/node-graceful-fs/blob/master/graceful-fs.js#L37.
This is because fastfs uses fs returned from graceful-fs https://github.com/facebook/react-native/blob/master/packager/react-packager/src/node-haste/fastfs.js#L14 and graceful-fs returns close() of a clone object https://github.com/isaacs/node-graceful-fs/blob/master/graceful-fs.js#L27 that is not patched by graceful-fs yet.

Reviewed By: cpojer

Differential Revision: D4021446

fbshipit-source-id: 87e50ff779dfea13b8db2b97575bff0bfd7778eb
2016-10-14 07:47:22 -07:00
David Aurelio 506604c5bb Add support for JSON files to `js_file` rule
Reviewed By: cpojer

Differential Revision: D3981152

fbshipit-source-id: 94b5018a1afa27c635ddff5e26c1ff2bed09baf9
2016-10-13 11:14:04 -07:00
Ovidiu Viorel Iepure dc0f7875c8 Add details to Activity events
Summary: Update Activity API to allow adding more details to events for telemetry purposes.

Reviewed By: davidaurelio

Differential Revision: D3982691

fbshipit-source-id: 07f3ed5d1ec4eddbbdeb00feb02ea75e1168705e
2016-10-12 10:43:59 -07:00
Pieter De Baets 308ab1001e Reorganize core JS files
Reviewed By: lexs

Differential Revision: D3987463

fbshipit-source-id: fa8f1d1bea7ed699120b9705ddc1c83767fcf8e4
2016-10-11 10:14:28 -07:00
Pieter De Baets 89d4f26846 Cleanup console and ErrorUtils
Reviewed By: davidaurelio

Differential Revision: D3981005

fbshipit-source-id: 3c95e62177f78785c7f971dd632126dbfb83746b
2016-10-11 06:58:55 -07:00
David Aurelio 47a7a9ee80 Add `js_file_prod` rule
Reviewed By: matryoshcow

Differential Revision: D3913439

fbshipit-source-id: fe3a30fddb4d8fcabfc88caf9b1b032189812b89
2016-10-05 09:28:50 -07:00
David Aurelio 85b74ab639 Add `js_file` rule
Reviewed By: matryoshcow

Differential Revision: D3900455

fbshipit-source-id: 61384ade035db978ef3ca258e4c0109bcb450692
2016-10-05 09:28:50 -07:00
David Aurelio 92fb9957b4 Implement proper command handling for new worker tool
Reviewed By: matryoshcow

Differential Revision: D3906818

fbshipit-source-id: a192723a16094d3901de40a9914428fd6ff119a2
2016-10-04 02:59:34 -07:00
Alex Kotliarskyi 3d23012d06 Send progress events via multipart response
Summary:
Context: I'm trying to add support for sending packager progress events to the client that is downloading the bundle over HTTP multipart response.

The idea is for the client to send `Accept: multipart/mixed` header, and if present the server will stream progress events to the client. This will ensure the change is backwards-compatible - the clients who don't know about progress events won't receive them.

In the future we can use this approach to download RAM bundle modules in one request.

Reviewed By: davidaurelio

Differential Revision: D3926984

fbshipit-source-id: 39a6e38e40a79f7a2f2cf40765a0655fb13b7918
2016-10-03 18:13:36 -07:00
Alex Kotliarskyi d9797e2de7 Move progress bar from Bundler to Server
Summary:
Context: I'm trying to add support for sending packager progress events to the client that is downloading the bundle over HTTP multipart response.

In order to do that I need the server to know about these events. Currently the bundler doesn't expose any hooks for monitoring the progress, so this diff introduces `onProgress` option for that.

Reviewed By: davidaurelio

Differential Revision: D3926806

fbshipit-source-id: b7d9c649df4f94ddf5082791209844610650325e
2016-10-03 18:13:36 -07:00
Ovidiu Viorel Iepure ecd933e73d Replacing node-haste with jest-haste-map
Summary: Modified `node-haste` implementation to use the much faster `jest-haste-map` under the hood. The underlying `fastfs` now gets passed the entire file list from the `jest-haste-map` rather than crawl the filesystem.

Reviewed By: cpojer

Differential Revision: D3724387

fbshipit-source-id: 447d58ea0edf283662ec23d1e2deee992cf8d240
2016-10-03 05:28:56 -07:00
David Aurelio a022f7d04a Rename Activity events for more clarity
Summary: Changed “Finding dependencies” and “Building Module Graph” to “Transforming modules” and “Initializing Packager” for more clarity

Reviewed By: matryoshcow

Differential Revision: D3950811

fbshipit-source-id: 7a2e655ef7e1655244ce427e7adc8c1e5afa7329
2016-09-30 08:58:36 -07:00
Ovidiu Viorel Iepure 351d9da0e8 Add file transform event to Activity
Summary: Add a telemetric event to the transformer.

Reviewed By: davidaurelio

Differential Revision: D3950902

fbshipit-source-id: c46e95ee93925fb0f9d1784aebdc3206baf74dc6
2016-09-30 08:43:34 -07:00
David Aurelio f3f12c6d2d Add more information to activity events
Reviewed By: matryoshcow

Differential Revision: D3950787

fbshipit-source-id: b6ac22027380a9f7cc7bcb39ecd33d5c9255301f
2016-09-30 07:43:35 -07:00
Konstantin Raev 6c1f9f99be added new property to mock in chalk.js
Summary:
Tests started [failing](https://travis-ci.org/facebook/react-native/jobs/163517412) with release of new  babel that uses chalk.white.bgRed in code.
Jest does not like chalk and needs it mocked.
Removed code duplication and patched the mock.
Closes https://github.com/facebook/react-native/pull/10169

Differential Revision: D3943493

Pulled By: davidaurelio

fbshipit-source-id: 11f57f60ed909a394f15de7b9cc511400aeff510
2016-09-29 04:13:33 -07:00
David Aurelio 7a3f44a2bd throwing for unresolved modules: flip logic
Summary:
The current test checks whether the target platform is `'ios'`. When building with windows, errors will also be swallowed silently.

This adds a check whether the target platform is `'android'`, where we have to avoid throwing for FB-internal reasons.

Reviewed By: martinbigio

Differential Revision: D3907025

fbshipit-source-id: 5abeb06b9121265fe1aa3932ad1785f148f04ddf
2016-09-22 07:28:33 -07:00
aleclarson 6bcad15e7b Fix 'isRelativeImport' to allow require('.') and require('..')
Summary:
davidaurelio 👍
Closes https://github.com/facebook/react-native/pull/10006

Differential Revision: D3898703

fbshipit-source-id: 6d88122ed56108d52bc1ae1b14c7ff7c39fd9b9a
2016-09-20 20:58:38 -07:00
aleclarsoniv bb1666a93a Fix node_modules resolution error messages
Summary:
We could probably relieve a lot of pain (in [this issue](https://github.com/facebook/react-native/issues/4968) specifically) by fixing the error message for when a module cannot be resolved after trying every relevant `node_modules` directory.

Currently, you get a confusing error message that only gives you the last `node_modules` directory checked. By creating the error message where we can access the `searchQueue`, we're able to provide all of the attempted `node_modules` directories.

Here's an example error message:

```
Unable to resolve module leftpad from /Users/aleclarson/ReactProject/src/stuff/index.js:
Module does not exist in the module map or as these directories:
  /Users/aleclarson/ReactProject/src/stuff/node_modules/leftpad
  /Users/aleclarson/ReactProject/src/node_modules/leftpad
  /Users/aleclarson/ReactProject/node_modules/leftpad
  /Users/aleclarson/node_modules/leftpad
  /Users/node_modules/leftpad
```
Closes https://github.com/facebook/react-native/pull/9832

Differential Revision: D3895408

Pulled By: davidaurelio

fbshipit-source-id: 872c9a3bb3633f751ec69b586a261616578ed511
2016-09-20 13:58:52 -07:00
James Ide 0a93067f3a Add "assetPlugin" option to allow arbitrary asset processing
Summary:
Adds a new URL option to the packager server called "assetPlugin". This can be a name of a Node module or multiple Node modules (`assetPlugin=module1&assetPlugin=module2`). Each plugin is loaded using `require()` and is expected to export a function. Each plugin function is invoked with an asset as the argument. The plugins may be async functions; the packager will properly wait for them to settle and will chain them.

A plugin may be used to add extra metadata to an asset. For example it may add an array of hashes for all of the files belonging to an asset, or it may add the duration of a sound clip asset.
Closes https://github.com/facebook/react-native/pull/9993

Differential Revision: D3895384

Pulled By: davidaurelio

fbshipit-source-id: 0afe24012fc54b6d18d9b2df5f5675d27ea58320
2016-09-20 13:43:51 -07:00
Cristian Carlesso bb80ef6326 Removing automatically reset modules between test run
Reviewed By: bestander

Differential Revision: D3886125

fbshipit-source-id: c8f47c3466add1e2c89649a1c6f47b01f0d7a89e
2016-09-19 12:43:55 -07:00
aleclarson 2d21260ce6 Check if node_modules dir exists before adding to search queue
Summary:
We can keep the `searchQueue` cleaner by using `this._fastfs.dirExists` on the potential `node_modules` directory. In addition to avoiding useless lookups, this also makes the error message provided by #9832 much more understandable.

/cc davidaurelio
Closes https://github.com/facebook/react-native/pull/9973

Differential Revision: D3887053

Pulled By: davidaurelio

fbshipit-source-id: 6a5a488bb4217dd0f9db1c9c9f988b498c746ca9
2016-09-19 10:43:58 -07:00
Jean Regisser 047cbf9d59 Fix iOS unchanged local assets refetched from packager in development
Summary:
Hi,

This PR fixes the problem described by chrisnojima in https://github.com/facebook/react-native/issues/9581#issuecomment-243766310

**Test plan**

In development mode,
- Run an app with an image: `<Image source={ require('./logo.png') }/>`
- Notice that you see the following in packager console:
```txt
6:46:42 PM] <START> processing asset request logo.png
[6:46:42 PM] <END>   processing asset request logo.png (1ms)
```
- Reload the app, or navigate to another page of the app with the same image
- Notice that you see again:
```txt
6:47:23 PM] <START> processing asset request logo.png
[6:47:23 PM] <END>   processing asset request logo.png (1ms)
```

Now wih the fix applied,
notice that you only see `logo.png` fetched once, even if you reload or show the same image in a different part of the app.

Let me know what you think.
Closes https://github.com/facebook/react-native/pull/9795

Differential Revision: D3876945

Pulled By: davidaurelio

fbshipit-source-id: f41f4719e87644692a690123fd6e54eead9cc87d
2016-09-19 10:43:58 -07:00
David Aurelio 2311a28cb2 Unbreak RAM groups for modules without dependency pairs
Reviewed By: javache

Differential Revision: D3886546

fbshipit-source-id: 9b18834f91393de8a4b7c2e963a63a8f37c1c7b1
2016-09-19 09:58:35 -07:00
David Aurelio 64245abfc9 Fix HMR after adding RA-Bundle groups
Summary:
The introduction of groups for random access bundles broke hot module reloading, because HMR uses a different Bundle class. And that didn’t have the `setRamGroups()` method.

This just adds an empty method on the base class.

**Test plan (required)**

I ran `node scripts/run-ci-e2e-tests.js --android`
Closes https://github.com/facebook/react-native/pull/9982

Differential Revision: D3886096

Pulled By: bestander

fbshipit-source-id: 46e6183607b0275d3cfe0d892360248b7b2154e9
2016-09-19 04:44:12 -07:00
David Aurelio fb02e5d216 Add support for module groups to iOS Random Access Bundle format
Summary:
Adds the possibility to specify an array of files (group roots) that are used to bundle modules outside of the “startup section” into bigger groups by colocating their code.
A require call for any grouped module will load all modules in that group.
Files contained by multiple groups are deoptimized (i.e. bundled as individual script)

Reviewed By: martinbigio

Differential Revision: D3841780

fbshipit-source-id: 8d37782792efd66b5f557c7567489f68c9b229d8
2016-09-16 10:13:49 -07:00
David Aurelio 5e31ffce27 Support `false` mappings in `"browser"` fields
Summary:
This adds support for `false` values in `package.json` `"browser"` and `"react-native"` mappings.
All `false` values are not longer silently ignored, but redirected to an empty file.

Fixes #9854 #9518

Reviewed By: bestander

Differential Revision: D3876521

fbshipit-source-id: 96d1ba03518812bc88c51672c374956eabd40c9b
2016-09-16 06:13:35 -07:00
Charles Dick 9f65b0f025 Add option to bundle server to generate full sourcemaps from babel
Reviewed By: bestander

Differential Revision: D3863894

fbshipit-source-id: a282758e022d403743841bc59277196e6741ed18
2016-09-15 06:58:26 -07:00
aleclarsoniv bc0c34967e Protect against roots that are contained within other roots
Summary:
For example, I could have a root named `random` and another root named `randomColor`.
A child of `randomColor` would **incorrectly** pass as a descendant of `random`.

So this commit changes `isDescendant` to do 2 things:
- check for exact matches (eg: the path is a root)
- call `startsWith` like before, but append `path.sep` to avoid false positives
Closes https://github.com/facebook/react-native/pull/9831

Differential Revision: D3864968

fbshipit-source-id: 7fe04913579aa0741840fc925216283304ae3433
2016-09-14 13:43:47 -07:00
David Aurelio 0e06c0f74f module graph
Summary:
This piece of code can assemble all transitive dependencies of a set of entry modules. It is supposed to replace `ResolutionRequest.getOrderedDependencies`.

It has the following advantages:
- has minimal API surface to other components of the system (uses two functions, exposes one function)
- allows to separate concerns into loading + transforming files, resolving dependencies, gathering all modules belonging to a bundle (this code), and bundling
- allows to specify multiple entry points
- allows to use any kind of dependency ID as entry point (haste IDs, node module IDs, relative paths, absolute paths – depends on the resolver)
- allows to skip files, which allows callers to incrementally update previously retrieved collections of modules

Reviewed By: cpojer

Differential Revision: D3627346

fbshipit-source-id: 84b7aa693ca6e89ba3c1ab2af9a004e2e0aaed3d
2016-09-14 10:28:34 -07:00
David Aurelio aad22c00c4 Calculate asset hash from file contents, cache hashes
Summary: This makes the `hash` property of asset data depend on asset file contents rather than modification time of files. That means that bundles will be consistent across different checkouts.

Reviewed By: martinbigio

Differential Revision: D3856815

fbshipit-source-id: 8bfea4e0a714f48fc6a4ae5ed2a1426dc8d5868e
2016-09-14 04:28:46 -07:00
Jing Chen 86faac4f86 Reverted commit D3841557
Reviewed By: davidaurelio

Differential Revision: D3841557

fbshipit-source-id: c6098f0d85aa5c56b4109cd4f1ffe622379ab457
2016-09-12 13:58:33 -07:00
Charles Dick ab8b8ce9af use babel sourcemaps in bundle server
Reviewed By: davidaurelio

Differential Revision: D3841557

fbshipit-source-id: a6d40cf224ba7c2fd0a8eb0f0e2f7cc4bf222bcb
2016-09-12 09:28:42 -07:00
aleclarsoniv a105d9e317 Remove 'new' keyword before Promise.race()
Summary:
I'm not sure if this was actually breaking anything, but I don't think `new` before `Promise.race()` is conventional.
Closes https://github.com/facebook/react-native/pull/9817

Differential Revision: D3836814

Pulled By: javache

fbshipit-source-id: 3bde46dca3760c3f7f3427f6346dd5f16f8ac011
2016-09-09 05:28:51 -07:00
aleclarsoniv 3b36662908 Fix typo in new ModuleCache args
Summary:
👍
Closes https://github.com/facebook/react-native/pull/9774

Differential Revision: D3835002

Pulled By: mkonicek

fbshipit-source-id: a94f07a7f32fe709f0a7bed561f26d1d9c5ac377
2016-09-08 07:43:52 -07:00
Eric Rozell 2bf4fff849 fix(packager): support node-haste browser and react-native replacements on Windows
Summary:
Explain the **motivation** for making this change. What existing problem does the pull request solve?

Fix issue with browser and react-native module mappings in node-haste when running the packager from Windows.

**Test plan (required)**

Tested on the NPM package uuid, which has a browser mapping, and it worked.

Fixes #9570
Closes https://github.com/facebook/react-native/pull/9572

Differential Revision: D3821761

Pulled By: davidaurelio

fbshipit-source-id: ebbd91f9e3215385afe3b81a97a962b45a6286f9
2016-09-06 08:58:37 -07:00
wusuopu 4fffdc3b58 Fix _processAssetsRequest when url contains non-latin letter
Summary:
When I use local static files as Image resources, it will occur a 404 error if the image file's name contains some non-latin letters.
The reason is that the request's url will be encoded if it contains some non-latin letters.
Closes https://github.com/facebook/react-native/pull/9604

Differential Revision: D3821328

Pulled By: javache

fbshipit-source-id: bfdc7f71517b5d4ba9e0a013979e5dcf6c31a237
2016-09-06 06:13:49 -07:00
Ovidiu Viorel Iepure 777ea1cbdc 'silent' option for Activity events
Summary: Activity events now have a `silent` boolean option that specifies whether or not the event phases are to be logged to the console. Defaults to `false`, preserving current behaviour for events that do not explicitly have this option set.

Reviewed By: davidaurelio

Differential Revision: D3810802

fbshipit-source-id: 38d14b9e6c6502fbc73eece9466f20b60d19965e
2016-09-05 06:43:51 -07:00
David Aurelio 9889e7d5ca re-enable and fix tests
Summary:
When bringing back `node-haste` to React Native, I left an `fdescribe` in a test that led to ~70 tests being skipped.
This re-enables these tests, and fixes test failures

Reviewed By: cpojer

Differential Revision: D3811225

fbshipit-source-id: 67a16f385759bb829f1f3f559862eab7e78f2097
2016-09-03 01:13:37 -07:00
Ovidiu Viorel Iepure dd4722161e Telemetry for update bundle event
Summary: Updating an existing bundle is now logged as a telemetric event.

Reviewed By: davidaurelio

Differential Revision: D3804754

fbshipit-source-id: adab3b054a161bd9535ad01d52573fb7bb177d43
2016-09-01 11:14:07 -07:00
Ovidiu Viorel Iepure bd814bff49 High resolution timers
Summary: - replaced `Date` timers with high resolution timers

Reviewed By: bestander

Differential Revision: D3770919

fbshipit-source-id: 08b10b02d59f260030359a1b65ff155c92952018
2016-08-27 06:28:42 -07:00
Ovidiu Viorel Iepure ad7aa8434a Improvements to the Activity API
Summary:
Revised the Activity implementation
- added flow annotations
- fixed some lint warnings
- added event `options`, specifically a `telemetric` option which indicates that events tagged in this manner are relevant for telemetry. The duration of these events is now highlighted in the Activity log

Reviewed By: bestander, kentaromiura

Differential Revision: D3770753

fbshipit-source-id: 6976535fd3bf5269c6263d825d657ab0805ecaad
2016-08-25 09:58:37 -07:00
David Aurelio 599aaead28 Fix module IDs of initial require calls
Summary: The logic of assigning module IDs to the initial require calls of a bundle was faulty, counting up from -1 instead of counting down. This change ensures that IDs are -1, -2, ...

Reviewed By: matryoshcow

Differential Revision: D3735560

fbshipit-source-id: 89efa3e73b39c2f8bfed8a6a30487733d1a8b145
2016-08-18 07:28:43 -07:00
David Aurelio a5a087ef44 Remove cached bundle if update fails
Summary: If a bundle failed to build, a file change would trigger the *update bundle* path, without ever being able to resolve the bundle. If a bundle can't be updated, we evict it from the cache.

Reviewed By: cpojer

Differential Revision: D3726567

fbshipit-source-id: a342f00c5a41364551194c33082718e5483fd7a4
2016-08-16 17:43:41 -07:00
David Aurelio 9e20146f7f Remove rejected promises from the cache
Summary: Rejected promises in the cache would prevent the cache from persisting. This removes rejected promises from the cache, so that subsequent successful cache updates can be persisted.

Reviewed By: cpojer

Differential Revision: D3726691

fbshipit-source-id: ddec03676a7a89264fe64b4af4b183cbead638fb
2016-08-16 17:43:41 -07:00
David Aurelio 08cc4d6832 remove unused property
Reviewed By: matryoshcow

Differential Revision: D3717515

fbshipit-source-id: 5ecba83367cd11b19b56d19edf72efe9db717e2b
2016-08-15 12:43:31 -07:00
David Aurelio 7d418d8e3e Clear bundles for potential dependency resolution changes
Summary:
This clears the packager server cache for potential changes of module resolutions.
We will make this a lot better in the future, but for now this crude mechanism will have to do.

Reviewed By: cpojer

Differential Revision: D3713143

fbshipit-source-id: 7c81f40e8ec71404c3369211b29f63928d6634b9
2016-08-15 08:43:34 -07:00
David Aurelio a6059b7ca8 Make reloads faster for simple file changes
Summary:
This is a very hacky solution to make reloads from packager faster for simple file changes.

Simple means that no dependencies have changed, otherwise packager will abort the attempt to update and fall back to the usual rebuilding method.

In principle, this change avoids re-walking and analyzing the whole dependency tree, and just updates modules in existing bundles.

Reviewed By: bestander

Differential Revision: D3713704

fbshipit-source-id: ba182325c4f4003c0a7402ea87444a94c75ebaf8
2016-08-15 04:43:49 -07:00
Jing Chen 676ad850b6 Reverted commit D3703896
Summary:
This is a very hacky solution to make reloads from packager faster for simple file changes.

Simple means that no dependencies have changed, otherwise packager will abort the attempt to update and fall back to the usual rebuilding method.

In principle, this change avoids re-walking and analyzing the whole dependency tree, and just updates modules in existing bundles.

Reviewed By: bestander

Differential Revision: D3703896

fbshipit-source-id: abc2a41144536baf969d346522a17044c1c9558b
2016-08-12 16:58:26 -07:00
David Aurelio 626e510098 Make reloads faster for simple file changes
Summary:
This is a very hacky solution to make reloads from packager faster for simple file changes.

Simple means that no dependencies have changed, otherwise packager will abort the attempt to update and fall back to the usual rebuilding method.

In principle, this change avoids re-walking and analyzing the whole dependency tree, and just updates modules in existing bundles.

Reviewed By: bestander

Differential Revision: D3703896

fbshipit-source-id: 671206618dc093965822aed7161e3a99db69a529
2016-08-12 09:43:27 -07:00
ColCh 62e8a8fe56 make fsop timeout injectable
Summary:
We have a weak build machine for React Native app: a poor Mac Book Air with HDD, which is very slow.

So, fs operations sometimes fail because of timeout.

We likely don't care about build time, but it's pretty annoying to restart builds sometimes.

In this PR I make timeout injectable via environment variable.

__USAGE__:
export this variable into environment. It's measured in miliseconds.
Example, for 1 minute timeout:
`export REACT_NATIVE_FSOP_TIMEOUT=60000`

If you don't specify it, it will remain default value: `15000`

This should not break anything, but repair slow builds.

Related to : #9373 , #8794 (I think so)

This PR should handle case of issue and close #9373
Closes https://github.com/facebook/react-native/pull/9374

Differential Revision: D3709325

Pulled By: bestander

fbshipit-source-id: b00c89e10d05362314546faea7a4524f3d327c97
2016-08-12 07:28:38 -07:00
David Aurelio d613e622f4 Strip down asset data
Summary: This removes asset data that is not used at runtime from the bundle.

Reviewed By: javache

Differential Revision: D3628486

fbshipit-source-id: 33cd579c904e0b0e29502df39a4ff92cad43367c
2016-08-08 18:28:49 -07:00
Nikhilesh Sigatapu 0b9ca22fb2 Fix off-by-one error in range requests
Summary:
https://github.com/facebook/react-native/pull/8219 adds range requests to the asset server, but there was an off-by-one-error that made responses end prematurely. This made (for example) react-native-video not work for video assets. This change fixes the off-by-one error and react-native-video works with assets.

**Test plan (required)**

Try the test in the original pull request for range requests: https://github.com/facebook/react-native/pull/8219
Closes https://github.com/facebook/react-native/pull/9254

Differential Revision: D3680070

fbshipit-source-id: 3f2a18ba9f35b45b340f4a1046bc099b8444eb7d
2016-08-06 03:28:32 -07:00
Spencer Ahrens bc9c3fc902 fix console.table polyfill when entries are missing
Summary: Looks like react-addons-perf is sometimes missing entries. This prevents it from crashing.

Reviewed By: davidaurelio

Differential Revision: D3669007

fbshipit-source-id: 18a1102b5ad8dcfd9b80d39e1172ba85ad0e9dd2
2016-08-04 11:43:56 -07:00
androidtrunkagent 1fcceb0c5f Add support for passing in additional assetExts to packager
fbshipit-source-id: 42e508e37d960fbeb905a2ea8cb4741dba5c67fc
2016-08-02 10:27:25 -07:00
David Aurelio eeda397983 add `'change'` event to `HasteMap`
Reviewed By: bestander

Differential Revision: D3641360

fbshipit-source-id: 7941d0e954ad3e2aba1f16d797da280f6095aa05
2016-07-29 11:15:10 -07:00
David Aurelio f34bb8fb94 Bring back node-haste to fbsource
Summary:
Since jest stopped using node-haste a while ago, we are the only client left.
This brings back node-haste back to fbsource to allow us to iterate faster.

Reviewed By: bestander

Differential Revision: D3641341

fbshipit-source-id: a859f8834765723a3515e2cf265581b9dd83997c
2016-07-29 11:15:02 -07:00
Christoph Pojer 6501f74652 Update to 14.0
Reviewed By: kassens

Differential Revision: D3627753

fbshipit-source-id: 35b8246c8cb61e60908d8c233a6e72063bf67096
2016-07-27 22:13:26 -07:00
David Aurelio e0f6dfdadf Debounce progress updates
Summary: This shows at max 5 progress updates per second on the terminal, which results in a minor speedup of reloads.

Reviewed By: bestander

Differential Revision: D3620164

fbshipit-source-id: d1a30f2f29f7088602d276b8ad3fc8ff1b74c79d
2016-07-26 07:28:41 -07:00
David Aurelio 3263f18a6e Adapt jest transform for node-only files
Summary:
This changes the jest preprocessor so that files targetet at node.js will be run with the node-specific transform.
It also adapts tests that relied on inline requires.

Benefit: packager tests run faster now.

Reviewed By: cpojer

Differential Revision: D3562007

fbshipit-source-id: e06c86d545926a5c546458025f505dca115e7ea8
2016-07-15 06:28:26 -07:00
Mark Oswald 9d6414281e Use HTTP range requests (responses) to serve mp4 from assets
Summary:
This PR solves a problem when video assets are used from third-party React Native components (e.g. [react-native-video](https://github.com/brentvatne/react-native-video). The video will not work while the assets are served from the react native packager because the used video component (iOS) relies on HTTP range requests.

I added a small fix that allows ranged requests (e.g. mp4) to be served in ranges.

To test this:

1. make new react native project
1. add [react-native-video](https://github.com/brentvatne/react-native-video) to xcode project
1. add video component to your project
```
import Video from 'react-native-video';
var resolveAssetSource = require('react-native/Libraries/Image/resolveAssetSource');
/* ... /*
render() {
    let source = resolveAssetSource(require('./someVideoFile.mp4')) || {};
    return <Video /*....*/ source={source} />;
}
```

That should not work (if video is smaller than a few megabytes, open app a few times). Then add my fix, that should do the trick.
Closes https://github.com/facebook/react-native/pull/8219

Reviewed By: davidaurelio

Differential Revision: D3542485

Pulled By: frantic

fbshipit-source-id: e4f2e4d3aaafa8445e965259bf04ad107dba8a4f
2016-07-13 03:58:22 -07:00
Konstantin Raev 7ae3a72b5b fix: increased fs timeout for assetserver to test if this helps for large codebases
Reviewed By: jingc

Differential Revision: D3528913

fbshipit-source-id: f04eff42327bd729ebfcd71856a1d38ef9810986
2016-07-07 11:44:54 -07:00
Johannes Stein 81961d8756 Fixes typo in error message
Summary:
This pull request fixes a small typo when a module fails being transformed through the React Packager.
Closes https://github.com/facebook/react-native/pull/8596

Differential Revision: D3522272

Pulled By: mkonicek

fbshipit-source-id: e117a26bab5a99573ac68fb0e7618df0a14325a4
2016-07-06 08:13:45 -07:00
Konstantin Raev 8f5ebd55da Revert "Reverted commit D3516741"
Summary:
Unrevert a revert
Closes https://github.com/facebook/react-native/pull/8581

Differential Revision: D3517894

Pulled By: bestander

fbshipit-source-id: 19006b9c6438cf05d44ee152eb7b1b17ea4d61a0
2016-07-05 13:28:20 -07:00
Konstantin Raev e428436416 Reverted commit D3516741
Summary:
Looks like spaces in function names can happen, but the lib we use for parsing stacktraces doesn't support that. As result, when error is thrown in global scope, new JSC puts "global code" as function name, our parser chokes on it and thinks "global code@http://...." is a file name and sends it to packager. The packager can't resolve that URL and fails the whole symbolication request.

Longer term fix here: https://github.com/errwischt/stacktrace-parser/pull/5

Reviewed By: astreet

Differential Revision: D3516741

fbshipit-source-id: 7f14b52a50a118dc95a3463aee842941e904e984
2016-07-05 11:43:19 -07:00
Alex Kotliarskyi 1dcf2e0c7f Fix test broken by D3516741
Reviewed By: astreet

Differential Revision: D3517064

fbshipit-source-id: 8fe6fca1bc2c77872b1bf09bd114a3d490d9c834
2016-07-05 10:58:49 -07:00
Alex Kotliarskyi 8b00d98167 Don't attempt symbolicating non-http(s) urls
Summary:
Looks like spaces in function names can happen, but the lib we use for parsing stacktraces doesn't support that. As result, when error is thrown in global scope, new JSC puts "global code" as function name, our parser chokes on it and thinks "global code@http://...." is a file name and sends it to packager. The packager can't resolve that URL and fails the whole symbolication request.

Longer term fix here: https://github.com/errwischt/stacktrace-parser/pull/5

Reviewed By: astreet

Differential Revision: D3516741

fbshipit-source-id: 4f2bb70084437ed9d37495cd775622a8c981fad1
2016-07-05 09:43:26 -07:00
David Aurelio ed0b6b1ef5 Remove `node_modules/react` from the list of discoverable haste modules
Summary: This removes `node_modules/react` from the list of directories that are used for haste module resolutions. Modules required from React are now imported with `require('react/lib/…')`.

Reviewed By: astreet

Differential Revision: D3509863

fbshipit-source-id: 32cd34e2b8496f0a6676dbe6bb1eacc18124c01e
2016-07-05 06:44:33 -07:00
Christoph Pojer 21be7ecccf Update some JS in preparation for some Jest updates.
Summary:
* Next version of Jest doesn't allow non test files in __tests__ folders.
* I'm trying to switch all tests off of jsdom on react-native. This should save 500ms of time when running a single test because jsdom is slow to load and react-native is also not supposed to run in a DOM environment, so let's not pretend we are providing the DOM in tests.
* Make the bridge config configurable so that when we disable automocking and we reset the registry we can redefine the value.

Oh also, stop using lodash in Server.js. First off, lodash 3 doesn't work in Jest's node env because it does some crazy stuff, second because we don't need to load all of lodash for debounce.

Reviewed By: davidaurelio

Differential Revision: D3502886

fbshipit-source-id: 1da1cfba9ed12264d81945b702e7a429d5f84424
2016-06-30 01:58:40 -07:00
David Aurelio 6345d17c79 Print nicer error message if an asset directory is not found in any of the roots
Summary:
When an asset is included in a module, and the directory for that asset can't be found in any of the roots, it is hard to debug that, because the error message contains neither the name of the requested file, the sub directory it is located in, nor the roots that have been searched for it. It becomes more difficult, because that exception is created asynchronously. It contains the calling promise code.

This diff makes the error message more useful by including the name of the file, the sub directory, and the roots.

Reviewed By: bestander

Differential Revision: D3456738

fbshipit-source-id: 60b81f04626ad386f7120247c5f5361c81c52968
2016-06-20 10:13:22 -07:00
David Aurelio 930ef51646 make module IDs deterministic when bundling
Summary:
This makes sure that `getModuleId` is called on modules in the order returned by `node-haste`, rather than waiting for a couple of promises to resolve before calling the function.

Related: #7758

Reviewed By: frantic

Differential Revision: D3450853

fbshipit-source-id: 7f26590b39b94ade32c73a8db9fd31d283d57549
2016-06-17 12:58:49 -07:00
Benoit Lemaire 50d5275fc0 Cleanup packager dead debug endpoint
Summary:
When trying to access the debug dependency graph through the `/debug/graph` endpoint of the packager server (documented in the packager README and listed as well when hitting the root `/debug` endpoint), all I am getting back is a nasty HTTP 500 error :'(

What triggers this HTTP 500 is a `TypeError` being thrown while trying to access a function that doesn't exists (anymore). Here is the error log of the packager when trying to access this endpoint :

```
TypeError: this._depGraph.getDebugInfo is not a function
    at Resolver.getDebugInfo (index.js:270:27)
    at Bundler.getGraphDebugInfo (index.js:575:27)
    at Server._processDebugRequest (index.js:369:28)
    at Server.processRequest (index.js:423:12)
    at next (/Users/blemair/Code/DependencyGraphTest/node_modules/connect/lib/proto.js:174:15)
    at Object.module.exports [as handle] (cpuProfilerMiddleware.js:17:5)
    at next (/Users/blemair/Code/DependencyGraphTest/node_modules/connect/lib/proto.js:174:15)
    at Object.module.exports [as
Closes https://github.com/facebook/react-native/pull/8117

Differential Revision: D3445582

fbshipit-source-id: cf5af8bbba293f39773f32814a3b388b7ff67bf7
2016-06-16 14:28:29 -07:00
Marc Horowitz 3f058100cd Change the default guard behavior to throw the exception
Differential Revision: D3428928

fbshipit-source-id: 7847d7fac6a2dc1e4c58dfd5f97feea97ba58930
2016-06-14 16:28:46 -07:00
Tim Yung 9497520963 RN: Fix Symbolicate Logspew for `/debuggerWorker.js`
Summary:
When remote debugging is enabled, stack traces start at `/debuggerWorker.js`. Since this is not a valid bundle URL, the packager fails to decipher it to find its sourcemap.

This changes the packager to skip the `/debuggerWorker.js` stack frame if one exists.

Reviewed By: frantic

Differential Revision: D3418341

fbshipit-source-id: 7434aa45dea7d120d9d77c060101dd9403989d0c
2016-06-10 12:28:26 -07:00
Yann Pringault a4c9a2d0a6 Minor typo in Error message
Summary: Closes https://github.com/facebook/react-native/pull/8001

Differential Revision: D3404663

fbshipit-source-id: 0d0af84e4f6d31e6ddf79ef4e263737542b81361
2016-06-08 06:13:25 -07:00
David Aurelio dee7aadd28 inline `Platform.select`
Summary: We are already inlining `Platform.OS`. This diff adds support to inline calls to `Platform.select` with an object literal as first argument. The transform will replace the call with the property value corresponding to the platform, or `undefined` if it does not exist.

Reviewed By: frantic

Differential Revision: D3385391

fbshipit-source-id: bb068d17948ed84e381707faeaa0450399c2f306
2016-06-05 05:58:20 -07:00
Konstantin Raev ff01465701 removed unused code: _numPrependedModules
Summary:
cc davidaurelio
Closes https://github.com/facebook/react-native/pull/7873

Differential Revision: D3371406

Pulled By: javache

fbshipit-source-id: 72ed3838a88022ae5c0832dcca5abda75f18dbe1
2016-06-01 06:28:22 -07:00
Yann Pringault fb050c4520 Add Array.prototype.includes polyfill
Summary:
Add `Array.prototype.includes` polyfill.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes

I had all my `includes` running well on iOS 9 but when switching to Android `includes` threw an error.
[The compatibility table](http://kangax.github.io/compat-table/esnext/#test-Array.prototype.includes_Array.prototype.includes) shows that is not supported on Android yet as well as iOS 6-8.
With Chrome debugging it's working on both environment.
Closes https://github.com/facebook/react-native/pull/7756

Reviewed By: davidaurelio

Differential Revision: D3346873

Pulled By: vjeux

fbshipit-source-id: 2e17d29992873fbe4448b962df0423e516455b4b
2016-05-25 11:58:24 -07:00
David Aurelio 0dd8af0ea2 adapt instantiation of node-haste/DependencyGraph to new version
Reviewed By: bestander

Differential Revision: D3339969

fbshipit-source-id: 2b81f8019223b060f3e3afb940cc58360ed024e5
2016-05-24 05:13:27 -07:00
Eric Rozell 69a46e2c6e Update node-haste dependency to 2.12.0
Summary:
Update to node-haste 2.12.0 to support pass through configuration of supported platforms.
Closes https://github.com/facebook/react-native/pull/7660

Differential Revision: D3335034

Pulled By: mkonicek

fbshipit-source-id: d238b90a90d51654301d61251ceb26d183fef57a
2016-05-23 10:28:34 -07:00
Alex Kotliarskyi 31131746d8 Symbolicate JS stacktrace using RN Packager
Summary:
The way we currently symbolicate JS stack traces in RN during development time
(e.g. inside the RedBox) is the following: we download the source map from RN,
parse it and use `source-map` find original file/line numbers. All happens
inside running JSC VM in a simulator.

The problem with this approach is that the source map size is pretty big and it
is very expensive to load/parse.

Before we load sourcemaps:
{F60869250}

After we load sourcemaps:
{F60869249}

In the past it wasn't a big problem, however the sourcemap file is only getting
larger and soon we will be loading it for yellow boxes too: https://github.com/facebook/react-native/pull/7459

Moving stack trace symbolication to server side will let us:
- save a bunch of memory on device
- improve performance (no need to JSON serialize/deserialize and transfer sourcemap via HTTP and bridge)
- remove ugly workaround with `RCTExceptionsManager.updateExceptionMessage`
- we will be able to symbolicate from native by simply sending HTTP request, which means symbolication
  can be more robust (no need to depend on crashed JS to do symbolication) and we can pause JSC to
  avoid getting too many redboxes that hide original error.
- reduce the bundle by ~65KB (the size of source-map parsing library we ship, see SourceMap module)

Reviewed By: davidaurelio

Differential Revision: D3291793

fbshipit-source-id: 29dce5f40100259264f57254e6715ace8ea70174
2016-05-20 12:13:48 -07:00
Eric Rozell 17f30d8666 Adds packager configuration to support windows platform
Summary:
This pull request is a prerequisite to enabling the react-native-windows platform extension.

In the Resolver component, we need to add 'windows' to the list of platforms that are allowed in the DependencyGraph.  We also need to add 'react-native-windows' (the name of the Windows platform extension NPM module) to the `providesModuleNodeModules` option. This allows the node_module folder check in the DependencyGraphHelper from node-haste to be bypassed for *.windows.js files in the Windows NPM package.

For good measure, I also included a change to blacklist.js to ensure .windows.js files are ignored when the packager is parameterized on a platform.
Closes https://github.com/facebook/react-native/pull/7639

Differential Revision: D3327771

Pulled By: mkonicek

fbshipit-source-id: d1080b045ff6aa0cbf05d8070ceb0eb4cdb6dceb
2016-05-20 05:28:38 -07:00
Konstantin Raev bd7114d00f Added timeouts to fs operations in packager
Reviewed By: davidaurelio

Differential Revision: D3316555

fbshipit-source-id: edf6e08569b6cb434219f4460367eec0827530fd
2016-05-18 08:43:24 -07:00
Martín Bigio 5fbd3751a0 Reset hasError flag after HMR request
Summary:
This got broken recently. As a result of this, when a module throws while being required, either by regular load or hot reload, the module object is marked as `hasError`. Form that point all subsequent HMR updates will fail because it will think the module failed while executing the factory but the failure could have been on an old run of an old factory.

The fix is very simple: just reset `hasError` to false when accepting a module.
Closes https://github.com/facebook/react-native/pull/7567

Differential Revision: D3310685

fbshipit-source-id: 2f0b48ab7432b7c221d0c88a019a28969a8862b2
2016-05-17 11:58:31 -07:00
Martín Bigio 56c3a581b0 Avoid clearing out factory on DEV mode
Summary:
grabbou pointed out this issue.

We recently started cleaning out the factory function after module are required to save some memory. This broke HMR on some edge cases because sometimes the factory function may need to be re-executed. This PR just wraps the optimization into `__DEV__` to make sure we don't use it while developing.
Closes https://github.com/facebook/react-native/pull/7568

Differential Revision: D3305120

Pulled By: martinbigio

fbshipit-source-id: 741cffbb327d118f0bd0ec34dc1af53d4f94880e
2016-05-16 10:43:21 -07:00
David Aurelio c6d52e7a89 Use continuous module IDs for random access bundles
Reviewed By: bestander

Differential Revision: D3292980

fbshipit-source-id: ab5791d31add42a26cf55a0309564330c383eaa2
2016-05-12 17:28:25 -07:00
David Aurelio 9dcdb156f0 Allow already loaded modules to be `require`’d by name string in dev mode
Summary:
The code to require modules by their name (rather than their numeric ID) was buggy, because it didn’t check whether the module factory was already executed and the module already existed.

This diff checks the already loaded modules, too, when loading modules by name.

Reviewed By: lexs

Differential Revision: D3281350

fbshipit-source-id: cef236e152fe5484f21c877d6cee37433fa11c76
2016-05-10 09:37:20 -07:00
Pieter De Baets f9da45197f Cleanup InitializeJavascriptAppEngine
Reviewed By: davidaurelio

Differential Revision: D3235141

fb-gh-sync-id: 86fc844c5e9d9ea57d504696bac30671c2079e7a
fbshipit-source-id: 86fc844c5e9d9ea57d504696bac30671c2079e7a
2016-05-04 10:50:32 -07:00
David Aurelio 4608593dce Add verbose module names to dev builds
Summary:
This intends to make the devx story better after switching to numeric module IDs:

- `require('<verbose-name>)` works again for dev builds
- In dev builds, Systrace will use the verbose names of modules for markers

Reviewed By: bestander

Differential Revision: D3253318

fb-gh-sync-id: 3425d5086ce28634653a6c8c7f5f11afa1614902
fbshipit-source-id: 3425d5086ce28634653a6c8c7f5f11afa1614902
2016-05-04 09:33:22 -07:00
David Aurelio 5f53658fb0 remove support for `process.platform`
Reviewed By: javache

Differential Revision: D3252666

fb-gh-sync-id: af0e4987c34f43ec2472cbdf52fc112b81050513
fbshipit-source-id: af0e4987c34f43ec2472cbdf52fc112b81050513
2016-05-04 02:51:26 -07:00
David Aurelio daa426c46a @ignore-signedsource [react-native-packager] use a single require implementation
Reviewed By: javache, bestander

Differential Revision: D3252718

fb-gh-sync-id: bfd85acc28dd6e2df72a3227743514cb6f8c32f1
fbshipit-source-id: bfd85acc28dd6e2df72a3227743514cb6f8c32f1
2016-05-03 15:19:17 -07:00
David Aurelio 2a77da76ae Unify source map approach for RA bundles on iOS/Android
Reviewed By: javache

Differential Revision: D3229780

fb-gh-sync-id: a3148d7626b32a2e6803ae8c35ac75025a992a32
fbshipit-source-id: a3148d7626b32a2e6803ae8c35ac75025a992a32
2016-04-29 10:16:22 -07:00
David Aurelio 17726e1ae6 Improve constant inlining, add `process.platform`
Reviewed By: bestander

Differential Revision: D3235716

fb-gh-sync-id: f9019ec0042827e409fa84ba74f4c426ccad1519
fbshipit-source-id: f9019ec0042827e409fa84ba74f4c426ccad1519
2016-04-28 11:23:21 -07:00
Pieter De Baets cc538b9b35 Enable console.debug
Summary: Apparently what we're using for console.trace is not really the same as what Chrome does (we don't log a stacktrace). Add `console.debug` with the same functionality as `console.trace`, just so we don't crash between browser and local execution.

Reviewed By: davidaurelio

Differential Revision: D3235053

fb-gh-sync-id: 4bed17ac8aa4c8c100f15cf0aabbc25101c913c1
fbshipit-source-id: 4bed17ac8aa4c8c100f15cf0aabbc25101c913c1
2016-04-28 07:02:29 -07:00
David Aurelio 789978a9ec Upgrade to node-haste@2.10.0 and allow to specify extra node modules
Summary: This upgrades to node-haste@2.10.0 and allows to expose folders as additional node modules from rn-cli.config.js

Reviewed By: bestander

Differential Revision: D3232595

fb-gh-sync-id: dffca66fec55a79a2b3af1d6ec1b8799b2bbcf59
fbshipit-source-id: dffca66fec55a79a2b3af1d6ec1b8799b2bbcf59
2016-04-28 06:33:27 -07:00
Christoph Pojer d4e704be17 Update Jest APIs on fbsource
Reviewed By: javache

Differential Revision: D3229435

fb-gh-sync-id: b0e252d69e1f399a946fca6e98ef62ff44c2ef9c
fbshipit-source-id: b0e252d69e1f399a946fca6e98ef62ff44c2ef9c
2016-04-27 19:16:32 -07:00
Steven Luscher d07a52d887 Move `Number` polyfills into the `/polyfills/` directory
Reviewed By: vjeux

Differential Revision: D3223317

fb-gh-sync-id: a49a14f217b27d6542b65c4780c557e73da2443f
fbshipit-source-id: a49a14f217b27d6542b65c4780c557e73da2443f
2016-04-26 11:24:42 -07:00
Steven Luscher ca409964fc Add a `Number.isNaN` polyfill
Reviewed By: sahrens

Differential Revision: D3222299

fb-gh-sync-id: 601283fb0b140bb305181ea381907e62286f7a37
fbshipit-source-id: 601283fb0b140bb305181ea381907e62286f7a37
2016-04-25 23:15:18 -07:00
Alexander Micklewright 05871df2a9 Fix a bug in asset server when using relative project roots
Summary:This PR fixes a bug where when using relative roots for the packager server, asset paths would be deemed invalid by the recently introduced security check. Resolving the root to an absolute path fixes that problem.

I'd be happy to write a regression test for this but I had a hard time setting up a mock file system with relative paths. If it is required, some help would be appreciated...
Closes https://github.com/facebook/react-native/pull/7161

Differential Revision: D3214840

fb-gh-sync-id: 08e13fb9f94a98206fd2d090f74a8b63ba2bf80f
fbshipit-source-id: 08e13fb9f94a98206fd2d090f74a8b63ba2bf80f
2016-04-22 16:06:21 -07:00
Pieter De Baets bdc9749ba0 Improve error handling in require-unbundle
Reviewed By: davidaurelio

Differential Revision: D3207450

fb-gh-sync-id: 35247c265e35976dcee9fca4215403efa604479e
fbshipit-source-id: 35247c265e35976dcee9fca4215403efa604479e
2016-04-22 06:18:26 -07:00
David Aurelio faa9adf2ab Allow for falsy module exports
Reviewed By: javache

Differential Revision: D3207353

fb-gh-sync-id: 3e23eb9cc9facea7993ce684f87ff4b7b0003a1c
fbshipit-source-id: 3e23eb9cc9facea7993ce684f87ff4b7b0003a1c
2016-04-21 06:49:20 -07:00
Mike Grabowski ae9f74e68d Strip shebang when present in JS files
Summary:Fixes #7034
Closes https://github.com/facebook/react-native/pull/7073

Differential Revision: D3199816

fb-gh-sync-id: 2099dd1f81b030933794be6a592a697cec3627d0
fbshipit-source-id: 2099dd1f81b030933794be6a592a697cec3627d0
2016-04-19 18:09:22 -07:00
Tadeu Zagallo f0e4826c46 Free modules' factories after caching module
Summary:The require functions will keep the generate bytecode + lexical environment in
memory unnecessarily, since we can be sure that it will be executed at most once

Reviewed By: davidaurelio

Differential Revision: D3168257

fb-gh-sync-id: 038e1bc08abea94ee52d0390b6aced5fb652f493
fbshipit-source-id: 038e1bc08abea94ee52d0390b6aced5fb652f493
2016-04-19 08:13:24 -07:00
Leland Richardson b7b8861b75 Whitelist the 'pdf' extension in the packager
Summary:The WebView component in iOS currently does not support displaying PDFs without providing a remote URI or manually including the assets in the xcodeproj itself. This is because the packager has not whitelisted the 'pdf' extension.

I've gone ahead and whitelisted the 'pdf extension according to the recommendation by nicklockwood

GH comment: https://github.com/facebook/react-native/issues/1846#issuecomment-199302488
Closes https://github.com/facebook/react-native/pull/7004

Differential Revision: D3196019

Pulled By: nicklockwood

fb-gh-sync-id: 10a86a9232095f98f277506141de0b8af5b21ab4
fbshipit-source-id: 10a86a9232095f98f277506141de0b8af5b21ab4
2016-04-19 03:52:27 -07:00
Sam Swarr 43c5ed2be0 Delete SocketInterface code
Reviewed By: davidaurelio

Differential Revision: D3152105

fb-gh-sync-id: a6c13bb54c2164ebc063a1b14f00114738546c8c
fbshipit-source-id: a6c13bb54c2164ebc063a1b14f00114738546c8c
2016-04-11 14:38:26 -07:00
Sam Swarr 1d9df442a4 Remove socket interface from dependencies command
Reviewed By: davidaurelio

Differential Revision: D3136438

fb-gh-sync-id: 51fce2caf60fdf32a8cba180c79b1996834cda6e
fbshipit-source-id: 51fce2caf60fdf32a8cba180c79b1996834cda6e
2016-04-11 09:23:29 -07:00
Thomas Aylott f9a9cd6f25 Fixes hotcode reloading issue
Reviewed By: martinbigio

Differential Revision: D3136032

fb-gh-sync-id: 5666fd45ffa574d2156b03c7bfbda3fe97090f56
fbshipit-source-id: 5666fd45ffa574d2156b03c7bfbda3fe97090f56
2016-04-06 12:14:20 -07:00
Adam Miskiewicz 65b0f7c868 Pass transformOptions to getShallowDependencies.
Summary:We weren't passing `transformOptions` to `getShallowDependencies`, and therefore, when this method was called on a module, it would bust the cache and cause a retransform of the file. This was resulting in a complete retransforming of all files when the HMR Client connected to the packager.
Closes https://github.com/facebook/react-native/pull/6843

Differential Revision: D3145306

Pulled By: martinbigio

fb-gh-sync-id: 3619c27801b2fc07b758fafed47fcc892bb8e6db
fbshipit-source-id: 3619c27801b2fc07b758fafed47fcc892bb8e6db
2016-04-06 11:38:27 -07:00
Nick 27e79ff0c3 CHORE - Remove Trailing Spaces
Summary:Remove Trailing Spaces.

Why:
Sometimes there are conflicts with trailing spaces
Saves space
Those whose tools automatically delete them will have their pr watered down with trailing space removal
Closes https://github.com/facebook/react-native/pull/6787

Differential Revision: D3144704

fb-gh-sync-id: d8a62f115a3f8a8a49d5b07f56c540a02af38cf8
fbshipit-source-id: d8a62f115a3f8a8a49d5b07f56c540a02af38cf8
2016-04-06 09:21:53 -07:00
Konstantin Raev 6f9aad3641 Fixed images required from node_modules
Summary:This fixes https://github.com/facebook/react-native/issues/6638 by resolving AssetRegistry relatively.
Closes https://github.com/facebook/react-native/pull/6822

Reviewed By: davidaurelio

Differential Revision: D3144463

Pulled By: bestander

fb-gh-sync-id: d3eeb24ae9e08a32f742c50ae5f0314fd33d1b6b
fbshipit-source-id: d3eeb24ae9e08a32f742c50ae5f0314fd33d1b6b
2016-04-06 07:59:29 -07:00
Janic Duplessis 30bdfdd370 Fix HMR on Windows
Summary:Tested HMR on Windows and found 2 small issues related to paths that made it not work. Now it works nicely :)

**Test plan (required)**
Tested HMR in UIExplorer on Windows.
Closes https://github.com/facebook/react-native/pull/6678

Differential Revision: D3138379

fb-gh-sync-id: f27cd2fa21f95954685c8c6916d820f41bc187be
fbshipit-source-id: f27cd2fa21f95954685c8c6916d820f41bc187be
2016-04-05 01:13:18 -07:00
Mart?n Bigio 97e1db3e6c Avoid getting `entryFilePath` on HMR codepath
Summary: The HMR codepath is currently broken because of a recent change that tries to compute the absolute entryFile path (needed for RAM Bundling). HMR Bundler's bundles are special as they contains a single file (the file that was transformed). However, for performance reasons we recycle an existing resolution response which contains the polyfills and the module system modules.

Reviewed By: sam-swarr

Differential Revision: D3098069

fb-gh-sync-id: 23d61aa304cd6f59d4df4840965f5eedda05dc31
fbshipit-source-id: 23d61aa304cd6f59d4df4840965f5eedda05dc31
2016-03-25 08:45:21 -07:00