Commit Graph

757 Commits

Author SHA1 Message Date
Maël Nison 167bda72b0 Fixes various issues on the Metro CLI
Reviewed By: rafeca

Differential Revision: D6407718

fbshipit-source-id: 871dd77fad4fcf8f6b0fa628bacc0dfb6cb51484
2017-11-27 04:36:12 -08:00
Burak Yigit Kaya 319220d870 Do not return a promise from transformers unless we have to
Reviewed By: mjesun

Differential Revision: D6405568

fbshipit-source-id: 09463442aecdb844e18498c3b3ce169d2915fe77
2017-11-27 02:32:39 -08:00
Rafael Oleza 091f8560f2 Make inlineRequires boolean when passed to the transformer
Reviewed By: mjesun

Differential Revision: D6408081

fbshipit-source-id: 812c8e3983677f4133ef3080525859a4a70418b7
2017-11-26 11:20:57 -08:00
Rafael Oleza 2d03a34bbc Remove isJSON() method from Module
Reviewed By: cpojer

Differential Revision: D6408739

fbshipit-source-id: 3f1b76ca54937fbc433d4e7a804a9703a3a2ccb7
2017-11-24 13:06:22 -08:00
Rafael Oleza 75047399d8 Simplify transform options + pass minify to the transformer
Reviewed By: mjesun

Differential Revision: D6406614

fbshipit-source-id: 722e8e209c7b7c922139f0777b9b3bd2a77bf735
2017-11-24 13:06:22 -08:00
Christoph Nakazawa 06466e4f6e Remove some of the whitespace from the progess output
Reviewed By: rafeca

Differential Revision: D6408458

fbshipit-source-id: 2e6c50baedbd53ce4271edc337fada3b628d9c63
2017-11-24 11:56:57 -08:00
Rafael Oleza b08ce130fd Move wrapModule logic for scripts, modules and JSON files to the transformer
Reviewed By: davidaurelio

Differential Revision: D6389116

fbshipit-source-id: fa43bd54669849c22b6b9d155ab07676b2455ef7
2017-11-23 15:40:03 -08:00
Rafael Oleza b193fc3436 BREAKING: metro transformers should only output AST
Reviewed By: jeanlauliac

Differential Revision: D6396416

fbshipit-source-id: e4c6f0c0feb1ac638dc13dd3eb400f1bc72b5d44
2017-11-23 15:40:03 -08:00
Jean Lauliac f434d43f54 metro-bundler: RAM bundles cannot contain scripts masquerading as modules
Reviewed By: davidaurelio

Differential Revision: D6405614

fbshipit-source-id: 6c21fd30d6246f50c34e9f23a193452737a3b67b
2017-11-23 12:10:21 -08:00
Peter van der Zee ccd8eae0b0 Fix terminal string chunker to ignore non-printable color seqs
Reviewed By: rafeca

Differential Revision: D6405127

fbshipit-source-id: 94fd12a04db43a790af34fdee36be9d7f8ecf59d
2017-11-23 10:11:54 -08:00
Burak Yigit Kaya b7ba5c7ee1 Support async transformers
Reviewed By: rafeca, mjesun

Differential Revision: D6405491

fbshipit-source-id: 7110135e9f75ab43c03710abfa8e582577662ab3
2017-11-23 09:56:44 -08:00
Peter van der Zee a766a4a499 Update http progress output in cli; add platform, shorten rest
Reviewed By: rafeca, davidaurelio

Differential Revision: D6395717

fbshipit-source-id: 0fed7f29539bb59bc300d88b09a99be13bbb42ba
2017-11-23 08:27:13 -08:00
Rafael Oleza 6557272f8c Avoid losing deltas when unexpected errors happen on the DeltaTransformer
Reviewed By: jeanlauliac

Differential Revision: D6402261

fbshipit-source-id: 6a1a18c1bd7d4f7cecd5a5e9114f6eb493d40b4d
2017-11-23 08:27:13 -08:00
Rafael Oleza 70dadc63f9 Update Readme + change default transform
Reviewed By: cpojer

Differential Revision: D6401596

fbshipit-source-id: 8928abb825933edd84c508a4f04f50c748725722
2017-11-23 03:06:48 -08:00
Burak Yigit Kaya 7b5ae96479 Add option to bypass AssetRegistry and sending assets to transforms
Reviewed By: rafeca

Differential Revision: D6385816

fbshipit-source-id: b94fb125bee0576cfb25170aa86a253c10a3d862
2017-11-23 02:38:19 -08:00
Rafael Oleza 5f58ae0e84 Metro reads AST from transformers if available
Reviewed By: BYK

Differential Revision: D6396330

fbshipit-source-id: 10539a1cce81b090a781df7d75515d52ece9ef9c
2017-11-22 13:36:20 -08:00
Rafael Oleza c9e0589171 Allow HMR client accept wrapped modules from metro
Reviewed By: davidaurelio

Differential Revision: D6385273

fbshipit-source-id: 15109332aceb4c0523c668a54b1bf40d8e8fba80
2017-11-22 11:37:20 -08:00
Jean Lauliac 52a76cb5af packager-worker-for-buck: refactor and fix source map output
Reviewed By: davidaurelio

Differential Revision: D6385199

fbshipit-source-id: f104f7b000dde131b57b671d14d4ec4e0d30d7a2
2017-11-22 05:08:49 -08:00
Peter van der Zee efceeacd77 Move Option types from Server to shared/types.flow
Reviewed By: davidaurelio

Differential Revision: D6384292

fbshipit-source-id: 58cba889f549cbd7a8c82856d5283048f4f2a8c5
2017-11-22 03:57:33 -08:00
Rafael Oleza d4b7cb5d08 Bump metro to v0.21.1
Reviewed By: mjesun

Differential Revision: D6385524

fbshipit-source-id: 189f03466f8e84a9ac3acfd1aa0faf4f39d394f2
2017-11-21 10:28:18 -08:00
Jean Lauliac 507fbd7d7e packager-worker-for-buck: store resolutions at library level
Reviewed By: davidaurelio

Differential Revision: D6359267

fbshipit-source-id: 795d451c6ff32c07842e9e067778136180a9988e
2017-11-21 07:08:28 -08:00
Rafael Oleza 6ec09775ef Upgrade uglify-es to 3.1.9
Reviewed By: davidaurelio

Differential Revision: D6309485

fbshipit-source-id: 17d8b66a2a676a9a556509e28a48ee703fc6da89
2017-11-21 06:44:11 -08:00
Rafael Oleza 085dd97fa0 Change getModuleId() signature to directly accept a path
Reviewed By: mjesun

Differential Revision: D6373180

fbshipit-source-id: d6b49431adf85e7587cf0fe858d9dc9b9afeee06
2017-11-21 05:45:44 -08:00
Rafael Oleza e58b7f1d73 Do not calculate inverseDependencies when processing a standard delta bundle
Reviewed By: mjesun

Differential Revision: D6373006

fbshipit-source-id: 86863595b1e5f0417e898f19f21ed83147b46db3
2017-11-21 05:45:44 -08:00
Jean Lauliac b77f177f92 metro-bundler: add additional tip for resolution errors
Summary: Rebase of a PR, closes https://github.com/facebook/metro-bundler/pull/39/files

Reviewed By: cpojer

Differential Revision: D6372967

fbshipit-source-id: 84c77b7e445269638616abde56b728ea6d3e475c
2017-11-21 02:23:09 -08:00
Maël Nison c2c99c4c1b Fixes for the Metro cli
Reviewed By: BYK

Differential Revision: D6348698

fbshipit-source-id: 3a00d9af7e03c5d636e2a51ce95842ca7d45b6e1
2017-11-20 10:47:46 -08:00
Rafael Oleza eb1ddfdcd9 Fix initializing packager logging
Reviewed By: cpojer

Differential Revision: D6359527

fbshipit-source-id: 0741955ca0efd6d5735637407e1bc140f04c3bbf
2017-11-18 17:10:51 -08:00
Christoph Nakazawa 6d756334a8 Fix CI
Reviewed By: rafeca

Differential Revision: D6368078

fbshipit-source-id: 04232ac3762ce4c9581c694a60c1372b2f495af0
2017-11-18 10:45:32 -08:00
Christoph Nakazawa 2c6aa5c5d8 Remove unused vars
Reviewed By: davidaurelio

Differential Revision: D6362298

fbshipit-source-id: 8a79663e4f83d7b15919f2a1a8dd9416900f3203
2017-11-18 01:10:15 -08:00
Christoph Nakazawa 5fdef3bdb2 Update Flow and Lerna for the Metro repo
Summary: I'm working on getting CI to pass. As a first step, I'll upgrade the lerna setup to use Yarn's workspaces (when yarn is run from the Metro root) as well as upgrading Flow to the same version we use in xplat. I also copied over the Jest type definitions. This should fix all type errors for a start.

Reviewed By: davidaurelio

Differential Revision: D6361276

