Commit Graph

757 Commits

Author SHA1 Message Date
Rafael Oleza fbe441febd Extract the logic to calculate the transform key to a separate module
Reviewed By: jeanlauliac

Differential Revision: D6674422

fbshipit-source-id: 1a439e2afe041084edd27637fb9b177980e667a1
2018-01-09 18:14:47 -08:00
Peter van der Zee 8815c8329d Fix Flow type for babel-generator
Reviewed By: rafeca

Differential Revision: D6682632

fbshipit-source-id: befc2fe51c8e3b542b0f2b8b595ed78b39bd1801
2018-01-09 04:03:36 -08:00
glevi@fb.com 1b37017eb1 @allow-large-files [Flow] Upgrade xplat/js to flow v0.63
Reviewed By: samwgoldman

Differential Revision: D6675320

fbshipit-source-id: 85575a6f30a50a3c40c6b46ba36f8cd33c091b1d
2018-01-08 12:54:34 -08:00
Jean Lauliac 521653798f metro, metro-buck: preprend NODE_ENV variable to bundles
Reviewed By: rafeca

Differential Revision: D6674216

fbshipit-source-id: ca0d17f679eb8fb8dd4c50192836faaf02d1aba8
2018-01-08 10:59:42 -08:00
Rafael Oleza 058336f3b6 Make the public metro runBuild() command generate the sourcemaps
Reviewed By: davidaurelio

Differential Revision: D6666140

fbshipit-source-id: f49e0fdc848a4cec095c808887f5e999d86c104a
2018-01-05 09:40:27 -08:00
Rafael Oleza f5198ad15f Delta Calculator: handle files that have been added from one side and deleted from another
Reviewed By: davidaurelio

Differential Revision: D6665792

fbshipit-source-id: fa8f241bdfc88d77f5662c31796b0644988187cd
2018-01-05 08:15:43 -08:00
Rafael Oleza de77f0340b Remove unused generateSourcemaps param
Reviewed By: jeanlauliac

Differential Revision: D6666060

fbshipit-source-id: e7786b3ed851f4952108ea80f96334f0fb25b034
2018-01-05 07:21:17 -08:00
Rafael Oleza c4d319429c Small flow tweaks in metro api
Reviewed By: jeanlauliac

Differential Revision: D6666057

fbshipit-source-id: 6f0b56fcb531e8c7a10c782342291b35399cac2b
2018-01-05 07:21:17 -08:00
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