Commit Graph

802 Commits

Author SHA1 Message Date
Jean Lauliac 46545d4f5c metro: allow dynamic dependencies from within node_modules
Summary: Tries to adress https://github.com/facebook/metro/issues/65. We need a reasonnable workaround to support modules like `moment.js` that do dynamic requires but only in some cases. By replacing the call by a function that throws, we move the exception at runtime instead of happening at compile time. We don't want to do that for non-node_modules file because they are fixable directly, while `node_modules` are not fixable by people and they get completely blocked by the error at compile time.

Reviewed By: rafeca

Differential Revision: D6736989

fbshipit-source-id: a6e1fd9b56fa83907400884efd8f8594018b7c37
2018-01-18 08:15:53 -08:00
Rafael Oleza 40497ee118 Make the FBGlobalTransformCache-test independent from folder structure
Reviewed By: jeanlauliac

Differential Revision: D6738154

fbshipit-source-id: 65f0c7ba11b9ddf0e7614ab9158c2bcf0e0352ac
2018-01-18 03:59:10 -08:00
Rafael Oleza cfb6174c25 Tweak test that calculates the transform cache key to be more consistent
Reviewed By: davidaurelio

Differential Revision: D6736754

fbshipit-source-id: 1a4c9dc1e5df0c7fa069148b87ed63caac949321
2018-01-17 08:14:22 -08:00
Miguel Jimenez Esun e84f33bd9c Update Jest to 22.1.2
Differential Revision: D6736758

fbshipit-source-id: fd6905e41abd1545b4847ad8ee6c12c7e5ce246e
2018-01-17 07:58:28 -08:00
Rafael Oleza f61ba53f73 Fix lint warnings
Reviewed By: davidaurelio

Differential Revision: D6736768

fbshipit-source-id: 7272118c2320edd688e6ce6450aeada3309d620f
2018-01-17 07:29:53 -08:00
Peter van der Zee 4ac601694a Consolidate the defaulting of options
Reviewed By: davidaurelio

Differential Revision: D6736170

fbshipit-source-id: 3b08279cc8a8022e1cb9cceea9665f30b9575cde
2018-01-17 04:20:33 -08:00
Peter van der Zee 329cfb4ee0 Remove lodash dep
Reviewed By: davidaurelio

Differential Revision: D6736155

fbshipit-source-id: 3a9785ecc887f7b49ab3c2ac36b25ea458b1d783
2018-01-17 04:20:33 -08:00
Rafael Oleza eaa4331d70 Add ws dependency
Reviewed By: cpojer

Differential Revision: D6733857

fbshipit-source-id: fff18fcd02a3115a4b65f0c65441f8758338b272
2018-01-17 03:36:22 -08:00
Rafael Oleza afb9b8488d Upgrade connect dependency
Reviewed By: cpojer

Differential Revision: D6732727

fbshipit-source-id: 80181ef184c90e3312789579034d70e2c3bcbf98
2018-01-17 03:36:22 -08:00
James Ide bb93e339fa Use `error.message` to set the `description` property of a nested error payload
Summary:
Depends on #124.

 ---

**Summary**
Metro reports errors using a JSON payload that has an `errors` array. Each item in this array has a `description` field. For transform errors, this field was set using the value in `error.description` -- however, JS Error objects only have a `message` field. (Grepping the Metro code, no errors (except in one test) ever get a `description` field.) This commit uses `error.message` instead of `error.description` when creating JSON payloads.

```
$ git grep description -- 'packages/**/*.js'
packages/metro/src/JSTransformer/__tests__/Transformer-test.js:        babelError.description = message;
packages/metro/src/lib/formatBundlingError.js:    description: string,
packages/metro/src/lib/formatBundlingError.js:): {type: string, message: string, errors: Array<{description: string}>} {
packages/metro/src/lib/formatBundlingError.js:      errors: [{description: message}],
packages/metro/src/lib/formatBundlingError.js:        description: error.message,
packages/metro/src/node-haste/__tests__/Module-test.js:  description: "A require('foo') story",
```

