Commit Graph

2046 Commits

Author SHA1 Message Date
Peter van der Zee 8097f8d6e5 Use lodash.throttle instead of lodash/throttle to prevent requiring the whole lodash lib
Reviewed By: jeanlauliac

Differential Revision: D6774508

fbshipit-source-id: bc06adda862a3ac2eb4499d941a99a03a5928952
2018-01-23 01:44:11 -08:00
Rafael Oleza 51c38629df Make the React Native HMR client extend from the generic metro HMR client
Reviewed By: BYK

Differential Revision: D6752278

fbshipit-source-id: 5c93cba3e9f3cee2119cb90a711909e0b4a5b835
2018-01-22 10:26:53 -08:00
Rafael Oleza 2f93b745ef Tweak circleci configuration
Summary:
We've had the node v6 test step failing for some time now (due to https://github.com/prettier/prettier/issues/3457).

Since there seems to be no progress on that issue, I'm adopting a similar approach that React Native has done to work around the issue: run the linter and flow on the latest nodejs version, and only run the jest tests on previous versions (this is also that `jest` seems to be doing as well).

For this I've created a `run-js-checks` step, while the jest tests are still under the `test-node-X` steps

Reviewed By: jeanlauliac

Differential Revision: D6770795

fbshipit-source-id: ba79caaf82c4b2fda5786a4cd3a9b2015c8b4537
2018-01-22 08:29:34 -08:00
William Desportes d6e13bece2 Added metro-core && fixed code
Summary:
Terminal moved to metro-core according to [commit](a96e99fae5) "Move Terminal to metro-core"
Closes https://github.com/facebook/metro/pull/115

Differential Revision: D6772184

Pulled By: jeanlauliac

fbshipit-source-id: cbf03940b64af9415d335bd1a6bb80e1ae4e90db
2018-01-22 03:20:40 -08:00
Jean Lauliac 59515d058c metro-buck: add control modules
Reviewed By: davidaurelio

Differential Revision: D6738569

fbshipit-source-id: 4f4c7310bf9ec389c075ed6b93a6ff819bf84519
2018-01-22 03:20:35 -08:00
Rafael Oleza 13ba5516d1 Bump metro@0.24.6
Reviewed By: arcanis, cpojer

Differential Revision: D6761110

fbshipit-source-id: b23536d639ed9e963893ef784c93aa0c6ab452a4
2018-01-19 11:36:19 -08:00
Rafael Oleza 19e52ee233 Add workaround to make metro not fail when being run with RN 0.52
Reviewed By: BYK, cpojer

Differential Revision: D6760980

fbshipit-source-id: 78fa75a74391baf18fc5615ef218facc65bc23d1
2018-01-19 11:36:19 -08:00
Rafael Oleza 350e9e4a7e Bump metro@0.24.5
Reviewed By: BYK

Differential Revision: D6759031

fbshipit-source-id: b6ba1e2da77b944c8c73d229749f84d9c16035c7
2018-01-19 08:24:22 -08:00
Rafael Oleza b5d123a99c Add generic HMR Client to metro
Reviewed By: BYK

Differential Revision: D6752277

fbshipit-source-id: 9d5e9e16e7d848fd12454136c6ff10a0a4fa3ae1
2018-01-19 08:24:18 -08:00
Rafael Oleza 429b91c382 Allow to attach the HMR server to an external http server
Reviewed By: BYK

Differential Revision: D6752279

fbshipit-source-id: 250255a3b1226f8aab6054e507cb3910cdcd6a85
2018-01-19 08:24:17 -08:00
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
David Aurelio 595f9d2d6c Stop ignoring `build/` folders
Reviewed By: rafeca

Differential Revision: D6736273

fbshipit-source-id: 4f332cf366ce3e79101509a526fb265a3a43acc0
2018-01-17 06:44:57 -08:00
David Aurelio 00544a9015 Stop ignoring `yarn.lock` in packages
Reviewed By: cpojer

Differential Revision: D6736274

fbshipit-source-id: 3ff73c5bc4ab120a6f320131f05c32534947f38c
2018-01-17 06:44:57 -08:00
Rafael Oleza 48092efe3b Consolidate metro's yarn.lock file
Reviewed By: cpojer

Differential Revision: D6736698

fbshipit-source-id: 89d7456c89af9b2f3ab1eacddfc6d278e3cfae32
2018-01-17 06:19:06 -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 b8fa8e0a7e Add babel version to build output
Reviewed By: mjesun

Differential Revision: D6722581

fbshipit-source-id: d6d1d79f86baa2b75673ef5c097aa27653621f60
2018-01-15 07:29:29 -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
Peter van der Zee 600af08361 Fix lint errors and add flow directive
Reviewed By: jeanlauliac

Differential Revision: D6722105

fbshipit-source-id: bcb81c47ff9feb7522ecfa393be53bf1c6604c91
2018-01-15 04:58:38 -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
codypearce 23855d0290 Fix Get started and Learn more button links on the index page
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? -->

Fixes #114 Learn more button links to a page that doesn't exist. This fixes both Learn more and Getting Starting buttons according to the comment in the issue.

**Test plan**

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

Differential Revision: D6719758

Pulled By: rafeca

fbshipit-source-id: 9647affacdda3c04b1e180fa95c1da28a51c0926
2018-01-13 13:58:46 -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 4260847ad7 Add Flow type definition for the "debug" library
Reviewed By: rafeca

Differential Revision: D6706956

fbshipit-source-id: 6192beb439440ef36fd74645805922daf7318530
2018-01-12 03:15:05 -08:00