fbshipit-source-id: 4e8661b7d5fe4e3f6dd1e6923891bd2d23c9b4db
2017-11-18 01:10:15 -08:00
Maël Nison c6b0134398 Removes debug
Reviewed By: rafeca

Differential Revision: D6358889

fbshipit-source-id: f04a6dd33dac72d0ad9ceb56c49215ebc53452ff
2017-11-17 07:51:46 -08:00
Jean Lauliac f0a4418b5b metro-bundler: ModuleGraph: nit: reduce code nesting
Reviewed By: davidaurelio

Differential Revision: D6324409

fbshipit-source-id: da7626772cb24b4f3749962e72e5952982b917d6
2017-11-15 06:22:04 -08:00
Rafael Oleza c04393b397 Fix sending multipart delta responses
Reviewed By: jeanlauliac

Differential Revision: D6328147

fbshipit-source-id: fcd16e64180a49bad0a0c606ab0f2bdd2d9ac0ee
2017-11-15 03:06:04 -08:00
Jean Lauliac 56e790f958 metro-bundler: ModuleGraph: fix in-memory node-haste impl error
Reviewed By: cpojer

Differential Revision: D6323532

fbshipit-source-id: 067be85171d8d8839c977bd2aa7fdc7efc178f0a
2017-11-14 06:08:17 -08:00
Benjamin Weggersen b75f385524 Normalize module name to have platform specific folder separators
Summary:
<!-- Thanks for submitting a pull request! Please provide enough information so that others can review your pull request. The two fields below are mandatory. -->

**Summary**

<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->

It is currently not possible to resolve specific module imports (such as `react-native/Libraries/Image/AssetRegistry` using forward slashes as folder separators) using a custom mapping defined in `extraNodeModules` on Windows. This PR solves this issue by normalizing module names to use platform-specific folder separators before splitting the module name using `path.sep` as separators.

**Test plan**

<!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI. -->