**Test Plan**
Added a unit test to check that the description field is set for transform errors (with the delta bundler).

Also in a test RN app, inspected the error payload that is received by RN when there's a syntax error with HMR turned on and verified that `data.body.errors[0].description` was set.
Closes https://github.com/facebook/metro/pull/125

Differential Revision: D6730671

Pulled By: rafeca

fbshipit-source-id: 58311462db9223d65580d77748203d8ea0ea1ac7
2018-01-16 17:14:32 -08:00
James Ide b7248380a6 Fix RN redbox messages for syntax errors by including error messages in payload
Summary:
**Summary**
With RN 0.52, when there was a redbox due to a syntax error in a source file (with regular, non-delta bundler), the redbox would say just "No message provided". The JSON that Metro sent to RN did not include a "message" field because `JSON.stringify(error)` does not include `message`.

**Test Plan**
Add a syntax error to one of the files in RNTester's JS and load the RNTester app (from RN master). See that the redbox now says there was a transform error with the syntax error's location.

Also tested adding a syntax error with HMR enabled and saw that the error `message` field was set in the payload as expected.

Also added a Jest test to Server-test.js.
Closes https://github.com/facebook/metro/pull/124

Differential Revision: D6728310

Pulled By: rafeca

fbshipit-source-id: 9ee3c113767d8c2849bcaac0cb8a9cfa8f2760a6
2018-01-16 17:14:32 -08:00
Rafael Oleza 3c3d95fb15 Make the global cache logic aware of the assetDataPlugins transform option
Reviewed By: jeanlauliac

Differential Revision: D6727589

fbshipit-source-id: d15fb501c7b1cd64c5fb494523a9154322a63dc6
2018-01-16 10:29:16 -08:00
Jean Lauliac dfcaa30f26 metro: break jest-haste-map cache
Reviewed By: cpojer, mjesun

Differential Revision: D6728279

fbshipit-source-id: ef26c6a295626adb6ff6272b308110fd00b096e2
2018-01-16 10:29:15 -08:00
Miguel Jimenez Esun cc7ceebaff Bind files to workers
Reviewed By: davidaurelio

Differential Revision: D6284120

fbshipit-source-id: f674214fbbc2f2463e0180c5dae45ace7f9c1563
2018-01-16 03:34:42 -08:00
Jean Lauliac 69ae428091 metro-buck: get rid of unecessary createBuildSetup
Reviewed By: mjesun

Differential Revision: D6712304

fbshipit-source-id: b720ff00a329b7dd4629751973f102e9b2034e2c
2018-01-16 03:34:42 -08:00
John Knox 826d68d4f5 Add tests for getRemoteFileMap
Reviewed By: mjesun

Differential Revision: D6711831

fbshipit-source-id: e5323e35a86ae03a8acee8c8d9e389218315d46f
2018-01-16 02:40:34 -08:00
Peter van der Zee 333182363a Add @flow to bunch of (mostly test-) files that trivially pass
Reviewed By: rafeca

Differential Revision: D6712326

fbshipit-source-id: 44ef8506664f92a34f8e3ca124bd6167a20fbade
2018-01-15 05:36:55 -08:00
Rafael Oleza a0d15e0d25 Add lodash as a dependency of metro-core
Reviewed By: mjesun

Differential Revision: D6722187

fbshipit-source-id: ae71df127e0cf3d6a74163b130dd09acaaf9f6ab
2018-01-15 04:58:35 -08:00
Adam Ernst 2e34f6f9a8 Add a flush() function to Terminal
Reviewed By: yungsters

Differential Revision: D6713011

fbshipit-source-id: 05afd49e4099301124d83e1b345d7b40a9c84c73
2018-01-12 13:03:39 -08:00
Rafael Oleza 5d3581e795 Bump metro to v0.24.4
Reviewed By: mjesun

Differential Revision: D6711855

fbshipit-source-id: 88192d22a8b50f16ad329b6dfdb7c5da24b2ce9e
2018-01-12 09:18:09 -08:00
Rafael Oleza 81a500cd67 Tweak default transformer to do some very minimal babel transformation
Reviewed By: jeanlauliac

