Commit Graph

799 Commits

Author SHA1 Message Date
Ville Immonen dad6c51f2a Fix out of memory error in projects with a lot of assets
Summary:
**Summary**

Metro crashed with "Allocation failed - JavaScript heap out of memory" when trying to build a project with a lot of assets. (Repro: https://github.com/fson/metro-out-of-memory, `yarn start` and open the app.)

By looking at a heap snapshot, I found out the reason was that `node-haste` was reading the contents of asset files and parsing them in search of the `providesModule` docblock field, although it should only do this for source files. I fixed this by checking that `isHaste()` evaluates to `true` before attempting to read the docblock. (`AssetModule` always returns `false` for `isHaste()`.)

**Test plan**

* Ran the [repro](https://github.com/fson/metro-out-of-memory) before the fix. It crashed with `FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory`
  * Heap snapshot: <img width="1440" alt="screen shot 2018-01-03 at 17 31 53" src="https://user-images.githubusercontent.com/497214/34571809-33ee8dfc-f178-11e7-93f9-3fd80e62c188.png">
* After implementing the fix, ensured that the process didn't crash anymore and the heap didn't grow significantly during the build:
![screen shot 2018-01-04 at 17 39 26](https://user-images.githubusercontent.com/497214/34571848-622818aa-f178-11e7-9972-9f54146a83ee.png)
Closes https://github.com/facebook/metro/pull/112

Reviewed By: jeanlauliac

Differential Revision: D6660719

Pulled By: rafeca

fbshipit-source-id: d4d8d4445e75274c65f6a52027d878041f1c9a33
2018-01-05 04:29:32 -08:00
Rafael Oleza 8640847e47 Do not include assets source code in the sourcemaps
Summary:
As reported in https://github.com/facebook/metro/issues/109, the sourcemaps generated by metro are including the binary data of all the assets, which adds a lot of overhead and is not useful at all.

This commit removes the assets contents from the sourcemaps to fix https://github.com/facebook/metro/issues/109

Reviewed By: jeanlauliac

Differential Revision: D6649741

fbshipit-source-id: 8b09d429a1aa8d487557c22440bfa73ae55d03bd
2018-01-03 04:31:36 -08:00
Jean Lauliac dd16d7427a ModuleResolution: extract resolveHasteName function
Summary: Finally we can extract this function out, that remove any remaining dependency on the `TModule` generics and the like. Next steps are to push Metro-specific concepts out of the `resolveDependency` function and out of the module completely, after which the module will be ready to have its own unit tests, and be split into a `metro-resolve`.

Reviewed By: cpojer

Differential Revision: D6645333

fbshipit-source-id: a7915d646f888c29b410bf211f2e2bc4ec157676
2018-01-02 03:13:47 -08:00
Jean Lauliac 7cab9a02c9 ModuleResolution: switch _resolveHasteDependency to non-throwing resolveFileOrDir()
Summary: This changeset alters the Haste resolution logic to be in sync with the new refactored pieces (resolveFile, etc.) Next steps involve extracting this function outside of the class so as to reduce the surface API and promote composability.

Reviewed By: cpojer

Differential Revision: D6645302

fbshipit-source-id: 6ee00fb52025cc0d332e57f837b46e8323faf6f4
2017-12-29 08:58:38 -08:00
Jean Lauliac af1e6e3298 ModuleResolution: move InvalidPackageError handler one level up
Summary: In a further diff, I'll add cases where this error may be thrown at a higher level than the `resolveFileOrDir` function. So we need to move the handler and wrapping logic up the stack, that doesn't have any difference in practice.

Reviewed By: cpojer

Differential Revision: D6642475

fbshipit-source-id: 6b746386a170bfc167a9b50d9786fbb98c920c6d
2017-12-29 04:45:07 -08:00
Jean Lauliac 86eb9680ac ModuleResolution: integrate Haste resolution as part of the overall resolution logic
Summary:
This is part of the efforts to clean up and extract the resolution logic. In this diff, the haste resolution is moved as part of the main resolution function rather than having 2 separate top-level functions. The reason for doing this is that logic is duplicated otherwise, making the already complex code harder to follow still. An example of duplicated logic is the call to `isRelativeImport`, that is done both in ResolutionRequest and ModuleResolution's node resolver. In that case, we never want to use Haste. Another duplication is the redirect of requires of package/haste names. With this changeset it is done in a single place at the beginning of the algo.

This changeset causes slight changes in behaviors. For example, consider `require('Foo/')`. A lookup of `Foo` would be done in the package `browser` field for a potential redirect. With this new code, we'll only look for `Foo/` in the redirect map. My opinion is that this is for the better, as this uniformize the way it works with Node.js `node_module` packages, making resolution more predictable. We should, additionally, actively strive to get rid of trailing slashes anywhere they might be in RN as they bring no apparent technical feature, but more confusion (I might be missing context, naturally).

Next steps will be to clean up `_resolveHasteDependency` completely, removing the callsite `try..catch` in favor of saner conditionals, and enforcing Haste packages to resolve if they exist (right now if a Haste package is found but corrupted, we just continue merrily trying to resolve the module with the rest of the logic; we should hash-crash instead, same as has been done for `resolvePackage`).

Reviewed By: cpojer

Differential Revision: D6642347

fbshipit-source-id: 2f40575b35916b644f342e0267c465a89bee202c
2017-12-29 04:45:07 -08:00
Jean Lauliac 66e19258a4 collectDependencies: provide more data in invalid-require error
Summary: This improves the error message by providing line/column so we can identify errors encountered in https://github.com/facebook/metro/issues/65 easier. Also provide additional fields so we can better format that later on.

Reviewed By: cpojer

Differential Revision: D6641909

fbshipit-source-id: 0372da6b2fb51010b42ab906fc40b528b1483532
2017-12-28 05:18:35 -08:00
Jean Lauliac 3ba92ba160 metro: Package: fix/simplify replacement behavior for string `browser` field
Summary:
The spec doesn't say the `browser` field should actually generate a replacement for the main *file*, just that it provides an alternative main: https://github.com/defunctzombie/package-browser-field-spec#alternate-main---basic
We also don't have any test covering this behavior. Any package relying on this behavior should be fixed to have a redirection of the main *file* in addition to their `main` *field*.

This is part of an effort to cleanup the way we do redirections. Eventually this will be part of the resolution module, not `Package.js`.

Reviewed By: davidaurelio

Differential Revision: D6611894

fbshipit-source-id: 0186aa23df2a9183d895ea02b5fd3b2b7339dc76
2017-12-24 08:31:18 -08:00
Jean Lauliac ec35565c33 metro: ModuleResolution: detect invalid packages
Reviewed By: davidaurelio

Differential Revision: D6619867

fbshipit-source-id: 927a121d9acd2ad43d13909054c22b968f4121a4
2017-12-24 03:29:59 -08:00
Jean Lauliac 6adc4cccd2 metro: ModuleResolution: do not allow recursive package directories
Reviewed By: davidaurelio

Differential Revision: D6612113

fbshipit-source-id: 8b688cb3eed5cc76b07f471ecc98e22e765583ad
2017-12-24 03:29:59 -08:00
Jean Lauliac 9ff46c13e3 metro: ModuleResolution: move tryResolveSync 1 level up
Reviewed By: davidaurelio

Differential Revision: D6610856

fbshipit-source-id: cc9c0e0d09785882e3b977dea5e8bc072099be71
2017-12-24 03:29:59 -08:00
Jean Lauliac 78802d7a42 metro: ModuleResolution: get rid of Packageish#root
Reviewed By: davidaurelio

Differential Revision: D6610822

fbshipit-source-id: 116d3b066fefae035f26f2b7a4021816a3d39549
2017-12-24 03:29:58 -08:00
Jean Lauliac 494422aa43 metro: ModuleResolution: break down more functions
Reviewed By: davidaurelio

Differential Revision: D6610652

fbshipit-source-id: 4c39fb69fe9b5eda96c1dca6697ff9da46df2cda
2017-12-24 03:29:58 -08:00
Jean Lauliac e4cba8e2e2 metro: ModuleResolution: break down functions out of the class
Reviewed By: davidaurelio

Differential Revision: D6610568

fbshipit-source-id: b9f9c6803026442e557d6422fe0589fdeacc8311
2017-12-24 03:29:58 -08:00
Rafael Oleza 1ce70bb695 Use persistent HTTP connections to download transformed files from the global cache
Reviewed By: mjesun

Differential Revision: D6612160

fbshipit-source-id: 391bb5a70bc01a95216b4f22c1fe233bc97c6b7e
2017-12-20 20:34:13 -08:00
Rafael Oleza 002c184a8f Bump metro to v0.24.3
Reviewed By: mjesun

Differential Revision: D6617297

fbshipit-source-id: 5216f2862cbf7707a57c4257f0e2c93f9dfab667
2017-12-20 19:31:01 -08:00
Rafael Oleza 03162aa76f Add .npmignore file to metro-core
Reviewed By: mjesun

Differential Revision: D6617155

fbshipit-source-id: 63382fc44cfc403896f7203b69520d951203d61c
2017-12-20 17:44:49 -08:00
Rafael Oleza a09476ec94 Bump metro to v0.24.2
Reviewed By: mjesun

Differential Revision: D6613447

fbshipit-source-id: 4d03cf86427c7ccd8ee471078d3798ab21aee933
2017-12-20 14:29:01 -08:00
Rafael Oleza 98ff5c785e Fix flow in assetTransformer
Differential Revision: D6592751

fbshipit-source-id: a0e08656bc830db1186df0249a01b8d2695c121e
2017-12-20 14:29:01 -08:00
Charles Dick a66e1f71f6 metro sourcemap add x_metro_module_paths
Reviewed By: davidaurelio

Differential Revision: D6593737

fbshipit-source-id: 3a642d77146308a9df19e16cddfcd0f91cb9d203
2017-12-20 08:27:07 -08:00
Jean Lauliac 5eeb88f5a9 metro: ModuleResolution: get rid of TModule for inner file resolution functions
Summary: This is one of the first step towards a generic and composable resolution algorithm. We shall get rid of `TModule` as it's an abstraction that doesn't bring us any benefit in the resolution algo, and we actually want to get rid of `Module.js` eventually. This changeset gets rid of `TModule` up to the place where I already got rid of the exception-based control flow mechanism. Next steps are to push the boundaries higher up both for error handling, and for removing `TModule`.

Reviewed By: mjesun

Differential Revision: D6603157

fbshipit-source-id: 551e9ccd93628f45452148ed40a817bdde3740ea
2017-12-20 01:59:06 -08:00
Jean Lauliac 730104b8ee metro: ModuleResolution: cleanup unnecessary code for file extensions
Reviewed By: davidaurelio

Differential Revision: D6602014

fbshipit-source-id: 86aa7b33370cabbbd2e2602131cd71145629516c
2017-12-20 01:59:06 -08:00
Jean Lauliac c9023fd907 metro: cleanup UnableToResolveError
Summary: I want to get rid of `TModule` and stuff so that we can eventually reunite this with `jest-resolve`. This is a continuation of the cleanup I started a long time ago.

Reviewed By: davidaurelio

Differential Revision: D6601657

fbshipit-source-id: 62c1806783323ee50e9a09146c73006c721eb891
2017-12-20 01:59:06 -08:00
Rafael Oleza 056ea9b5bf Fix lint error
Reviewed By: davidaurelio

Differential Revision: D6598510

fbshipit-source-id: c4c6a340d72090c9184471985674a25c6cde6238
2017-12-19 04:15:49 -08:00
Rafael Oleza dfb5d95a0d Fix flow error when calling hash.digest()
Reviewed By: cpojer

Differential Revision: D6598742

fbshipit-source-id: 47bd6f0ee0d54c61c2ff9b201005e7366d9df76d
2017-12-19 04:15:47 -08:00
Rafael Oleza 3b497585f1 Make collectDependencies smarter when evaluating the require argument
Reviewed By: BYK

Differential Revision: D6592104

fbshipit-source-id: d90a93c51cb04e38cc172eb8eda932f64fce0075
2017-12-18 12:40:27 -08:00
Miguel Jimenez Esun 57cfa19518 Update to Jest 22.0.0
Reviewed By: cpojer

Differential Revision: D6591693

fbshipit-source-id: ac3d6320445372a5694e7618ed52eb2f391d0bad
2017-12-18 05:20:08 -08:00
Peter van der Zee c32aef25c9 Update metro version to v0.24.1
Reviewed By: rafeca

Differential Revision: D6579060

fbshipit-source-id: f36a87bce9633370a02b8991cec4aced05ca72d1
2017-12-15 10:45:27 -08:00
Peter van der Zee ed269d0f8a Bump metro and all packages to v0.24.0
Reviewed By: rafeca

Differential Revision: D6578653

fbshipit-source-id: 99ec17bcb7c1f4daeb868c3755a9e6e668d1ae61
2017-12-15 10:45:27 -08:00
Peter van der Zee 1d1c23160f Add metro-core to the package.jsons that use it
Reviewed By: rafeca

Differential Revision: D6578053

fbshipit-source-id: b9d4e2e5820854ffe0e9cb54a78436d0ef2917ce
2017-12-15 06:39:55 -08:00
Peter van der Zee 4586152ebf Move Logger to metro-core
Reviewed By: rafeca

Differential Revision: D6568129

fbshipit-source-id: fc367c45e22ef58436331e1a6347ec16f1f155a0
2017-12-15 06:39:55 -08:00
Peter van der Zee 1d12090bc3 Move unused sleep module out of repo
Reviewed By: rafeca

Differential Revision: D6566682

fbshipit-source-id: 48cff465ace25d6d38b8574006e0c54081b8fbde
2017-12-15 06:39:55 -08:00
Peter van der Zee d7e0111bb6 Eliminate cyclic dependency for the sake of BundleOptions
Reviewed By: rafeca

Differential Revision: D6556262

fbshipit-source-id: da710f619e486a43a759b03cae61d6bc20ce5e87
2017-12-15 06:39:55 -08:00
Peter van der Zee 9485a37fe0 Move formatBanner to metro-core
Reviewed By: rafeca

Differential Revision: D6555773

fbshipit-source-id: 9d10a3d03c88eeaa2d6845518da3dacab8b556b0
2017-12-15 06:39:55 -08:00
Peter van der Zee a96e99fae5 Move Terminal to metro-core
Reviewed By: rafeca

Differential Revision: D6532920

fbshipit-source-id: d1463aa0759a6b6d5cc46b05157518a4ce3eb9bf
2017-12-15 06:39:55 -08:00
Burak Yigit Kaya 82b508296d Fallback to Haste name if file path cannot be found when bundling
Reviewed By: rafeca

Differential Revision: D6567420

fbshipit-source-id: 84821b31b45bc7eeb302eef83531cc9a4e666406
2017-12-14 11:46:14 -08:00
Jean Lauliac 86914666e5 metro-buck: check validity of segments
Reviewed By: davidaurelio

Differential Revision: D6496312

fbshipit-source-id: 586dc8d9f64d13cfddaf6bfe768e8f7b3442561a
2017-12-14 09:59:47 -08:00
Brian Shin d2075f3743 Add inline support code for PlatformOS
Reviewed By: mjesun

Differential Revision: D6491061

fbshipit-source-id: e51b50e8a5b1c497946f8dfa3a95bd7599877018
2017-12-13 09:45:20 -08:00
Brian Shin 1a37164dac Extract some platform related code to a separate file
Reviewed By: davidaurelio

Differential Revision: D6491060

fbshipit-source-id: e8d040495b549e1925932b4ded4b44dd1f81fff6
2017-12-13 09:45:20 -08:00
Rafael Oleza db47372f06 Pass runBeforeMainModule option correctly when building prod bundles
Summary:
On D6248242, runBeforeMainModule was changed to `getModulesRunBeforeMainModule`, but the entry point used by opensource to build prod bundles was not updated. We couldn't catch this since we don't use this codepath internally

Fixes https://github.com/facebook/metro/issues/73

Reviewed By: mjesun

Differential Revision: D6556097

fbshipit-source-id: 889eaf825c7c3cdebe1ca4fc9831020a4a7d56dc
2017-12-13 08:30:59 -08:00
Nat Mote 26159b6638 Update to Flow v0.61.0
Reviewed By: gabelevi

Differential Revision: D6540122

fbshipit-source-id: 0ded15d3b368555d12c693feb4bf491bd9092355
2017-12-12 10:44:53 -08:00
Jean Lauliac 26c7a96f44 metro: JSTransformer/worker: report the filename when a dynamic dep is encountered
Reviewed By: rafeca

Differential Revision: D6544291

fbshipit-source-id: 618851850b50d49a29c767ba0d21a7bad522c4ca
2017-12-12 06:14:30 -08:00
Jean Lauliac 2bd9a503a1 metro: collectDependencies: fix error message
Reviewed By: rafeca

Differential Revision: D6544283

fbshipit-source-id: d2e7144ae6f77f312e02ef7720212e9505bd002e
2017-12-12 06:14:30 -08:00
Rafael Oleza 6f0d786e57 Simplify the inlineRequires transform option on incremental builds
Reviewed By: davidaurelio

Differential Revision: D6533845

fbshipit-source-id: ae38defafe70344d0bb0b80d2266dff0e9b273b1
2017-12-11 13:00:00 -08:00
Rafael Oleza 5e65dfcf81 Consolidate eslint config + fix some issues
Reviewed By: davidaurelio

Differential Revision: D6519564

fbshipit-source-id: 0cd894e92dfde451f8ee69d6c7c3d4cbd73b83ea
2017-12-11 12:32:20 -08:00
Jean Lauliac f044f42030 metro-buck: add e2e testing of command
Reviewed By: davidaurelio

Differential Revision: D6533842

fbshipit-source-id: b641559eb3085bac57ab3a1cc80a3f2f86b7ec92
2017-12-11 11:16:21 -08:00
Maël Nison f66eb477ba Adds an indirection layer to enhance the Metro middleware
Reviewed By: BYK

Differential Revision: D6436722

fbshipit-source-id: d864960e2eb7c8c2a96e9869c0b340cc6257808e
2017-12-11 10:15:08 -08:00
Rafael Oleza fa08cb3c99 Add metro-source-map dependency to metro package
Differential Revision: D6532856

fbshipit-source-id: c6df2ad47e2befbff809103da4dcea7b5eb71dad
2017-12-11 10:01:47 -08:00
Adam Ernst 62dcb400ca Back out D6509723
Reviewed By: danzimm

Differential Revision: D6529249

fbshipit-source-id: 71c4ca9f83edfd030f77f3b67290b5751384c731
2017-12-09 13:46:35 -08:00
David Aurelio ae5ebc8078 No compound assignement operators
Summary:
Addresses a performance regression introduced by automatic linting: Compound assignment operators are much slower than keeping assignment separate on `let` bindings in certain versions of v8.

This reverts the relevant changes and configures eslint to *disallow* these operators explicitly in `metro-source-map`.

Reviewed By: mjesun

Differential Revision: D6520485

fbshipit-source-id: 16f35f5cd691ce6b1924480cbc30fbaa1275f730
2017-12-09 13:46:35 -08:00
Rafael Oleza c5e83dd86a Log bundling errors to scuba
Reviewed By: davidaurelio

Differential Revision: D6519623

fbshipit-source-id: a8e54639a041e300bb98d8a9744490fdeae17d1a
2017-12-09 13:30:05 -08:00
Adam Liechty f347e4ff47 Expose createModuleIdFactory as bundler option
Summary:
**Summary**

`createModuleIdFactory` is already used in `metro` internally, but is currently always a fixed function.
This enables `metro.runBuild()` to be run with a custom module ID factory.

One use case: building a base bundle, on top of which other application-specific bundles could reference modules in the base.  The application-specific IDs need to not conflict with those in the base bundle, and all references to modules in the base must resolve to the correct ID in the base bundle.  A custom ID factory can make all this possible.

**Test plan**

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

Using `metro.runBuild(...)` with these changes, I was able to substitute in a custom ID factory

```javascript
const fs = require('fs')
const metro = require('metro')

const baseManifestFileContents = JSON.parse(fs.readFileSync('./baseManifest.json'))
// baseManifest looks like:
// { "modules": { ...
//    "react/index.js": { "id": 12 },
//    "react/cjs/react.production.min.js": { "id": 13 }, ...  } }

const opts = {
  dev: false,
  entry: 'index.js',
  out: './out.bundle',
  platform: 'ios',
  projectRoots: ['.', 'node_modules'],
  config: {
    createModuleIdFactory: createModuleIdFactory(baseManifestFileContents)
  }
}

metro.runBuild(opts)

// Creates a sample custom ID factory
function createModuleIdFactory(manifestFileContents) {
  return function createModuleIdFactory() {
    const fileToIdMap = new Map()
    let nextId = manifestFileContents ? getNextIdAfterBaseManifest(manifestFileContents) : 0

    return path => {
      const sourcePath = path
        .replace(process.cwd() + '/node_modules/', '')
        .replace(process.cwd(), '.')

      // If module is in the base manifest, return its ID
      if (manifestFileContents && manifestFileContents.modules[sourcePath]) {
        return manifestFileContents.modules[sourcePath].id
      }

      // Otherwise, get it from the map or create a new ID
      if (!fileToIdMap.has(path)) {
        fileToIdMap.set(path, nextId)
        nextId += 1
      }
      return fileToIdMap.get(path)
    }
  }

  function getNextIdAfterBaseManifest(manifestFileContents) {
    return Object.keys(manifestFileContents.modules).reduce((id, key) => {
      if (manifestFileContents.modules[key].id > id) {
        return manifestFileContents.modules[key].id
      }
      return id
    }, 0) + 1
  }
}
```

With the sample module ID factory above, the output looks like the following, where defined module IDs start at a higher number to avoid the base module IDs, but may depend on modules in the base bundle (lower numbers).

```javascript
...
__d(function(r,o,t,i,n){t.exports=r.ErrorUtils},551,[]);
__d(function(n,t,o,r,u){'use strict';var e,c=t(u[0]);e=c.now?function(){return c.now()}:function(){return Date.now()},o.exports=e},552,[553]);
...
__d(function(e,t,r,s,l){'use strict'; ...},564,[18,565,27]);
...
```
Closes https://github.com/facebook/metro/pull/100

Reviewed By: mjesun

Differential Revision: D6508351

Pulled By: rafeca

fbshipit-source-id: f2cfe5c373a6c83c8ae6c526435538633a7c9c2a
2017-12-08 06:29:23 -08:00
Rafael Oleza 6d7ba472ee Consolidate AssetData flow types
Reviewed By: jeanlauliac

Differential Revision: D6497429

fbshipit-source-id: cd9abe2d8c5b2b7eb48d8a0335ea5bfa8ac13269
2017-12-08 04:44:26 -08:00
Rafael Oleza 452ee5962d Add metro-source-map dependency to metro package
Reviewed By: cpojer

Differential Revision: D6509723

fbshipit-source-id: da92908c9272148112a98defed328d64cc1bf791
2017-12-08 04:16:06 -08:00
Jean Lauliac 2ecf6c9450 metro: introduce asyncRequire function
Reviewed By: davidaurelio

Differential Revision: D6498107

fbshipit-source-id: a9c4ab634e60f19b7058205eddcd248f57f63500
2017-12-07 10:49:27 -08:00
Peter van der Zee 636c0ed5c9 Kick off metro-core by moving the source-map generator
Reviewed By: rafeca

Differential Revision: D6448594

fbshipit-source-id: 8498ae8ff62e5afc6ae92c56b7c15cdaf8acd3a1
2017-12-07 09:33:50 -08:00
Adam Ernst 9e4cfb4c93 Upgrade to 1.9.1
Reviewed By: vjeux

Differential Revision: D6497877

fbshipit-source-id: 3b88b96e375ddf1fbe039a0593569bbdde40a2dc
2017-12-06 17:31:38 -08:00
Miguel Jimenez Esun 3a377ee0a7 Upgrade Jest to "21.3.0-beta.13"
Reviewed By: rafeca

Differential Revision: D6497197

fbshipit-source-id: b816f4b02cf35abee4ce4098c30291b32656ed04
2017-12-06 09:04:51 -08:00
Rafael Oleza 758ce871e6 Get rid of AssetServer
Reviewed By: mjesun

Differential Revision: D6488612

fbshipit-source-id: e6144f0e143c0008d47342077b4a2c6c15765edc
2017-12-06 07:32:47 -08:00
Rafael Oleza 5bff35f09e Remove getAssetData() method from AssetServer
Reviewed By: mjesun

Differential Revision: D6488537

fbshipit-source-id: 48c27e9cf5802c62fb25aac592ac1c5bcd6cc87f
2017-12-06 07:32:46 -08:00
Jean Lauliac 0e6f72b1ed metro: cleanup collectDependencies
Reviewed By: rafeca

Differential Revision: D6474108

fbshipit-source-id: fd497a248d3552a75e572b1ef8365cc5424c2c00
2017-12-06 03:17:09 -08:00
Rafael Oleza 0e583a981f Get rid of outdated_dependencies
Reviewed By: jeanlauliac

Differential Revision: D6485979

fbshipit-source-id: 8cf21a8c531d96df93f66e1cc465fe7ae044ef8e
2017-12-05 10:45:24 -08:00
Rafael Oleza d8cb904104 Bump metro@0.23.0
Reviewed By: davidaurelio

Differential Revision: D6484402

fbshipit-source-id: e934edc5319aec3c6f36927a0c8d5b48c304719e
2017-12-05 09:28:57 -08:00
Peter van der Zee dfa05cbcd4 Enable flow type for a file and fix a related typo/bug
Reviewed By: rafeca

Differential Revision: D6473575

fbshipit-source-id: 7b96b6bfb2aff96e6d4697ad29fd96fb85d1ceda
2017-12-05 01:31:30 -08:00
Rafael Oleza 5c06a80fd7 Remove old wrapping logic
Reviewed By: davidaurelio

Differential Revision: D6439155

fbshipit-source-id: 3332b9c7952c90411d0c595f184f92aeffd4ddd2
2017-12-04 16:46:17 -08:00
Rafael Oleza 8c43848a1e Move the asset JS generation logic to the worker
Summary:
With this, we do all the transformation and wrapping of files inside the workers, which mean faster initial builds (because parallelization and caching), and more legacy code that can be removed (see the following diff).

I've done some tests locally, and while the initial builds are slightly faster, the increase is not super substantial (the big win was in the diff were I moved the wrapping of JS files, in this diff only the assets transformation has speed up).

The most important thing that this diff enables is the possibility of doing the minification of modules also in the worker. This will mean that we can cache minified files and prod builds will get significantly faster - almost as fast as development builds (this will be relevant mainly for the opensource community).

Reviewed By: davidaurelio

Differential Revision: D6439144

fbshipit-source-id: ba2200569a668fcbe68dbfa2b3b60b3db6673326
2017-12-04 16:46:15 -08:00
Rafael Oleza f3ea76a0b4 Simplify AssetModule logic
Reviewed By: jeanlauliac

Differential Revision: D6438714

fbshipit-source-id: ec1cfe0d439b1dcb07a0861872df5318f468396a
2017-12-04 16:46:15 -08:00
Rafael Oleza fbdbd7ae2c Make Module.getName() return relative paths for non-haste modules
Reviewed By: davidaurelio

Differential Revision: D6473739

fbshipit-source-id: d459040f99148ae4be0d58c40d5eef7bb5e2b929
2017-12-04 16:46:15 -08:00
Rafael Oleza e324b229bb Make getAssetData() method stateless
Reviewed By: davidaurelio

Differential Revision: D6436349

fbshipit-source-id: 3544ae2824ada191f8ad8909f3b6cef13f208975
2017-12-04 16:46:13 -08:00
Rafael Oleza 8b28294bbd Do not cache hash generation in the AssetServer
Reviewed By: davidaurelio

Differential Revision: D6436249

fbshipit-source-id: eebbd92ebfdf1c8f12dbbcf3f5a66166fb1bc828
2017-12-04 16:46:11 -08:00
Rafael Oleza 5fb41e6fc8 Move AssetServer methods that do not require any state out of AssetServer
Reviewed By: davidaurelio

Differential Revision: D6436227

fbshipit-source-id: f276c88b6c954e864c966758a9ec0a17f0aca55f
2017-12-04 16:46:10 -08:00
Marshall Roch 7924e70fe4 @allow-large-files [flow] deploy flow 0.60
Reviewed By: gabelevi

Differential Revision: D6466441

fbshipit-source-id: c51eeb53a2465498ad77b3865b5f8c03758d1d35
2017-12-04 13:30:30 -08:00
Rafael Oleza 3016e74efd Add X-Metro-Files-Changed-Count header to Delta responses
Reviewed By: davidaurelio

Differential Revision: D6473909

fbshipit-source-id: bd71693816007bf961f4b3a7f10b7b6380d158e0
2017-12-04 13:00:12 -08:00
Rafael Oleza b456f7b61a Remove old extract-dependencies logic
Reviewed By: davidaurelio

Differential Revision: D6447749

fbshipit-source-id: 39c4960da65a9d8ab1e2615d48f5c2868a17f82b
2017-12-04 08:14:55 -08:00
Jean Lauliac 03e735d232 metro: fix collect-dependencies for the async/BundleSegments case
Reviewed By: cpojer

Differential Revision: D6462925

fbshipit-source-id: ca83176a7c7f47346daf16703cefb86172dc35b5
2017-12-02 04:58:52 -08:00
Rafael Oleza de7f1d90f2 Support null transformer AST output
Summary: This fixes https://github.com/facebook/metro/issues/99, which causes issues when metro tries to build files that are ignored by babel (if babel transformer ignores a file, it returns a null AST, which makes the collectDependencies logic break).

Reviewed By: mjesun

Differential Revision: D6466878

fbshipit-source-id: b5030e03775b982958a0b9204f4efccc8940ae4d
2017-12-02 00:28:42 -08:00
Rafael Oleza 5d76d340e5 Check for inverseDependencies existance before calling HMR
Differential Revision: D6449768

fbshipit-source-id: d9fe8b54fec0754ffb8ce2db1e87f180862a57a3
2017-12-01 08:59:20 -08:00
Rafael Oleza 8cf97e332f Use async/await in AssetServer methods
Reviewed By: davidaurelio

Differential Revision: D6435849

fbshipit-source-id: c665dfd6737e636f06c7056a89609730a5041a53
2017-11-30 04:03:29 -08:00
Rafael Oleza e19f82d408 Remove unused param from AssetServer
Reviewed By: jeanlauliac

Differential Revision: D6435881

fbshipit-source-id: 1d6d354e63a67f566e69d894bc22999e32b9a76f
2017-11-30 04:03:29 -08:00
Rafael Oleza 750e62bcdf Remove transformAndExtractDependencies() method in worker
Reviewed By: mjesun, davidaurelio

Differential Revision: D6433590

fbshipit-source-id: ef3c31d73a831fabe2a6f1be6051b0cb5c7e6c55
2017-11-30 04:03:29 -08:00
Jean Lauliac 86aba17329 metro: clean up Module option, remove some from state
Reviewed By: davidaurelio

Differential Revision: D6435957

fbshipit-source-id: eaed8f5c1d4d18d6ff0bde34892f059a01fe1a65
2017-11-30 04:03:29 -08:00
Jean Lauliac ec4a0ce527 packager-worker-for-buck: resolve at bundling time using js_library resolution information
Reviewed By: davidaurelio

Differential Revision: D6414372

fbshipit-source-id: 7bb0404e51a6130dfc89adb9476ad829020e76f0
2017-11-30 04:03:29 -08:00
Christoph Nakazawa 66b381a5c7 Export Config/defaults on Metro's main module
Reviewed By: arcanis

Differential Revision: D6435529

fbshipit-source-id: a9549dc5900025fcc798ccb92b49e96c982c2e1e
2017-11-30 04:03:29 -08:00
cpojer 0f7ad193c7 Rename metro-bundler to metro
Reviewed By: davidaurelio

Differential Revision: D6413420

fbshipit-source-id: f13184b8157de2c3aeaa7f2647becc175f62cdbb
2017-11-30 11:56:25 +00:00
Maël Nison 9249ebcea7 Adds a (deprecated) --reset-cache option
Reviewed By: BYK

Differential Revision: D6424553

fbshipit-source-id: f84064f86a985ab19794ea3d94410dceac77a95b
2017-11-29 00:45:23 -08:00
Burak Yigit Kaya cf9ef1b30f Make `assetTransforms` option available to the new metro CLI
Reviewed By: arcanis

Differential Revision: D6424404

fbshipit-source-id: 30c56128b914d86491fce6276775d75e7b497146
2017-11-29 00:45:23 -08:00
Peter van der Zee 37995e2196 Add a bundle type to logger output and type
Reviewed By: rafeca

Differential Revision: D6405599

fbshipit-source-id: 2f3da971d55fae28fbd94ed9f60d3bc2be176d6a
2017-11-28 04:55:00 -08:00
Rafael Oleza b0de96c74a Small refactor in module resolution
Reviewed By: jeanlauliac

Differential Revision: D6417509

fbshipit-source-id: 9c6abb8ceebb7048c775c9c9d21cd881f7e56c1f
2017-11-28 04:35:55 -08:00
Maël Nison 5cc0939454 Automatically watches the metro configuration file
Reviewed By: BYK

Differential Revision: D6408358

fbshipit-source-id: d167534c9c51c3c079148d982ef4ab44c8be0d75
2017-11-28 04:35:55 -08:00
Miguel Jimenez Esun b282031517 Make tests compatible with the latest Jest version
Reviewed By: cpojer

Differential Revision: D6419868

fbshipit-source-id: f01a3f4d54ca1aa3539d92363a51f70247642463
2017-11-28 03:34:45 -08:00
Rafael Oleza ac2aa718c0 Bump metro-bundler@0.22.1
Reviewed By: mjesun

Differential Revision: D6415105

fbshipit-source-id: 51687fd20fc5958a3b18d704ffa100400d208057
2017-11-27 11:29:54 -08:00
Rafael Oleza d46e4ecb6a Keep the dependencyMaps consistent between runs
Reviewed By: mjesun

Differential Revision: D6413998

fbshipit-source-id: fd0ff9a82dcca23603977456b51213216c370f8d
2017-11-27 08:52:03 -08:00
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