We use `extraNodeModules` to create a mapping between `react-native` and a forked and scoped version of react-native (i.e. `scope/react-native`). If we import a specific file from react-native (such as [`react-native/Libraries/Image/AssetRegistry`](https://github.com/facebook/react-native/blob/master/local-cli/core/Constants.js), which gets referenced when importing image assets), `ModuleResolution.js` is not able to extract the first folder name on Windows. This first folder name is the name of the module (`react-native` in the previous example) and is used to query `extraNodeModules` for possible matches. It is not able to find this folder name because the module name is split using `path.sep` as a separator, which is `'\\'` on Windows. Most module names use forward slashes as folder separators. The solution is to normalize `toModuleName` before we split on `path.sep`.
Closes https://github.com/facebook/metro-bundler/pull/89

Differential Revision: D6312391

Pulled By: jeanlauliac

fbshipit-source-id: 920c52633e8c9584ecb2bdd309dc4a8516c3199b
2017-11-14 02:52:35 -08:00
Maël Nison 1bd30c977d Adds an experimental metro-cli to metro-bundler
Reviewed By: davidaurelio

Differential Revision: D6129384

fbshipit-source-id: b32049ad17aeae74cde23dbaa79845e6a4a51507
2017-11-13 17:36:35 -08:00
Rafael Oleza e1b5fe79fa Remove ModuleTransport/ResolutionResponse modules and lots of logic from Resolver/ResolutionRequest
Reviewed By: davidaurelio

Differential Revision: D6284728

fbshipit-source-id: 53d27cd65b8c96ed6d6872eb16a9b5d1e14db85e
2017-11-13 16:43:36 -08:00
Rafael Oleza 860dcc4867 Use current DependencyGraph tests as integration tests for the traverseDependency logic
Reviewed By: davidaurelio

Differential Revision: D6284627

fbshipit-source-id: 7e3f21c53142238f7d50444627c417388a4c1d1d
2017-11-13 16:43:36 -08:00
Rafael Oleza f1728e4c7b Add support for the postProcessModules param
Reviewed By: davidaurelio

Differential Revision: D6277777

fbshipit-source-id: b9a0341f17f3829ccc3daf7db89275f07e435803
2017-11-13 16:43:36 -08:00
Caleb Meredith 42a547551f Flow 0.59 xplat/js deploy
Reviewed By: avikchaudhuri

Differential Revision: D6300238

fbshipit-source-id: a6839fa2a9bbc50c3832a3f5b1cac2a6d2bd96b7
2017-11-10 21:12:40 -08:00
Rafael Oleza 1dec296000 Downgrade uglify-js from 3.1.8 to 3.1.1
Summary:
Uglify@3.1.7 is causing some perf issues (more specifically, this commit: 5b4b07e9a7) that are impacting TTI on RN views and increased memory usage.

More specifically, code like:

```
function nonTrivialFn(pre) {
  return pre + Math.random();
}
function hotFunctionCalledALotOfTimes(num) {
  return nonTrivialFn(num + Math.random());
}
hotFunctionCalledALotOfTimes(3);
hotFunctionCalledALotOfTimes(5);
```

in v3.1.7 gets converted to:

```
function hotFunctionCalledALotOfTimes(num){
  return function(pre) {
    return pre + Math.random();
  }(num + Math.random())
}
hotFunctionCalledALotOfTimes(3);
hotFunctionCalledALotOfTimes(5);
```

This causes a function creation each time `hotFunctionCalledALotOfTimes` is called.

By comparison, in v3.1.6, that previous code was converted to:

```
function nonTrivialFn(pre){
  return pre + Math.random()
}
function hotFunctionCalledALotOfTimes(num){
  return nonTrivialFn(num + Math.random())
}
hotFunctionCalledALotOfTimes(3);
hotFunctionCalledALotOfTimes(5);
```

Reviewed By: jeanlauliac, alexeylang

Differential Revision: D6296740

fbshipit-source-id: b3988d886e607103ec3ae6b9763b2f0411a8aa3c
2017-11-10 04:52:50 -08:00
Miguel Jimenez Esun e08b34239e Add asset size to the module
Reviewed By: jeanlauliac

Differential Revision: D6284248

fbshipit-source-id: 3b860d7b123a1d2470c7b6c7e9e9082d0622c369
2017-11-10 03:20:52 -08:00
Rafael Oleza e7b4e50813 Fix flow types of sourcemaps
Reviewed By: davidaurelio

Differential Revision: D6271757

fbshipit-source-id: abf9c91a4ebd36eb4cd77acf75c40f85fbecd5f9
2017-11-08 13:03:43 -08:00
Rafael Oleza 7b93876541 Remove old Bundler/* logic
Reviewed By: mjesun

Differential Revision: D6259048

fbshipit-source-id: b39e4c602a0af9d2ad91b72a699b1369526ac9f2
2017-11-08 13:03:43 -08:00
Rafael Oleza 2eefccc72a Remove old bundler code from Server class
Reviewed By: mjesun

Differential Revision: D6255868

fbshipit-source-id: 74695129199c8be43e13c97f2ae2ca2c03b801eb
2017-11-08 13:03:43 -08:00
Rafael Oleza 8f45fb6bf3 BREAKING: Bump metro-bundler to v0.21.0
Summary:
`metro-bundler` v0.21 contains a rewritten bundling mechanism, with simplified logic and much faster rebuild times, called delta bundler. This release contains a couple of breaking changes:

* Now, when using a custom transformer, the list of additional babel plugins to apply are passed to the `transform()` method. These are used in non-dev mode for optimization purposes (Check 367a5f5db8 (diff-40653f0c822ac59a5af13d5b4ab31d84) to see how to handle them from the transformer).
* Now, when using a custom transformer outputting `rawMappings`, the transformer does not need to call the `compactMappings` method before returning (check d74685fd1d (diff-40653f0c822ac59a5af13d5b4ab31d84) for more info).
* We've removed support for two config parameters: `postProcessModules` and `postProcessBundleSourcemap`.

Reviewed By: davidaurelio

Differential Revision: D6186035

fbshipit-source-id: 242c5c2a954c6b9b6f339d345f888eaa44704579
2017-11-08 09:20:17 -08:00
Rafael Oleza 08ed373a60 Add postMinifyModule param support to Delta Bundler
Reviewed By: mjesun

Differential Revision: D6264450

fbshipit-source-id: 1dd0bc8c5957d99b6f4b6722c843fe9cc284ec3a
2017-11-08 07:07:46 -08:00
Rafael Oleza 98518c9fff Add ramGroups and preloadedModules support when creating RAM bundles
Reviewed By: davidaurelio

Differential Revision: D6250307

fbshipit-source-id: b7143fa31ded9fcaa28025f05b9d28013361ea0e
2017-11-08 07:07:46 -08:00
Miguel Jimenez Esun 91f724d69d Update Jest to 21.3.0-beta.8
Reviewed By: davidaurelio

Differential Revision: D6221784

fbshipit-source-id: 189e895378635dd21d14d6fb1f93510a52c90742
2017-11-08 06:50:53 -08:00
Rafael Oleza ed55e0a53f Remove cyclic dependency when getting the transform options
Reviewed By: davidaurelio

Differential Revision: D6231766

fbshipit-source-id: ae200a4507febcd47bcc636d0e62f01eb6a93477
2017-11-08 04:07:07 -08:00
Andreas Amsenius b0c79aa193 Upgrade uglify-es to fix minification issues
Summary:
**Summary**

Minification fails or minified bundle may crash due to uglify-es bugs which have been fixed recently. See https://github.com/facebook/react-native/issues/16689

**Test plan**

Try to production bundle a project using ex-navigation, which fails with:
```
Maximum call stack size exceeded
```

Use this patch and see that bundling suceeds. There are also minified runtime errors solved by this change, see https://github.com/facebook/react-native/issues/16689 for more information.
Closes https://github.com/facebook/metro-bundler/pull/85

Reviewed By: mjesun

Differential Revision: D6259177

Pulled By: rafeca

fbshipit-source-id: 55987eb338b06938181c0da74d104d23eeb135b6
2017-11-07 08:28:17 -08:00
Rafael Oleza 8fe2d588bc Use Delta Bundler to get all bundle assets
Reviewed By: mjesun

Differential Revision: D6255563

fbshipit-source-id: fe08021ef6be8528ddcbb553be62e8a8cf2bcf0a
2017-11-07 08:10:32 -08:00
Miguel Jimenez Esun d4dcd4c6fa Migrate metro-bundler to jest-worker
Summary:
This diff migrates Metro Bundler from `worker-farm` to `jest-worker`:

* Fully removes the custom patched `worker-farm` fork.
* Removes //a lot// of non-clear Flow types used to cast functions from callbacks to promises.
* Reduces cyclomatic complexity of the `Transformer` class by using `async`/`await`.
* Cleans all additional methods inside `JSTransformer/index.js`, by moving them to a single class and properly scoping them.

**Note:**  this diff does not still enable the ability to bind files to workers by using `computeWorkerKey`; this will come at a later stage.

Reviewed By: davidaurelio

Differential Revision: D6247532

fbshipit-source-id: 51259360a5c15117996777a3be74b73b583f595e
2017-11-07 07:52:16 -08:00
Jean Lauliac 81bfef0389 metro-bundler: allow different run-before-main-module depending on entry point
Reviewed By: davidaurelio

Differential Revision: D6248242

fbshipit-source-id: 9471820fce926e676170e3024bd48c9d7335c1a7
2017-11-07 07:41:58 -08:00
David Aurelio 2c5a2fec66 fix `$FlowFixMe`
Reviewed By: rafeca

Differential Revision: D6258938

fbshipit-source-id: 7331d0a3216c1714099139fe6c6ab8fe11771fae
2017-11-07 06:22:55 -08:00
Jean Lauliac dbb2d44c42 metro-bundler: collect-dependencies: expose async deps
Summary: To determine whether segment boundaries are properly covered by async imports rather than requires, we need to get knowledge about it higher up in the stack. This changeset exposes which of the dependencies are async as an array of indices within the `dependencies` array (I'd prefer avoiding duplicating the strings because they could get inconsistent, and I don't want to have 2 separate arrays of names either because we'd have to modify a bunch of stuff across the stack to support that).

Reviewed By: davidaurelio

Differential Revision: D6220236

fbshipit-source-id: 1ee36bc7c59f7f27e089f7771a24c45c8bd57b5d
2017-11-06 03:40:10 -08:00
Jean Lauliac 41ec9e6d4d react-native: BundleSegments
Reviewed By: davidaurelio

Differential Revision: D6231309

fbshipit-source-id: 565cbadedc5fd8ab25025b5846c098f24fb15a82
2017-11-06 03:40:10 -08:00
Miguel Jimenez Esun 0a292a2a58 Add code for generating remote assets
Reviewed By: davidaurelio

Differential Revision: D6201839

fbshipit-source-id: 78c81eae03c6137ba9bbe33cd7aab8b87020f8d2
2017-11-03 06:10:20 -07:00
Jia Li 0664367460 Revert D6210177: react-native: BundleSegments
Differential Revision: D6210177

fbshipit-source-id: 8cb4ee37cd03698e9f3980a9819269086a9d6eab
2017-11-02 12:04:31 -07:00
Avik Chaudhuri 4ed2139567 @allow-large-files Flow 0.58 upgrade for xplat/js
Reviewed By: yungsters

Differential Revision: D6219339

fbshipit-source-id: f003111500ef5971b9a95f26d43cee6644c16abe
2017-11-02 10:51:15 -07:00
Jean Lauliac 3129532cd9 react-native: BundleSegments
Reviewed By: davidaurelio

Differential Revision: D6210177

fbshipit-source-id: c39e4118389a9739e9e70ba34feb5d335a7f2546
2017-11-02 09:57:43 -07:00
Miguel Jimenez Esun 1ec323bbd5 Adding @email tags to most of the tests
Reviewed By: rafeca

Differential Revision: D6185623

fbshipit-source-id: 30df83288fe85516d8d5a1617a4fb8fea826ed6f
2017-11-02 06:25:10 -07:00
Rafael Oleza 26718da993 Fix flacky Server-test in metro
Reviewed By: mjesun

Differential Revision: D6220171

fbshipit-source-id: 603671db9a6345dd039c443eb14593e3631c7a88
2017-11-02 06:18:20 -07:00
Rafael Oleza cecb9bae99 Make metro always use the delta bundler
Reviewed By: jeanlauliac

Differential Revision: D6208727

fbshipit-source-id: 08589cc92de340d896833cfee2ed14b48b1e6f38
2017-11-01 20:02:10 -07:00
Rafael Oleza cdfe5b0f20 Remove buildBundle() method from metro public API
Reviewed By: mjesun

Differential Revision: D6208701

fbshipit-source-id: 9e2f20df778cdaad542466692256ca4740a7fb38
2017-11-01 14:53:59 -07:00
Jean Lauliac 64645cbaab react-native: move out the hardcoded import() transform
Reviewed By: davidaurelio

Differential Revision: D6196869

fbshipit-source-id: 237cd269a2f382851102e3e1ba3208f1460f8c0a
2017-11-01 05:36:24 -07:00
Rafael Oleza cd67cd4794 Update shared/output modules to accept the output from the Delta Bundler
Reviewed By: davidaurelio

Differential Revision: D6186386

fbshipit-source-id: 6160f5a02891dbfb56c6350239703ace91e53690
2017-10-31 10:26:10 -07:00
Rafael Oleza ff7ec2e6bf Prepare metro to build production bundles using the Delta Bundler
Reviewed By: davidaurelio

Differential Revision: D6186012

fbshipit-source-id: a9c2757211345881e3feba331bdbe66cdc0f6b97
2017-10-31 10:26:10 -07:00
Rafael Oleza 775867445a Make sourcemap flow types non-nullable
Reviewed By: mjesun

Differential Revision: D6185460

fbshipit-source-id: c33bac5f0e70c142d6238043ce8c2996f1d1ee50
2017-10-31 10:26:10 -07:00
Rafael Oleza 437a6a3f27 Add minify support to the Delta Bundler
Reviewed By: davidaurelio

Differential Revision: D6163566

fbshipit-source-id: d49eab159ee1d1b4453136f21e25e48154d0142a
2017-10-31 10:26:10 -07:00
Rafael Oleza 772d21f72d Move the getAssetData() logic out of the Bundler
Reviewed By: davidaurelio

Differential Revision: D6183424

fbshipit-source-id: 47a658de25ac0943f4b82e7eb90c1018e9d0357d
2017-10-31 09:16:18 -07:00
Rafael Oleza 2850627a66 Add prettier to metro-bundler
Reviewed By: mjesun

Differential Revision: D6187278

fbshipit-source-id: 05b0881743b69c4a1eb491a6f8c57581081a85e4
2017-10-31 03:51:26 -07:00
Jean Lauliac bada7f8684 metro-bundler: ModuleGraph tests: @flow
Summary: Having types in tests ensure that we're testing what the API is supposed to process and not something else. In that case, adding type revealed that we were mistakenly passing strings instead of `Buffer` objects to the transform and optimize functions, but it would still work because `toString` was called over it. Passing proper `Buffer` objects as expected ensures that it doesn't just work with strings, and that the integration of these files in the rest of the application works as expected. This changeset fixes these callsites and add a few invariants here and there. We use `invariant` instead of `expect()` because Flow understands only the former as a type refinement, even though `expect` would also be a form of possible refinement. I don't think it's a big deal.

Reviewed By: davidaurelio

Differential Revision: D6160019

fbshipit-source-id: cbcbb05d7bccf9e1b9f6bb3ea30b0bb2925aef1b
2017-10-30 11:05:13 -07:00
Jean Lauliac c293f4bfab metro-bundler: stricter TransformedCodeFile type and fix use sites
Summary: Here's a good example why Flow "exact types" are useful: there are a few place where we were adding unusused fields in the objects. As these fields end up in JSON files used to communicate with Buck, this can amount to a waste of resources. This changeset make the type exact and removes the unused fields.

Reviewed By: mjesun

Differential Revision: D6159350

fbshipit-source-id: 8cdf29d5729253f119778943ad961eacb8990c04
2017-10-26 07:57:00 -07:00
Rafael Oleza 0e764686e1 Add id to DeltaEntry object
Reviewed By: mjesun

Differential Revision: D6158753

fbshipit-source-id: 5997e36c8d85da750113250e5180a1f54ee14b76
2017-10-26 03:28:55 -07:00
Jean Lauliac e4dad595e1 xplat/js: replace import() calls by require.async() calls
Reviewed By: mjesun

Differential Revision: D6147316

fbshipit-source-id: b93a247ce0830a5db250824d22e81a3b786daf36
2017-10-26 02:21:05 -07:00
Jean Lauliac d01f514fa0 metro-bundler: ModuleGraph: add support for require.async() when collecting dependencies
Summary: This is the last step remaining before enabling the `import()` syntax to use `require.async()` (for now that function is just doing a simple `require()` in behind).

Reviewed By: davidaurelio

Differential Revision: D6147030

fbshipit-source-id: 5cd8ee6cc550816ae3cdea0b457dc2419c99e7a7
2017-10-26 02:21:05 -07:00
Rafael Oleza d74685fd1d Remove compactMapping call from JS transformer
Reviewed By: mjesun

Differential Revision: D6136200

fbshipit-source-id: a38cf19c247f60c0bfee01c39fae070043a76332
2017-10-25 10:28:03 -07:00
Rafael Oleza fa4091c63e Make insertion of modules into the delta structure deterministic
Summary:
After checking more deeply, there were still situations where the delta bundler could generate different bundles between runs: when a module is required by two different modules (it has two or more inverse dependencies), that module would not always be inserted after the first inverse dependency in the bundle, which would cause some bundling order discrepancies.

In order to fix that, the bundler now re-traverses synchronously the dependency graph using a DFS traversing algorithm to guarantee the same order. This will add some small runtime overhead (specially when generating the initial bundle), but it's not worrying (from benchmarks in my macbook pro it'll add ~10ms of initial build for every 1000 modules traversed, being this overhead linear).

Reviewed By: mjesun

Differential Revision: D6124993

fbshipit-source-id: 9bc7cb329f01a7860c7d3b52c3376c643ea5cf3b
2017-10-24 12:28:46 -07:00
Rafael Oleza 0a225fc1e3 Add wordwrap dependency
Summary:
The `formatBanner.js` file is requiring the `wordwrap` package, but it was not defined in the package.json. Somehow this was working before (maybe the package was being downloaded by another depdendency or maybe `formatBanner` was not used).

This fixes https://github.com/facebook/metro-bundler/issues/79

Reviewed By: mjesun

Differential Revision: D6136865

fbshipit-source-id: 722dd61cb936fca893453f4cfc3248718a329779
2017-10-24 12:28:46 -07:00
Miguel Jimenez Esun b9023bd626 Backed out changeset c188b39e104f
Reviewed By: fkgozali

Differential Revision: D6111799

fbshipit-source-id: 34213f79135fb605aa2af60182cc1182b10aa602
2017-10-20 12:44:07 -07:00
Rafael Oleza 367a5f5db8 Apply inline code + constant fold transforms when dev is false
Reviewed By: davidaurelio

Differential Revision: D5940962

fbshipit-source-id: 699d45416bade8471164d6ddf5ef3ade535376b3
2017-10-19 18:53:43 -07:00
Miguel Jimenez Esun 0fdf36d06d Support for remote assets
Reviewed By: davidaurelio

Differential Revision: D6030886

fbshipit-source-id: c188b39e104f5c3f65a98336fecbffc93091ff4c
2017-10-19 18:39:49 -07:00
Rafael Oleza 1a2a46a9fb Always set the runBeforeMainModule bundle param on buildBundle()
Summary: This diff fixes https://github.com/facebook/metro-bundler/issues/78 by adding the `runBeforeMainModule` server parameter to the bundler. This is not the cleanest solution, but will be fixed once we use the Delta Bundler for builds from the CLI

Reviewed By: davidaurelio

Differential Revision: D6074469

fbshipit-source-id: 068926ef671d9f897ad9f1bd0540036a97340c00
2017-10-18 12:24:26 -07:00
Rafael Oleza 58f3fa957e Make sure that modules not present in the dependency graph are initially required
Reviewed By: davidaurelio

Differential Revision: D6071529

fbshipit-source-id: 916768e85657207d1f7a2bf41d0aa11abd158ee7
2017-10-18 12:24:26 -07:00
Rafael Oleza 941b25a2ca Ignore some irrelevant URL params in order to calculate the bundle cache
Reviewed By: davidaurelio

Differential Revision: D6086420

fbshipit-source-id: 52c1d5dc53d23b3963e663f4033446344b892659
2017-10-18 12:24:26 -07:00
Rafael Oleza e9d2575b26 Make the module ids deterministic between runs
Reviewed By: Hypuk

Differential Revision: D6082114

fbshipit-source-id: fd43b64818a1da192c9252a9d2aed918a130517c
2017-10-18 12:00:07 -07:00
David Aurelio 86ffdae347 Dependencies file: add size as attributes
Summary:
Adds module size as `fb_`-prefixed node attributes to the digraph output of dependencies.

The list of edges is now followed by a list of node declarations, that use the `fb_size` attribute to expose the module size in bytes.

E.g:

```
digraph {
	"a" -> "b";
	"b" -> "c";
	"a"[fb_size=123];
	"b"[fb_size=456];
	"c"[fb_size=789];
}

```

Reviewed By: fkgozali

Differential Revision: D6064861

fbshipit-source-id: 73127e08c5e38075b5112053de12f9abac1102ee
2017-10-17 03:55:26 -07:00
Jean Lauliac 55a22d2c5c metro-bundler/src/ModuleGraph: test image asset transform
Reviewed By: davidaurelio

Differential Revision: D6039836

fbshipit-source-id: 0fc022b72892f8a7064482f63e19b9fa5a3d5b00
2017-10-12 10:01:31 -07:00
Jean Lauliac 0608332cb9 metro-bundler/src/ModuleGraph: throw on empty asset images
Reviewed By: fkgozali

Differential Revision: D6030788

fbshipit-source-id: 000757096f7af68c077e80829f48d52814752599
2017-10-12 10:01:31 -07:00
Kathy Gray 9bb438ed1d Upgrade babel generator
Reviewed By: arcanis

Differential Revision: D6008862

fbshipit-source-id: f8c0bc35d696453fd7cda82ce614d084cbc867e0
2017-10-12 07:52:01 -07:00
Jean Lauliac 6074d897db js1 metro-bundler: add script to publish new version
Reviewed By: davidaurelio

Differential Revision: D6019220

fbshipit-source-id: 97bb53323b29609e192f0e4f4d79b6be6440b98e
2017-10-12 03:23:38 -07:00
Burak Yigit Kaya d1d59d81e5 Show filename and line number on dynamic require errors
Reviewed By: cpojer

Differential Revision: D6008549

fbshipit-source-id: 72fde0a3f97841a020a6fc877f86513e9a7b8521
2017-10-10 06:43:08 -07:00
Burak Yigit Kaya a60ba098c5 Add option for disabling global hot key usage
Reviewed By: mjesun

Differential Revision: D6008860

fbshipit-source-id: 604059e2f2b738e6df2c756f3cdc62981544de64
2017-10-10 03:55:27 -07:00
Burak Yigit Kaya 9f8d4ad4fe Make bablyon parse files in module mode
Reviewed By: davidaurelio

Differential Revision: D6008659

fbshipit-source-id: 6ec3a5e1470e91208a6e71eeca3a2f7c5e755acf
2017-10-09 10:27:46 -07:00
Jani Eväkallio b2002609c1 Fixes Platform.OS and process.env.NODE_ENV inlining resulting in an invalid AST
Summary:
Resolves https://github.com/facebook/metro-bundler/issues/27

**Summary**

There is an edge case where tools like react-primitives need to assign to `Platform.OS`,
but the inline transformation results in an invalid AST.

When Platform.OS is unconditionally inlined, the following scenario:
````
Platform.OS = 'ios';
````
Is transformed to:
```
"ios"="ios"
````

And results in error `Property left of AssignmentExpression expected node to be of a type ["LVal"] but instead got "StringLiteral"**`.

See issue in react-primitives: https://github.com/lelandrichardson/react-primitives/issues/79

This patch checks whether the current node is on the left hand side of an AssignmentExpression
and skips the inlining when this is the case.

It also does the same for `process.env.NODE_ENV`, which suffers from the same problem. See related closed issue https://github.com/facebook/react-native/issues/7607#issuecomment-221425153 which was resolved by using bracket notation `process.env["NODE_ENV"]` instead.

**Test plan**

Unit tests included.

**Notes**

This is my first contribution to Metro, and haven't worked with Babel AST a lot, so constructive feedback on the implementation is welcome.
Closes https://github.com/facebook/metro-bundler/pull/45

Reviewed By: cpojer

Differential Revision: D5974615

Pulled By: mjesun

fbshipit-source-id: 224e63cef24f450b33e17ff9c0e0c0cea46bc70e
2017-10-09 08:23:04 -07:00
Daniel Mueller 475a580569 Add require.getModules
Summary:
In order to aid with debugging inline requires we add a method that
will give us the modules.

**Summary**

I was looking for a way to see what modules had been loaded when I was working with inline requires. I had tried using beginEvent on Systrace, but I was worried that there were modules that I might have missed (I'm not certain if all the loaded files are polyfills before the entryFile is invoked for instance). By adding getModules() it simplifies seeing what modules are loaded.

**Test plan**

At the root of my app `index.ios.js`:

```

import App from './App';
import { AppRegistry } from 'react-native';

AppRegistry.registerComponent('App', () => App);

// after 3 seconds the initial app data should have loaded, so lets take a look:
setTimeout(() => {
  console.log(require.getModules());
}, 3000);

```

**NOTE**
If there is a way to get to this easily (via the debugger or some other mechanism) I would be happy to use that instead and add documentation for it.
Closes https://github.com/facebook/metro-bundler/pull/37

Differential Revision: D6008180

Pulled By: cpojer

fbshipit-source-id: 850103bbce166bf65a0cbd710582198c66273db5
2017-10-09 08:08:43 -07:00
Richard Girges c4307d7170 Prevent error on safely-handled requires using non-static arguments
Summary:
**Summary**
This is the workaround that cpojer suggested in #65 and should resolve the biggest pain point that developers are experiencing in that issue: using moment.js in React Native. Hopefully this at least serves as a starting point to reaching a decent solution for libraries using non-static `require()` statements.

**Test plan**
- Expected error when non-static-argument-based `require()` is nested more than one level deep within a `try` statement
- Expected no error when non-static-argument-based `require()` is nested directly within a `try` statement

```bash
ip-192-168-1-10:trueflipapp richard$ react-native bundle --entry-file index.js --platform ios --bundle-output /tmp/test.js --reset-cache
Scanning folders for symlinks in /repo/trueflip/sandbox/code/trueflipapp/node_modules (8ms)
Scanning folders for symlinks in /repo/trueflip/sandbox/code/trueflipapp/node_modules (8ms)
Loading dependency graph, done.
warning: the transform cache was reset.
bundle: start
bundle: finish
bundle: Writing bundle output to: /tmp/test.js
bundle: Done writing bundle output
```

Closes https://github.com/facebook/metro-bundler/pull/69

Differential Revision: D6008567

Pulled By: cpojer

fbshipit-source-id: f9be328cf50dc47c7433ffeb5eb053b398c92122
2017-10-09 08:08:43 -07:00
Jean Lauliac 51d4754efc metro-bundler: AmbiguousModuleResolutionError: provide default message
Reviewed By: davidaurelio

Differential Revision: D5986044

fbshipit-source-id: f61d351f91fed3638177bd3c10702f1cb0742a21
2017-10-09 07:45:01 -07:00
Matt Labrum 6c60f61cbd Fix importing a dot file from the root directory doesn't work
Summary:
Hi,
**Summary**
This fixes #40 where bundler cannot resolve a file starting with `.` from the root package directory.

it just adds a check to see if the absolute path filename is the same as the localpath filename then lets it through.

**Test plan**
- Steps to reproduce have been written up in #40

Thanks!
Closes https://github.com/facebook/metro-bundler/pull/54

Reviewed By: cpojer

Differential Revision: D5974618

Pulled By: mjesun

fbshipit-source-id: 4b7113c3bed20f2c908739881d61410d651e6ed7
2017-10-09 05:51:07 -07:00
Zachary Kim d07bfa1532 Whitelist node opt --max-old-space-size for JSTransformer
Summary:
Whitelist node opt `--max-old-space-size` for JSTransformer.

Bundling can choke on the default node memory settings for those of us generating large index.js files. This change allows supplied node options to make it through to the node processes spawned by the JSTransformer worker farm.
Closes https://github.com/facebook/metro-bundler/pull/70

Differential Revision: D6008141

Pulled By: cpojer

fbshipit-source-id: 1ef3b436ea30baf3f255a4fd718fe4d958d70c65
2017-10-09 04:28:39 -07:00
Jean Lauliac 1349edad70 Fix edge case of moving a haste file to a different folder
Reviewed By: davidaurelio

Differential Revision: D5945574

fbshipit-source-id: 5fdd12c0af1b7a92012f4be71ce18f44e42ad4e1
2017-10-05 04:51:40 -07:00
Jean Lauliac e235f6a9fd metro-bundler: writeFile: limit concurrency
Reviewed By: cpojer

Differential Revision: D5975830

fbshipit-source-id: c35be29e8dd64d9653cd24814c5d9f1ef89755dd
2017-10-05 03:27:59 -07:00
Rafael Oleza 6d0c371d65 Handle the case where a file gets modified and deleted afterwards
Reviewed By: jeanlauliac

Differential Revision: D5944099

fbshipit-source-id: 7d41cf849dc53936cb014c44ce02f106853733c6
2017-10-04 04:21:02 -07:00
Sam Goldman 87cfc05ea6 Upgrade Flow to v0.56.0
Reviewed By: calebmer

Differential Revision: D5958715

fbshipit-source-id: 7feda03a9540e69bf8d9b4eb89720248ff43294f
2017-10-02 21:05:38 -07:00
Matt Bruce 86a69bf25d Change all calls to no-console from no-console-disallow
Reviewed By: TheSavior

Differential Revision: D5944700

fbshipit-source-id: cdd78d1b32fa98d8a792a39ccc3cb37241ab4366
2017-09-29 16:37:02 -07:00
Rafael Oleza f32c1edb8d Implement getOrderedDependencyPaths() using the Delta Bundler
Reviewed By: jeanlauliac

Differential Revision: D5922153

fbshipit-source-id: d5d595f99053d0eacde37fe0cedcba2ca86bd6f7
2017-09-29 15:06:49 -07:00
Rafael Oleza 09ee6d9cbe Add Source Map support to e2e deltas in chrome debugger
Reviewed By: jeanlauliac

Differential Revision: D5917380

fbshipit-source-id: 31391bc03c420b8e7af5c840fbea2fb0dd5f7bbc
2017-09-29 05:58:31 -07:00
Rafael Oleza 07d73a3af2 Improve progress bar when using delta dependencies traversal
Reviewed By: davidaurelio

Differential Revision: D5901052

fbshipit-source-id: a06584bfbd287f6d8d9b53fb5918dfa7d88bceef
2017-09-28 15:10:50 -07:00
Rafael Oleza a606e79af0 Integrate the incremental dependency traversor into the Delta Bundler
Reviewed By: davidaurelio

Differential Revision: D5880892

fbshipit-source-id: d6e04b59aee5fe0bf671553c98f728be054e01b9
2017-09-28 15:10:50 -07:00
Rafael Oleza 7e65f2f1ea Add module for incrementally traversing the dependencies
Reviewed By: davidaurelio

Differential Revision: D5880827

fbshipit-source-id: 9500c54c2f93726449a413321b9e4ef46825b977
2017-09-28 15:10:50 -07:00
Christoph Nakazawa 34b108b37e Small Config defaults cleanup
Reviewed By: davidaurelio

Differential Revision: D5841910

fbshipit-source-id: e3645a115da4a445dd2b16cf9adccf68462513f9
2017-09-28 10:07:06 -07:00
Rafael Oleza ccbe4bc78c Use Delta Bundler for symbolication of errors endpoint
Reviewed By: jeanlauliac

Differential Revision: D5913798

fbshipit-source-id: 5a8aaa6b39aa864424eabb94748cbff24b463b81
2017-09-28 09:28:16 -07:00
Rafael Oleza 8302fcb92b Bump metro-bundler dependency to 0.19.x
Reviewed By: cpojer

Differential Revision: D5920597

fbshipit-source-id: fdc4f50ffdb43487e7c3480b7cc587b7ff483681
2017-09-27 14:36:30 -07:00
Christopher Chedeau f4d9fccee6 Codemod to 1.7.0
Differential Revision: D5763302

fbshipit-source-id: a91ca1786c7ac8eb9aa3dd43555a7a223dc6f9cf
2017-09-26 23:46:09 -07:00
Rafael Oleza 7c69e832b2 Add support to metro server to send Deltas to devices
Reviewed By: jeanlauliac

Differential Revision: D5890498

fbshipit-source-id: 3ce5c3edb69598adffd2224a418647f3b8897945
2017-09-26 18:06:31 -07:00
Rafael Oleza a3a60c912a Make Module.getName() synchronous
Reviewed By: cpojer

Differential Revision: D5911221

fbshipit-source-id: 2381d70008adff9e0f7613fe43c8fb562222acd6
2017-09-26 17:23:20 -07:00
Rafael Oleza eefb8e9fc5 Make the runBeforeMainModule config param to RN repo and make it absolute
Reviewed By: davidaurelio

Differential Revision: D5880700

fbshipit-source-id: 5df6781026030395900388c561283abadefa6511
2017-09-26 13:07:13 -07:00
Rafael Oleza 7ba76a32e1 Change format of dependencyPairs param received by wrapModule()
Reviewed By: jeanlauliac

Differential Revision: D5880766

fbshipit-source-id: ef9f0ec2d7dcc4e47f5dacb9d899b5f1fde18e8f
2017-09-26 07:09:21 -07:00
Rafael Oleza 24be572cf5 Fix integration snapshots + add emails to test
Reviewed By: davidaurelio

Differential Revision: D5910903

fbshipit-source-id: 2d7d95db99303ce1106203f6146173b0030c4096
2017-09-26 06:53:41 -07:00
Jean Lauliac 21eef9ebb1 RN buck: add bundle splitting
Reviewed By: davidaurelio

Differential Revision: D5854013

fbshipit-source-id: 97e706d2e40ccb18397950f3d09763dd2498aee8
2017-09-26 04:21:38 -07:00
David Aurelio afb91bccd3 Don’t save original source code
Reviewed By: jeanlauliac

Differential Revision: D5901918

fbshipit-source-id: 68332b07f34ac4fd5491868cbc9f81283dae8d91
2017-09-25 18:06:58 -07:00
Jean Lauliac 0c2e414337 RN: add bundleId to nativeRequire() call
Reviewed By: davidaurelio

Differential Revision: D5863569

fbshipit-source-id: 62f65032f103b5bd20252343c771d0cd01950109
2017-09-25 09:06:49 -07:00
Jean Lauliac c4f9ee5720 metro-bundler: fix jest-haste-map require
Summary:
Addresses https://github.com/facebook/metro-bundler/issues/62

Apparently with some versions of `jest-haste-map`, the nested source file returns the module wrapped with `default` instead of the exports themselves (due to some ES6 babel transform, I am guessing). I wasn't able to reproduce this myself yet, but I think a good first step is to avoid using nested library files in the first place, ie. only use what's exported at the top-level.

Reviewed By: rafeca

Differential Revision: D5890757

fbshipit-source-id: 1196264b5626eda65c4aae222db2a1620f901c55
2017-09-25 07:20:58 -07:00
Jean Lauliac 3b6fddc746 RN buck: move asset work into transform worker
Reviewed By: davidaurelio

Differential Revision: D5872268

fbshipit-source-id: 829a0d26930f8893b93a5f42ef7026350dc01f29
2017-09-22 07:25:03 -07:00
Rafael Oleza e736518c43 Remove unneeded params from `getTransformOptions()`
Reviewed By: jeanlauliac

Differential Revision: D5880687

fbshipit-source-id: ef9683b1272133a9b38005cb8ba43d80b9ac6ec8
2017-09-21 09:27:05 -07:00
Sina Sabet f700c9e54d Removing unnecessary eslint enable/disable comments (round 2)
Reviewed By: TheSavior

Differential Revision: D5865725

fbshipit-source-id: 92d5e4376956a05c23aeeb84a4996626d82e0fb6
2017-09-20 23:39:49 -07:00
Jean Lauliac 39238acb78 RN: add some test to module system
Reviewed By: davidaurelio

Differential Revision: D5862757

fbshipit-source-id: cf5c88c4bb9d65368df07f6e85b207c90565bad9
2017-09-20 11:05:49 -07:00
Jean Lauliac 7d92dd2b5d RN buck: fix Flow error
Reviewed By: davidaurelio

Differential Revision: D5871509

fbshipit-source-id: 91bd020b95d33a854b5649daea1a0b8d7782706d
2017-09-20 09:22:56 -07:00
Lee Byron 9f4ca4a541 Synchronize all relay packages
Reviewed By: mjmahone

Differential Revision: D5842774

fbshipit-source-id: 40c57619901e15b0baa62c59837fc887c100652b
2017-09-19 22:56:43 -07:00
Ian Levesque 522a0460a1 Revert D5841425: Removing unnecessary eslint enable/disable comments
Differential Revision: D5841425

fbshipit-source-id: 5a5bb73eafce9e09c89fe9f0cf57676cfc962a5a
2017-09-19 13:26:30 -07:00
Sina Sabet 114b00ee34 Removing unnecessary eslint enable/disable comments
Reviewed By: TheSavior

Differential Revision: D5841425

fbshipit-source-id: cf30e47e0a544230595b8298c6bca67cbee2fb08
2017-09-19 12:52:15 -07:00
David Aurelio ad927b93dc Upgrade uglify to v3 + es support
Summary: Upgrades uglify to version 3 with (experimental) ES6 support turned on.

Reviewed By: jeanlauliac

Differential Revision: D5842410

fbshipit-source-id: 1c8ccea15785bc5bb1c68d7a83b75881432d0ce2
2017-09-19 12:23:53 -07:00
David Aurelio 025e1841d9 Get rid of `async/queue`
Summary:
This replaces `async/queue` with a hand-rolled queue that does not yield to the event loop if a unit of work can be run synchronously.

Anecdotally, this leads to a > 11x speedup for the graph traversal when all data is available synchronously, e.g. from an in-memory cache.

Reviewed By: jeanlauliac

Differential Revision: D5861763

fbshipit-source-id: f7cf5f916a13adf9ca418d7522cd2f19df596fba
2017-09-19 09:21:40 -07:00
David Aurelio c546349da4 `GraphFn` returns promise rather than taking callback
Summary: Changes `GraphFn` to return a promise rather than taking a callback. This is more in line with call sites, which so far have been using `denodeify`.

Reviewed By: jeanlauliac

Differential Revision: D5857192

fbshipit-source-id: 61bbbef4fbf24b0b91c4a3008541eaa5a1af0f7a
2017-09-19 09:21:40 -07:00
David Aurelio 5aaf148179 `@format` for `Graph-test.js`
Reviewed By: jeanlauliac

Differential Revision: D5857069

fbshipit-source-id: 38e58f11579161a94d5201d016cf8b0ba3681eb4
2017-09-19 09:21:37 -07:00
David Aurelio 6062a9bd34 `LoadFn`/`ResolveFn` without callbacks
Summary:
Changes `LoadFn` to be synchronous or return a promise, and `ResolveFn` to be synchronsous.

This makes for a nicer API, without losing the property of not yielding to the event loop for synchronous work.

Reviewed By: jeanlauliac

Differential Revision: D5855963

fbshipit-source-id: 4b3c3363f4e49a9890586462925e8e400872feb2
2017-09-19 09:21:32 -07:00
David Aurelio 3f2b200e01 Fix creation of indexed RAM bundles
Reviewed By: jeanlauliac

Differential Revision: D5852737

fbshipit-source-id: 98e16fbd69d9ad3666acfc86e5de308175102643
2017-09-18 11:08:44 -07:00
Rafael Oleza f6e2e17900 HMR: Include updated modules in the correct order
Reviewed By: davidaurelio

Differential Revision: D5852269

fbshipit-source-id: 519564a4899b22d16a2ab3be4b466e21783e8f86
2017-09-18 09:06:43 -07:00
Jean Lauliac a7ad7502aa RN buck: ModuleGraph: get rid of callbacks, async/await for the best
Reviewed By: davidaurelio

Differential Revision: D5842855

fbshipit-source-id: 71f9e799db4ad312213a20c1b1a93280e934d1e7
2017-09-18 04:21:14 -07:00
Rafael Oleza 539885386a Remove unneeded await in sync method
Reviewed By: cpojer

Differential Revision: D5851184

fbshipit-source-id: 4a6f5cbd9d1237843c349b5944bd17767f84f625
2017-09-18 03:53:19 -07:00
Rafael Oleza 77f6ac080d Handle renames/deletes of modules correctly
Reviewed By: cpojer

Differential Revision: D5845030

fbshipit-source-id: a33af56bf5a479768eaf64b42ec3251a724c0315
2017-09-16 09:07:40 -07:00
Rafael Oleza f9526cf486 Fix issue when there is transform errors
Reviewed By: mjesun

Differential Revision: D5843842

fbshipit-source-id: a9c5efde86248a5e4b188012360d8830d2049985
2017-09-15 17:24:56 -07:00
David Aurelio d56cef3493 Don’t use unnecessary transforms for node 8
Summary: When running with node 8, the babel plugins `async-to-generator` and `syntax-trailing-function-commas` are unnecessary. Removing them makes runtime transpilation faster, and the resulting code is closer to the original (useful with debugging: less unmapped code areas, better breakpoint support, less renamed variables).

Reviewed By: mjesun

Differential Revision: D5842305

fbshipit-source-id: d99f719794e4a8f48fd10b0349fbb36f2994666e
2017-09-15 12:06:42 -07:00
Christoph Nakazawa 2a64bd390e Use the Config type from Metro
Reviewed By: davidaurelio

Differential Revision: D5832633

fbshipit-source-id: 8e4e0e6a2907e485a5627c87161af2d0672b4f56
2017-09-15 05:10:08 -07:00
Christoph Nakazawa 34b1fb6abf Add Config object and loading mechanism
Summary:
This copies the basic loading mechanism and default config from the RN local cli into Metro and exposes it under `metro-bundler`, and switches internal scripts over to it.

davidaurelio: I changed the packager-worker-for-buck to hardcode the rn.cli file, like we do in other files. I would like to pull the "find" mechanism that traverses up to find a config into Metro at some point, but for now I'd prefer to keep it lean until we need it. Let me know if that doesn't work for you.

The next diff will switch the RN cli over to these functions also.

Reviewed By: davidaurelio

Differential Revision: D5832596

fbshipit-source-id: a3e167644d96c8831e5a83378e8ba143e62426db
2017-09-15 01:39:30 -07:00
Christoph Nakazawa 37a7a3b018 Add ConfigT type
Summary: As a first step in defining a new public API and CLI for Metro, I'd like to pull the generally useful pieces from the RN cli into Metro. This diff makes it as a non-breaking change (so we don't have to bump the version of Metro for RN) by updating only the imports outside of the react-native-github folder.

Reviewed By: davidaurelio

Differential Revision: D5832464

fbshipit-source-id: 11b00b5517665441763c2207d577ae0e110c681b
2017-09-15 01:39:30 -07:00
Christoph Nakazawa 80a3306448 Bump metro-bundler dependency to 0.17
Reviewed By: davidaurelio

Differential Revision: D5834180

fbshipit-source-id: 121efc7000bff7aff121d44e6b0b8eed1d4e81ae
2017-09-14 22:09:13 -07:00
Alexander Gugel db7ea0b5f7 Add hook for accessing aggregated resolution cache
Reviewed By: mjesun

Differential Revision: D5775425

fbshipit-source-id: 9e1855d9a161f60d7163a208c5539264ba67d3fd
2017-09-14 18:53:57 -07:00
Rafael Oleza 300cd924e0 Add logging for HMR changes
Reviewed By: davidaurelio

Differential Revision: D5833673

fbshipit-source-id: 5cfc9e7de6b761130093f785f2f9b829093571d0
2017-09-14 16:43:53 -07:00
Rafael Oleza bfa19e9db0 Do not include polyfills in the inlineRequiresBlacklistFiles transform option
Reviewed By: davidaurelio

Differential Revision: D5834728

fbshipit-source-id: 7c531b2464fb0bda50fdfa527112313060f11a0c
2017-09-14 14:08:34 -07:00
Rafael Oleza 4f31807cf8 Add multipart response functionality to the full bundler created by Delta Bunlder
Reviewed By: jeanlauliac

Differential Revision: D5825701

fbshipit-source-id: 481d36420396e2fcb457397905c69fb5720f43b2
2017-09-14 10:21:12 -07:00
Rafael Oleza 61fb142520 Bump babel-preset-react-native dependency in metro bundler
Reviewed By: jeanlauliac

Differential Revision: D5833281

fbshipit-source-id: 42a62e71b77467973d15d60419a33c310082d015
2017-09-14 09:05:52 -07:00
Rafael Oleza 9294f5a46a Multiple requests to the Delta Bundler when there is an error should produce an Error
Reviewed By: jeanlauliac

Differential Revision: D5814215

fbshipit-source-id: 9a72057078819d07ddbd5d4f949d7bdf13aff29e
2017-09-14 08:25:36 -07:00
David Aurelio 3401cfe768 disable all dev settings for base transform
Reviewed By: fkgozali

Differential Revision: D5824578

fbshipit-source-id: 7503700b82dc2b4de4c2d941829ba837ddcd5f3c
2017-09-13 16:53:45 -07:00
Rafael Oleza 0a1e79a820 Replace the ETag header by the Last-Modified to improve performance
Reviewed By: mjesun

Differential Revision: D5823545

fbshipit-source-id: 57eac5548e626eeed05f9b454e3f54b114193eb0
2017-09-13 13:08:05 -07:00
Rafael Oleza b64a07e38b Make DeltaBundler HMR handle errors correctly
Reviewed By: jeanlauliac

Differential Revision: D5814107

fbshipit-source-id: 2bcc52901eff5f2330453c7dc948a0b4ac0332db
2017-09-13 10:12:55 -07:00
Christoph Nakazawa 5422f802f5 Use hasteImpl in the Buck worker
Reviewed By: davidaurelio

Differential Revision: D5803422

fbshipit-source-id: de3aa40ab8ea9ec54e61173b3d6556351394089f
2017-09-13 00:09:09 -07:00
Kevin Gozali 8654b558ca fix output path for the UNBUNDLE magic file
Summary: Fixed the UNBUNDLE magic file location to match what JniJSModulesUnbundle.cpp expects.

Reviewed By: sahrens

Differential Revision: D5821637

fbshipit-source-id: 4342e4bb4d139b4eba77dd92a53b1683041fc7e9
2017-09-12 22:43:13 -07:00
Rafael Oleza 449e943d91 Add 'bundler' column to metro bundler logs
Reviewed By: davidaurelio

Differential Revision: D5809350

fbshipit-source-id: 7e1b9dcda26f3c199ff1723e21c670659d9cf747
2017-09-12 09:11:14 -07:00
Miguel Jimenez Esun 090df5c104 Make cache method public
Reviewed By: jeanlauliac

Differential Revision: D5804391

fbshipit-source-id: 8da732a440111ca5d89d51fa9e4c2727d386bbff
2017-09-12 08:11:29 -07:00
Rafael Oleza 5fa193bdee Move createModuleIdFactory() to a separate module
Reviewed By: jeanlauliac

Differential Revision: D5813714

fbshipit-source-id: 17ae2cf1751d30f6f18bb896576747871b8a0b68
2017-09-12 08:11:29 -07:00
Rafael Oleza bd51bc3c2f Use getModuleForPath() method from Resolver instead of Bundler
Reviewed By: davidaurelio

Differential Revision: D5813534

fbshipit-source-id: dbd005c2f9b478be58f33bd30df16e94159509da
2017-09-12 07:11:30 -07:00
Christoph Nakazawa d9ff4fa1dc Apply @format to root level files
Reviewed By: davidaurelio

Differential Revision: D5803464

fbshipit-source-id: e250a3ada33790b989f1e70990438c300bfb6d52
2017-09-12 01:06:05 -07:00
Rafael Oleza c51161d209 Fix issue calculating dependencyPairs when adding a new dependency
Reviewed By: cpojer

Differential Revision: D5812028

fbshipit-source-id: ced2cb19e87b3622d16f4c59d58d6711ce5161df
2017-09-12 01:06:05 -07:00
Christoph Nakazawa b3e817285b Remove HasteMap
Reviewed By: davidaurelio

Differential Revision: D5803275

fbshipit-source-id: 2e64733d8ef400a61d116b21cd53185934dd3d57
2017-09-11 23:54:09 -07:00
Christoph Nakazawa 61a0116dd4 Prevent logspew in symbolication worker-test
Reviewed By: mjesun

Differential Revision: D5803050

fbshipit-source-id: b585d073191ae521e8bc8cabb90a15d2a176d6da
2017-09-11 19:44:11 -07:00
Christoph Nakazawa 92fa17f70e Fix DependencyGraph-test log-spew
Reviewed By: mjesun

Differential Revision: D5803016

fbshipit-source-id: fc94590331fb77796cb5d2bbc96f963b7b5f8c7c
2017-09-11 19:44:11 -07:00
Christoph Nakazawa 86a943bbcd Branding: "packager" -> "Metro Bundler"
Summary:
This diff renames all the stragglers in comments and strings from variations of "packager" to "Metro Bundler". I did one of three:

* Rename "packager" to "Metro Bundler"
* Rename "react-native-packager" to "Metro Bundler"
* Remove "packager" when code inside of Metro implies that it's about Metro

I also removed `Glossary.md` because it is unmaintained and very old. mjesun is currently starting to write documentation for Metro which will supersede whatever was there before.

Reviewed By: mjesun

Differential Revision: D5802993

fbshipit-source-id: ba99cb5ed04d84b0f7b7a8a0bf28ed99280a940a
2017-09-11 19:44:11 -07:00
Rafael Oleza 8e2252d35d Implement end() method in DeltaBundler
Reviewed By: jeanlauliac

Differential Revision: D5803466

fbshipit-source-id: 78a29cd943774506694513987d97d9f37be04485
2017-09-11 08:27:56 -07:00
Rafael Oleza 197d885ec1 Add X-Metro-Files-Changed-Count HTTP header to the response when using Delta Bundler
Reviewed By: mjesun

Differential Revision: D5793977

fbshipit-source-id: 9e0783356ca7574077d4eb06489e9837f033d986
2017-09-11 08:27:56 -07:00
Rafael Oleza bf64ba58d3 Integrate the Source Map generator from Delta Bundler into the metro server
Reviewed By: mjesun

Differential Revision: D5793423

fbshipit-source-id: a26b6d67405d6ec0d59479cfe5091159a29018d1
2017-09-11 08:27:56 -07:00
Rafael Oleza e57e0002d1 Add Source Maps support to Delta Bundler
Reviewed By: jeanlauliac

Differential Revision: D5793499

fbshipit-source-id: 67e49ed5f5bc9ccae2fb4982cd506fc03259589a
2017-09-11 08:27:56 -07:00
Rafael Oleza dcf30322a5 Do not minify a bundle when calling wrapModule()
Reviewed By: jeanlauliac

Differential Revision: D5791079

fbshipit-source-id: 942d2963e17153508b4a7c5bd48e11b7cb3fdcd4
2017-09-11 08:27:56 -07:00
Rafael Oleza 2593ea2ad4 Make the sourcemaps generation module independent of ModuleTransport
Reviewed By: jeanlauliac

Differential Revision: D5789998

fbshipit-source-id: a460ccb0baa62d0edb4e0da2b6f4d4abaa7fe222
2017-09-11 08:27:56 -07:00
Rafael Oleza 5ee6de217d Disable using babel-generated sourcemaps from the metro bundler server
Reviewed By: jeanlauliac

Differential Revision: D5785354

fbshipit-source-id: be1a5c114b12af356804ff3b4ed6c4263d66fa0c
2017-09-11 08:27:56 -07:00
Jean Lauliac 36b2f8d67f RN packager: wrap-worker-fn.js: syncify
Reviewed By: davidaurelio

Differential Revision: D5803796

fbshipit-source-id: d6b7d169a2c17864e8ce68d82df8e898d966e404
2017-09-11 07:41:44 -07:00
Jean Lauliac 69eb3430b6 RN packager: transform-module.js: syncify everything
Reviewed By: davidaurelio

Differential Revision: D5803768

fbshipit-source-id: 06c28e6c30fce347780d953312646a449d0026d9
2017-09-11 07:41:44 -07:00
Jean Lauliac 7ccbcc5ebc metro-bundler: fix Flow errors in OSS
Reviewed By: cpojer

Differential Revision: D5775151

fbshipit-source-id: 730ab160fdf5ea35f8047eb55a7e2844ba7a7c14
2017-09-08 06:39:36 -07:00
Rafael Oleza 286c5ccdd9 Bump metro-bundler to 0.16.0
Reviewed By: davidaurelio

Differential Revision: D5793558

fbshipit-source-id: c5d7f3029b889987613034150ba13a72b4850421
2017-09-08 06:23:47 -07:00
Jean Lauliac 890de8436f xplat/js: switch to new oncall javascript_foundation
Reviewed By: cpojer

Differential Revision: D5774897

fbshipit-source-id: 6b3246aeda9fe3bee89065ed2ac244282e496373
2017-09-08 03:39:34 -07:00
Rafael Oleza 177c4fb1ab Do not bundle deleted modules in HMR
Reviewed By: mjesun

Differential Revision: D5777831

fbshipit-source-id: dd3551194eca99097cea5a1944555cd8adff9f19
2017-09-07 10:21:19 -07:00
Marshall Roch 14428a67e5 @allow-large-files Flow v0.54.0
Reviewed By: leebyron

Differential Revision: D5773490

fbshipit-source-id: 2c54bb6326f23edbe9a969f3010f79da8189923e
2017-09-06 03:31:10 -07:00
Jean Lauliac a94654255b packager-worker-for-buck: include all entries point for getting extra configuration
Reviewed By: davidaurelio

Differential Revision: D5764794

fbshipit-source-id: a9bddd05a66c1d5a45f5dd4d04517dbe86ea5b76
2017-09-05 10:54:17 -07:00
Rafael Oleza 0265758e5e Create brand-new HMR server using the Delta Bundler
Reviewed By: mjesun

Differential Revision: D5765024

fbshipit-source-id: 3f51ab1564a93b8268e51c0a0a97ea3ef5bd6681
2017-09-05 07:21:06 -07:00
Rafael Oleza 387a55de40 Make the DeltaCalculator and the DeltaTransformer emit change events
Reviewed By: jeanlauliac

Differential Revision: D5765042

fbshipit-source-id: 5b45cc425b6afb4f8cead80ce967263936baa8c1
2017-09-05 07:21:06 -07:00
Rafael Oleza 8b6d69b645 Return the inverseDependencies from the Delta Bundler to support HMR
Reviewed By: jeanlauliac

Differential Revision: D5763905

fbshipit-source-id: 6b95c8dfded5fc30ec2e7a558ab25550d9a1c333
2017-09-05 07:21:06 -07:00
Miguel Jimenez Esun d4a93eb2fa Update Jest to v21
Reviewed By: cpojer

Differential Revision: D5765333

fbshipit-source-id: 94ea448c4380fdc68f42f84eb3963322ea18ec70
2017-09-05 05:25:02 -07:00
Rafael Oleza 1f90522a13 Upgrade metro-bunder to v0.15.0
Summary: Some breaking changes require a new release.

Reviewed By: cpojer

Differential Revision: D5766207

fbshipit-source-id: d0ebc5cb46fbd2ad167c0a3369d0f354346f61b9
2017-09-05 05:25:02 -07:00
Rafael Oleza e18d4e1b89 Enable delta bundler on metro-bundler behind a cli argument
Reviewed By: mjesun

Differential Revision: D5761110

fbshipit-source-id: 83127f63679caffbc4f335f52f6f5eda398e8c05
2017-09-04 13:53:55 -07:00
Rafael Oleza 7b17ca335d Add DeltaPatcher module to handle Delta bundles
Reviewed By: jeanlauliac

Differential Revision: D5761096

fbshipit-source-id: 8c8ef5fb720b08e3f4f097c5a76f793dc4f1c1da
2017-09-04 13:53:55 -07:00
Rafael Oleza 52fcaf4a10 Delta Bundler: Initial implementation of the Delta Bundler
Reviewed By: jeanlauliac

Differential Revision: D5760233

fbshipit-source-id: 5f829d48401889b1391719564119951a1cf3c792
2017-09-04 13:53:55 -07:00
Rafael Oleza 8c8cfb364f Expose some private methods from the Bundler and the DependencyGraph
Reviewed By: jeanlauliac

Differential Revision: D5755556

fbshipit-source-id: cff95e3464154883fd872bf8ab916276a1f09027
2017-09-04 13:53:55 -07:00
Rafael Oleza 70a0916dd2 Change signature of Resolver.wrapModule() to not depend on ResolutionResponse
Reviewed By: mjesun

Differential Revision: D5757102

fbshipit-source-id: 1cb514612ec431e48d669607c5332f26d19f53a0
2017-09-04 13:53:55 -07:00
Rafael Oleza ebb14a56c6 Add prependPolyfills option param to getDependencies()
Reviewed By: jeanlauliac

Differential Revision: D5755548

fbshipit-source-id: 599d3fb6d9acb34f5970ad83947daeb5f28f86d3
2017-09-04 13:53:55 -07:00
Rafael Oleza 9c251076cf Fix sourceMap flow annotations by making them nullable
Reviewed By: mjesun

Differential Revision: D5755671

fbshipit-source-id: 19be8475b1f1b54bc55b64a1de4b8a446e125c65
2017-09-04 13:53:55 -07:00
Miguel Jimenez Esun 2377f04f4a Always report filename
Reviewed By: cpojer

Differential Revision: D5764824

fbshipit-source-id: cb90e429176764d4a1043fd57bbfee223361a182
2017-09-04 13:53:55 -07:00
Jean Lauliac 6e415bcb2f metro-bunder: v0.14.0
Summary: Some breaking changes require a new release.

Reviewed By: cpojer

Differential Revision: D5763898

fbshipit-source-id: 0580c9b1256c2c019adc5fb2f771c54d7e7a0bf1
2017-09-04 04:42:16 -07:00
Rafael Oleza 717a8c7f61 Improve HMR performance by allowing to specify bundlingOptions to getShallowDependencies() method
Reviewed By: jeanlauliac

Differential Revision: D5745205

fbshipit-source-id: a69ac40bb676a809e3786681179e2b4bac392ce6
2017-09-01 08:51:22 -07:00
Jean Lauliac 8907de28ac metro-bundler: v0.13
Reviewed By: cpojer

Differential Revision: D5754623

fbshipit-source-id: b70bfa105e6752db5350b82433bd64e1ca45f33b
2017-09-01 07:36:11 -07:00