Differential Revision: D6711526

fbshipit-source-id: 03c6aea85fb6d13e92e458a46bf4a3db1268aa11
2018-01-12 07:44:51 -08:00
Maël Nison 1cad201448 Exposes HMR through the Metro API
Reviewed By: rafeca

Differential Revision: D6692912

fbshipit-source-id: 6f119170c40fb99bf2cad83d00edba91bcbbe1c9
2018-01-12 07:28:47 -08:00
Maël Nison cfe3670a07 Makes js1 run use the builtin Metro CLI
Reviewed By: rafeca

Differential Revision: D6510003

fbshipit-source-id: c0593c71a4b5c236b3e2e91c31f8a7c87bd83e42
2018-01-12 07:28:47 -08:00
James Ide da2fdba240 Add back support for the assetPlugin option
Summary:
**Summary**
Metro used to have support for "asset plugins", which allowed developers to specify arbitrary JS modules that could export a function for adding more fields to asset data objects. Some of this functionality was removed in the delta bundler work -- this PR adds it back.

**Test plan**
Made existing unit tests pass and added unit tests to test asset plugin behavior. Also tested E2E in a React Native project by adding `assetPlugin=/path/to/pluginModule` to a JS bundle URL and ensuring that the plugin ran.
Closes https://github.com/facebook/metro/pull/118

Differential Revision: D6711094

Pulled By: rafeca

fbshipit-source-id: f42c54cfd11bac5103194f85083084eef25fa3cd
2018-01-12 06:01:43 -08:00
Peter van der Zee 1152a69432 Fold modulegraphs sourcemap file into metro-source-map
Reviewed By: rafeca

Differential Revision: D6711210

fbshipit-source-id: 1d91df189607c032045f604df75b119a87794ca6
2018-01-12 05:34:01 -08:00
Peter van der Zee 199b51892b Drop redundant type re-export
Reviewed By: mjesun

Differential Revision: D6711235

fbshipit-source-id: 0e5cb6c22ba4000589f8b97dcfb340297aea5a41
2018-01-12 04:51:23 -08:00
Peter van der Zee fe443193c3 Remove double @format
Reviewed By: rafeca

Differential Revision: D6711182

fbshipit-source-id: 30c61d42900cc6c2471827d560f05d0140dd8721
2018-01-12 04:51:23 -08:00
Jean Lauliac 0151519a42 metro-buck: do not transform non-source files
Reviewed By: davidaurelio

Differential Revision: D6666127

fbshipit-source-id: ba20664da81361fadb8119bfeb858c70a7500c14
2018-01-12 04:51:23 -08:00
Peter van der Zee 1687f3766e Flow cleanup
Reviewed By: mjesun

Differential Revision: D6702877

fbshipit-source-id: ddb6c508f4a408316aef19d69b3a73c8744d5355
2018-01-12 04:23:40 -08:00
Peter van der Zee a05eb11cab Stop using `as SourceMap` and just use `MetroSourceMap` instead
Reviewed By: rafeca

Differential Revision: D6702882

fbshipit-source-id: ef4a58569719bd8aeb8f1869943929c255f89595
2018-01-12 04:23:40 -08:00
Peter van der Zee 4697ecf120 Get rid of the "unknown" source-map raw mapping type, use "segments" instead of "raw"
Reviewed By: mjesun

Differential Revision: D6702883

fbshipit-source-id: def36c719eabbcd443b0c643b760a87781977a45
2018-01-12 04:23:40 -08:00
Peter van der Zee 5c2fb8d327 Rename functions to clarify output
Reviewed By: mjesun

Differential Revision: D6702879

fbshipit-source-id: 23daa9027425c2dd1d020eae9873bab092fff573
2018-01-12 04:23:40 -08:00
Peter van der Zee 4403f81102 Rename `BabelRawMapping` to `BabelSourceMapSegment`
Reviewed By: mjesun

Differential Revision: D6702880

fbshipit-source-id: 4c800ef9571bcfed6f3ed8e39d0002a94bd9190f
2018-01-12 04:23:40 -08:00
Peter van der Zee 4cf85b278f Rename `RawMapping` to `MetroSourceMapSegmentTuple`
Reviewed By: mjesun

Differential Revision: D6702878

fbshipit-source-id: d6063e2f356d24c91ff87760fa90bf909d49f98e
2018-01-12 01:28:39 -08:00
Peter van der Zee 01ab028d4f Clean up mapping types
Reviewed By: mjesun

Differential Revision: D6702876

fbshipit-source-id: 5a19ba033016e14b6aaa919ef838e32ed35748c7
2018-01-11 15:30:06 -08:00
Jean Lauliac 67385d8e4a metro: do not override process.env completely in prelude
Summary: This changeset tweaks the prelude so as to avoid overriding `process.env` if it already exists, and add tests to verify this behavior. This is useful when a bundle is loaded in a context that already provides a global `process` somehow, ex. Electron/Node.js. We still do want to override `NODE_ENV` in that case so as to have consistency with constant inlining.

Reviewed By: rafeca

Differential Revision: D6702441

fbshipit-source-id: 69dd9ba2303a43db151cbe1877f01e38d45b05b9
2018-01-11 10:01:28 -08:00
Jean Lauliac 325a216442 metro, metro-buck: unify prelude code
Reviewed By: rafeca

Differential Revision: D6692449

fbshipit-source-id: 21434de55d076bcb020e156212c26b6bc72e437c
2018-01-11 04:59:24 -08:00
Peter van der Zee 3ee6e5bfb5 Bringing clarity to the Mapping types
Reviewed By: rafeca

Differential Revision: D6702118

fbshipit-source-id: 0fc99454713042117ce41ddfe1d3f84c95265d74
2018-01-11 04:28:49 -08:00
Miguel Jimenez Esun ca525f0e8d Upgrade Jest to 22.0.5
Reviewed By: rafeca

Differential Revision: D6684639

fbshipit-source-id: 3fe7772451377619f93b48b1d7f79462a7a85ddc
2018-01-10 08:58:23 -08:00
Peter van der Zee d6feb5a89a Moving source map stuff into its own package
Reviewed By: rafeca

Differential Revision: D6692262

fbshipit-source-id: 7476ec4c8ea45eaea6c19f410e98650ce7eb0acb
2018-01-10 07:43:58 -08:00
Jean Lauliac 997be549aa metro: ModuleResolution: only throw error at top-level
Summary: Next step would be to move the error handling out of this module so that we don't depend on `TModule` at all anymore. Once this is done, the module can be extracted as `metro-resolve`, and we can potentially reuse it for jest, etc.

Reviewed By: davidaurelio

Differential Revision: D6660540

fbshipit-source-id: dd0612bec6b526f9ab52cc2e162b6977e2b1670f
2018-01-10 03:37:40 -08:00
Rafael Oleza 2ab9c268b1 Move preludes and require.js files to lib folder
Reviewed By: jeanlauliac

Differential Revision: D6674423

fbshipit-source-id: e459e7e8c58b2282b8d341cf7a2d71429e7b7081
2018-01-09 18:14:47 -08:00
Rafael Oleza bdaddb2585 Remove Resolver module
Reviewed By: jeanlauliac

Differential Revision: D6674419

fbshipit-source-id: 75cd9dbbc90725850ce23b62c9c8c50922145dd3
2018-01-09 18:14:47 -08:00
Rafael Oleza a5b0f236e4 Move module minification logic to Bundler
Reviewed By: jeanlauliac

Differential Revision: D6674420

fbshipit-source-id: ee552812437da731f419871cfca9ae930fa8f6a9
2018-01-09 18:14:47 -08:00
Rafael Oleza eb489bf105 Remove logic to calculate polyfills from Resolver
Reviewed By: jeanlauliac

Differential Revision: D6674424

fbshipit-source-id: 20c0ace056150c1f6910edc7eadf8effb9ddf38d
2018-01-09 18:14:47 -08:00
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