Commit Graph

884 Commits

Author SHA1 Message Date
Rafael Oleza 6da4bc4d30 Make sure that files that have been modified and deleted afterwards are marked as deleted
Reviewed By: davidaurelio

Differential Revision: D7030986

fbshipit-source-id: e00fc80ff6f5cb7bb49714d35c91361cb795ad0b
2018-02-22 09:39:51 -08:00
Michal Glaus 40c2449eec Pass numWorkers instead of maxWorkers to jest-worker
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**

Jest Worker accepts parameter `numWorkers`, not `maxWorkers`, see:
https://github.com/facebook/jest/tree/master/packages/jest-worker#numworkers-number-optional

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

**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/136

Reviewed By: mjesun

Differential Revision: D7036411

Pulled By: rafeca

fbshipit-source-id: 5528ca4a9abe5a8e3668e83b214e10d97ba7a827
2018-02-22 08:31:07 -08:00
Burak Yigit Kaya a984719eef Upgrade Jest to 22.4.0 to pull fixes for jest-haste-map
Reviewed By: mjesun

Differential Revision: D7041111

fbshipit-source-id: 6dbd0cbf7b62a54d0b5f16bbf2fa81332542f14e
2018-02-22 06:15:23 -08:00
Maël Nison b354a81427 Uses Yargs instead of Command
Summary: This diff allows Metro to throw an error when a configuration file cannot be found, by using a new strict: true option.

Reviewed By: rafeca

Differential Revision: D6998613

fbshipit-source-id: b704633be18d5c007f1a022fa811d0a74c636fc9
2018-02-22 06:08:20 -08:00
Maël Nison eb72ad3794 Makes the Metro CLI commands injectable
Summary: This diff makes the Metro CLI commands injectable into any Yargs object, so that we can override various aspects of it, add extra commands, etc.

Reviewed By: davidaurelio

Differential Revision: D6988250

fbshipit-source-id: 217c661e4c1b05282b6cdbf4d745d1b29f5cbbe0
2018-02-22 06:08:20 -08:00
Peter van der Zee 60f16aafc2 Version bump babel-plugin-external-helpers
Reviewed By: cpojer

Differential Revision: D7054249

fbshipit-source-id: 5cb5619ab700e61a9f4feeceac0a5b803ddfdc15
2018-02-22 04:14:23 -08:00
Miguel Jimenez Esun 0f3f7daa4f Move mocking inside beforeEach for Transformer test
Reviewed By: rafeca

Differential Revision: D7040798

fbshipit-source-id: eece8c42e1368ead476c6d1495dad7e0abb4b0e3
2018-02-21 04:53:06 -08:00
Jean Lauliac d110c7b9ea metro: extract metro-resolver package
Reviewed By: rafeca

Differential Revision: D7011526

fbshipit-source-id: 523c54792cef1c31eef281e6e39bc25b20e2ceec
2018-02-21 04:53:06 -08:00
Peter van der Zee 5aa19c7626 Add minifier-path option to Metro
Summary:
This exposes the `minifierPath` externally and allows it to be adjusted through the `--minifier-path` argument.

This works for both the server (when starting the server) and running a single build through the CLI.

In server mode, this can not be used per file request yet, though that should also be doable if need be.

Reviewed By: rafeca

Differential Revision: D6998562

fbshipit-source-id: 669b876c24fe117ec88b2200d48aa82658f568b4
2018-02-20 04:22:00 -08:00
Peter van der Zee c080d70699 Start making the minifier an option for Metro
Reviewed By: jeanlauliac

Differential Revision: D6998187

fbshipit-source-id: 32e6fbb756ff119ed8a3070585e9f6c39fab1baa
2018-02-20 04:22:00 -08:00
Peter van der Zee e9e3a986c7 Add a minifier path option to the ModuleGraph path
Reviewed By: mjesun

Differential Revision: D6998189

fbshipit-source-id: 4876de98b9970088161d78e1b462688307ef477f
2018-02-20 04:22:00 -08:00
Rafael Oleza 25b201148b Refactor the traversal of dependencies logic
Reviewed By: jeanlauliac

Differential Revision: D7009928

fbshipit-source-id: a56e4d3b5a3b2c91f14affbc56cbca56c8526d06
2018-02-19 06:52:36 -08:00
Rafael Oleza cfe175254a Do not do unnecessary work when re-adding a file after deleting it
Reviewed By: mjesun

Differential Revision: D7009760

fbshipit-source-id: 18a93443226bdec4decb69f75539e27f528c128c
2018-02-19 06:52:36 -08:00
Rafael Oleza a5307e986e Make metro rely much less in the ModuleCache system
Reviewed By: jeanlauliac

Differential Revision: D6949157

fbshipit-source-id: cb5ef25aa582935f7c624375392be7fceefd87b6
2018-02-19 06:52:36 -08:00
Miguel Jimenez Esun 03c3b3d219 Fix JSTransformer/index test
Reviewed By: jeanlauliac

Differential Revision: D7019771

fbshipit-source-id: cbf232dc22f55d75dced3206b3c4ef1a472a7102
2018-02-19 04:59:47 -08:00
Peter van der Zee dd48bb1fa3 Improve Flow coverage
Reviewed By: mjesun

Differential Revision: D6999089

fbshipit-source-id: 5dfaef91909060b5a2bec0030048e97c2c2c3698
2018-02-19 04:24:08 -08:00
Sophie Alpert 2a327fb19d Update to MIT license
Summary: Manual changes.

Reviewed By: TheSavior, yungsters

Differential Revision: D7012152

fbshipit-source-id: de7459be3db13c687868b45059856f125c4f2eb1
2018-02-16 18:30:48 -08:00
Sophie Alpert 8242229b59 Update license headers for MIT license
Summary:
Includes React Native and its dependencies Fresco, Metro, and Yoga. Excludes samples/examples/docs.

find: ^(?:( *)|( *(?:[\*~#]|::))( )? *)?Copyright (?:\(c\) )?(\d{4})\b.+Facebook[\s\S]+?BSD[\s\S]+?(?:this source tree|the same directory)\.$
replace: $1$2$3Copyright (c) $4-present, Facebook, Inc.\n$2\n$1$2$3This source code is licensed under the MIT license found in the\n$1$2$3LICENSE file in the root directory of this source tree.

Reviewed By: TheSavior, yungsters

Differential Revision: D7007050

fbshipit-source-id: 37dd6bf0ffec0923bfc99c260bb330683f35553e
2018-02-16 18:30:48 -08:00
Miguel Jimenez Esun e651b81881 Move "transformFile" to "transform" to match worker interface
Reviewed By: cpojer

Differential Revision: D6968803

fbshipit-source-id: 7dee92d5a58e18bb1ee0d5cd5748acd44cde5b18
2018-02-16 11:49:30 -08:00
Miguel Jimenez Esun b129827fa2 Move Buck-specific config into its own types.flow
Reviewed By: rafeca

Differential Revision: D6949488

fbshipit-source-id: aa26b3cb51809569ea2123d9a24cb99506b2b52b
2018-02-16 11:49:30 -08:00
Jean Lauliac 0386ef17e9 metro: ModuleResolution: extract resolveDependency
Reviewed By: rafeca

Differential Revision: D6999063

fbshipit-source-id: 2568d996f7403fcd6f8b9a9311f5bdfa36b25b52
2018-02-16 09:24:43 -08:00
Rafael Oleza 29115f729c Make the getTransformCacheKeyFn-test not dependant on the metro version
Reviewed By: davidaurelio

Differential Revision: D6976235

fbshipit-source-id: 8ba5a0413c3c96224a91d6972beda5a413557646
2018-02-16 05:53:06 -08:00
Peter van der Zee 5b383fce16 Cleanup lint errors
Summary:
Argument was no longer used and is causing lint errors.
Dropping it simplifies the debounce function as well.

Reviewed By: davidaurelio

Differential Revision: D6999567

fbshipit-source-id: 8856ed40feb0fa23155c9d18e20c43550aac876b
2018-02-15 10:07:45 -08:00
Andres Suarez 581623ed11 Fold .eslintrc's into the root eslintrc
Reviewed By: davidaurelio

Differential Revision: D6996960

fbshipit-source-id: f05c76b7356b21ecb8db4489920fd3a1fc34f1d9
2018-02-15 08:24:07 -08:00
Miguel Jimenez Esun b958c400f0 Upgrade Jest to 22.3.0
Reviewed By: BYK

Differential Revision: D6978514

fbshipit-source-id: 3c6be52d38fedbe849dee6319bb2e4d7a97297c9
2018-02-15 03:38:41 -08:00
Peter van der Zee 084dbcef30 Move the minifier to its own package
Reviewed By: davidaurelio

Differential Revision: D6988462

fbshipit-source-id: 437b8a2fda3f25d7ace73d548602356de319a99d
2018-02-15 03:38:41 -08:00
Rafael Oleza d9b6fd7102 Pass cacheVersion param via the new API
Reviewed By: BYK

Differential Revision: D6980337

fbshipit-source-id: 72c01136b6720390ffec8593f0375c8756dc1d4a
2018-02-14 08:46:56 -08:00
Rafael Oleza afa3307659 Fix enableBabelRCLookup option in new CLI + global cache script
Reviewed By: BYK

Differential Revision: D6977885

fbshipit-source-id: 50245e046c7639f9fb4022a9cc5974d50831524c
2018-02-14 08:46:56 -08:00
Rafael Oleza 33e93dcde3 Bump metro@0.26.0
Reviewed By: cpojer

Differential Revision: D6976161

fbshipit-source-id: 0cf20f4b2372997a8aac41cc07a9bdd641a93ad4
2018-02-13 07:15:04 -08:00
Rafael Oleza c955b65b22 Remove flaky babel 7 test + some small lint fixes
Differential Revision: D6976119

fbshipit-source-id: 0315511e8835e7dcfc796ac7133b24346d805853
2018-02-13 06:31:03 -08:00
Christoph Nakazawa 892b4ac9de Expose getDependencies when using RAM bundles
Reviewed By: rafeca

Differential Revision: D6965192

fbshipit-source-id: 8f4178aa4c38c03beab6da8bcaf4dc193c02b044
2018-02-12 10:16:19 -08:00
Andres Suarez 7d5a120fe9 Namespace custom ESLint rules through eslint-plugin-lint
Reviewed By: mzlee

Differential Revision: D6934651

fbshipit-source-id: 3cb0c3550ad628e3b5c0bdaec8cde9d5579ea0af
2018-02-09 11:14:55 -08:00
Peter van der Zee eacd27ecaa Remove log
Reviewed By: jeanlauliac

Differential Revision: D6948396

fbshipit-source-id: 5c9286b47257820bd4ec0da3068c5b21dbaff663
2018-02-09 04:32:23 -08:00
Maël Nison f12b07101e Refactors option forwarding from RN-cli to Metro
Reviewed By: jeanlauliac

Differential Revision: D6936821

fbshipit-source-id: aeaad43ca056cf0cb26255e426695f3bfb396368
2018-02-09 04:32:23 -08:00
Jean Lauliac 07a79853ef metro: ModuleResolution: extract resolveModulePath
Summary: Continue cleaning up the resolution algo. By removing the class completely as well as the `TModule` type, and providing options via the `context`, we'll be able to identify clearly the inputs of the resolution algorithm, and reuse it eventually for Jest. This changeset extract one more function in this fashion. Next steps: extract the rest of the stateful code into functions, or into `ResolutionRequest`.

Reviewed By: davidaurelio

Differential Revision: D6937569

fbshipit-source-id: bab0bcd280be32a11f23174b0591dd0cc7dee7ab
2018-02-08 10:14:25 -08:00
Jean Lauliac 1498c4ba6b metro-buck: getLibrary: precompute asset hashes
Reviewed By: davidaurelio

Differential Revision: D6937279

fbshipit-source-id: 328f06b2b66eeed6fd2f767dab1a03854c4dd28c
2018-02-08 10:06:29 -08:00
Jean Lauliac 01a92f3c2f asyncRequire: wrap result in default
Reviewed By: cpojer

Differential Revision: D6911464

fbshipit-source-id: 44953e0716e076e50d551738059435697d064733
2018-02-08 09:15:55 -08:00
Rafael Oleza 6f6890505e Bump metro@0.25.1
Reviewed By: cpojer

Differential Revision: D6924028

fbshipit-source-id: f643bd912b201a5333778f124b0c21acf84814df
2018-02-07 09:29:50 -08:00
Maël Nison cbaf70ce99 Ensures that the Metro server is closed when an exception happens in runBuild
Differential Revision: D6924180

fbshipit-source-id: 80f5bf60aa357ce8df0598e8fdac92776c4af601
2018-02-07 09:23:04 -08:00
Miguel Jimenez Esun be528451f5 Upgrade Jest to v22.2.1
Reviewed By: rafeca

Differential Revision: D6923664

fbshipit-source-id: 0751ee6f0eb72193b0b22bb38d0398b3d83592a3
2018-02-07 08:45:48 -08:00
Christoph Nakazawa a28fba69c8 Allow to pass output bundle object
Reviewed By: davidaurelio

Differential Revision: D6923820

fbshipit-source-id: 99a9cdeab867f0f749792ca62edee8ebdee33328
2018-02-07 07:27:29 -08:00
Danny B 532a2139b8 Clarify advice on resetting bundler cache
Summary:
**Summary**

The cache dir name now starts with `metro-bundler-cache-` but the message still refers to `react-`.

This just wasted a bit of my time before I realized and that's not the first time this happens either.

Also I don't have `$TMPDIR` defined on vanilla ubuntu, I think using that instead of `/tmp` creates more confusion than helps.

**Test plan**

Just a change in a string constant.

I signed the CLA.
Closes https://github.com/facebook/metro/pull/131

Differential Revision: D6923347

Pulled By: rafeca

fbshipit-source-id: 4e816e5d0c75b0d2ee5ddf4d92d2d7397011d4e4
2018-02-07 04:50:27 -08:00
Maël Nison 1f743f3e93 Adds a globalTransformCache option to the metro API
Reviewed By: rafeca

Differential Revision: D6900514

fbshipit-source-id: b150662b5aec9c11506333b07377165636d9180c
2018-02-06 06:29:41 -08:00
Maël Nison bc6f188a59 Moves the maxWorkers default into the API rather than the CLI
Reviewed By: BYK, davidaurelio

Differential Revision: D6883200

fbshipit-source-id: 9f5a73f873adc3ac39286c7f32d4f759eb36820d
2018-02-06 03:17:27 -08:00
Rafael Oleza c2fb238b5d Bump metro@0.25.0
Reviewed By: davidaurelio

Differential Revision: D6878299

fbshipit-source-id: cde26c9c9e56ee9a052f1915ad7772ae475b5e41
2018-02-05 21:44:21 -08:00
Rafael Oleza e162ea7698 Break infinite loop when trying to hot patch circular dependencies
Reviewed By: BYK

Differential Revision: D6853993

fbshipit-source-id: 9e42d207738102e019fccea517411fccd0fb6b1b
2018-02-05 21:44:21 -08:00
Rafael Oleza e329f00dc9 Avoid doing multiple unnecessary traversals when hot patching modules
Reviewed By: martinbigio

Differential Revision: D6853969

fbshipit-source-id: 982ca135a4113c985bbd7d8e8631601e16844a86
2018-02-05 21:44:21 -08:00
Peter van der Zee 1f14cf1a0f Add progress bar to Metro cli build
Reviewed By: davidaurelio

Differential Revision: D6899035

fbshipit-source-id: 4e9c852ecc8d7d172919a79385903e95c0bc239e
2018-02-05 06:14:25 -08:00
Peter van der Zee d6e80c4ebf When the sourceMap option is false, try to listen to it better
Summary:
I think the default value for the `--source-map` option is true, although it's not defined that way explicitly. Regardless, when it's explicitly set to `false` I would expect Metro to at least listen to that. Currently that's not the case. This diff attempts to improve that situation.

Note that it's still not perfect since there are more places where sourcemaps are still being touched when this flag is `false`. It turns out adding a proper flag for this leads to a lot of cascading type problems and so I ended up with this fix instead.

Reviewed By: rafeca

Differential Revision: D6884423

fbshipit-source-id: 7fe10045d9d9f73c7841588627ba41b14c2e412b
2018-02-05 01:16:56 -08:00
Peter van der Zee eb08ed4adc Dont build sourcemap stuff if it wont be used
Summary: Don't bother to work on the source map if it won't be used anyways

Reviewed By: rafeca

Differential Revision: D6884244

fbshipit-source-id: ac014bf982e33c669a1e79f16dd06149e758a797
2018-02-05 01:16:56 -08:00
Peter van der Zee 5e505980ec This function was working inline, reflect this clearly
Summary:
This function was working on a source map object inline and then returning the same reference.

For clarity it's better if it either clones the whole thing (that would be a waste) or not return the reference at all. Also renamed the function (but not the file) for clarity.

Dropped the unused check and updated callsites instead.

Reviewed By: mjesun

Differential Revision: D6884241

fbshipit-source-id: 33aa7a1ad7096510903bbb74dd6b9c675b81aff5
2018-02-05 01:16:56 -08:00
Peter van der Zee 63e8aebf79 Dont build sourcemap if it will not be used
Summary: Don't bother to work on the source map if it won't be used anyways

Reviewed By: mjesun

Differential Revision: D6884247

fbshipit-source-id: 811409313e7ac1a7255ddd0eed665ed92020241e
2018-02-05 01:16:56 -08:00
Peter van der Zee b1372a37bd Dont relativate source map if it wont be used
Summary: Don't bother to work on the source map if it won't be used anyways

Reviewed By: mjesun

Differential Revision: D6884243

fbshipit-source-id: 483664ad32a72a8e6e3de3e0cc224b3a6ea67d46
2018-02-05 01:16:56 -08:00
Peter van der Zee 92e9cfa050 Drop unused arg
Summary: Small refactor

Reviewed By: mjesun

Differential Revision: D6884242

fbshipit-source-id: b811238c91b0e82d8b25420aa1b463f9d8293482
2018-02-05 01:16:56 -08:00
Peter van der Zee 23e4d7abae Prevent unnecessary deserialize/serialize of sourcemap
Summary: This prevents unnecessary JSON.stringify/JSON.parse when the operation is noop anyways.

Reviewed By: mjesun

Differential Revision: D6884246

fbshipit-source-id: 3370caac1e01cb79f86af95f0dd06285150c5d95
2018-02-05 01:16:56 -08:00
Rafael Oleza 79fd0b341e Allow to pass custom transformer parameters via the request url
Reviewed By: davidaurelio

Differential Revision: D6869137

fbshipit-source-id: a985b2df7e4fca308e62adaededc2ad0038d5373
2018-02-04 09:29:07 -08:00
Rafael Oleza cd23c579b5 Rename the require function name inside modules
Reviewed By: davidaurelio

Differential Revision: D6818774

fbshipit-source-id: ae67dccc07fa8c56be28d7b83e2f510d927e2345
2018-02-04 09:29:07 -08:00
Maël Nison 4c4eaeac8a Renames fetchMetroConfig into loadMetroConfig
Reviewed By: davidaurelio

Differential Revision: D6834104

fbshipit-source-id: fc8e9300dd43b2212c067595063fc2f98dbc8e3b
2018-02-02 05:20:49 -08:00
Maël Nison c020e40894 Removes projectRoots & enhanceMiddleware from the metro options
Reviewed By: davidaurelio

Differential Revision: D6834105

fbshipit-source-id: de7e2264c9902f098a641265e4f3a0aaa0a9100a
2018-02-02 05:20:49 -08:00
Maël Nison 2312bf2929 Uses findMetroConfig and fetchMetroConfig in the internal RN cli
Reviewed By: davidaurelio

Differential Revision: D6819226

fbshipit-source-id: 6436855cc5dce9ce7922d89df99c3cb90abb095e
2018-02-02 05:20:48 -08:00
Maël Nison a620cf05d1 Plugs the metro runServer function into the internal CLI
Reviewed By: rafeca

Differential Revision: D6797531

fbshipit-source-id: 52dab36749c84274d7b70666ee9359afb8cac31e
2018-02-02 05:20:48 -08:00
Peter van der Zee d23c3ca10b Rename `Ast` to a more appropriate `BabelNode` in the babel flow type
Summary:
An Ast consists of `Node` elements and the one Babel uses is specific to Babel (incompatible with Astree spec by default) so `BabelNode` seems more appropriate.

Keeping the other `ast` names for now to reduce the footprint of this diff.

Also makes sure `babel-core` properly exports the same node type as what the api returns making fixes to this type in the future easier to implement.

Reviewed By: davidaurelio

Differential Revision: D6834291

fbshipit-source-id: 4cb0eb2ee280a4988071b8412539edfad12cf56f
2018-02-01 03:23:50 -08:00
Peter van der Zee 7fcff0a976 Small refactor
Summary: This test can be simplified.

Reviewed By: davidaurelio

Differential Revision: D6834289

fbshipit-source-id: 23072230ce844c39b5fba30cfe7ad51e5a879bed
2018-02-01 03:01:44 -08:00
Peter van der Zee bd345427a8 Use the new `sync` versions of `translate` from babel core
Reviewed By: davidaurelio

Differential Revision: D6834295

fbshipit-source-id: 3a954d9c7b62042e15fbbfa428fde4fc81158247
2018-01-31 08:15:16 -08:00
Peter van der Zee 45be0395ce Use Babel 7 when building packages
Reviewed By: davidaurelio

Differential Revision: D6834296

fbshipit-source-id: 177c0ff41145961d8debe623eac3fbd2ca0919bf
2018-01-31 08:15:16 -08:00
Peter van der Zee 9ac44657bc Add Babel 7 packages to metro (only)
Reviewed By: davidaurelio

Differential Revision: D6834293

fbshipit-source-id: 8375f6ff770673e47770b5af19bb50bb6faf0914
2018-01-31 08:15:16 -08:00
Bhuwan Khattar 1ddb0227ff Pass hasteImplModulePath to JestHasteMap and everywhere else
Reviewed By: jeanlauliac

Differential Revision: D6641294

fbshipit-source-id: 36ebec95e69fe920c6cc10addd96406521cb4b82
2018-01-30 11:26:52 -08:00
Peter van der Zee 448c85014c Add babel bridge to switch easily between 6 and 7
Summary:
This bridge pulls in the various babel things and exports them again.

In a future update this bridge will also pull in babel 7 versions of the same thing and an env var will determine which sources to use so you can switch between using babel 6 or 7 through ENV.

Reviewed By: davidaurelio

Differential Revision: D6844862

fbshipit-source-id: 610a60eaf7bf368eddcd015e37f228651e2fd78b
2018-01-30 07:34:51 -08:00
Peter van der Zee f9dc29afbc Fix missing `Ast` flow type
Summary: The type was not imported and this escaped the attention of Flow somehow.

Reviewed By: davidaurelio

Differential Revision: D6834292

fbshipit-source-id: 8a9b5f2ac56fca2d0ff298b52f54935327eb2686
2018-01-30 04:43:54 -08:00
Peter van der Zee 51cb4df06f Fix missing `Ast` flow type
Summary: The type was not imported and this escaped the attention of Flow somehow.

Reviewed By: davidaurelio

Differential Revision: D6834298

fbshipit-source-id: 96f754d5aae9fda661cb18bbbb30ccfd033598a1
2018-01-30 04:43:54 -08:00
Jean Lauliac 4b7371d732 metro: collectDependencies: do not hardwire dependency on asyncRequire
Reviewed By: rafeca

Differential Revision: D6773002

fbshipit-source-id: a55b63f6bf20f467496ffe1d18c663b87f5d7ba6
2018-01-29 08:56:53 -08:00
Rafael Oleza 47519ec56b Bump metro@0.24.7
Summary: Releasing a new version of metro with an executable CLI

Reviewed By: davidaurelio

Differential Revision: D6808207

fbshipit-source-id: 68f6522924ea8ad7b6f9aaa3e952ebcf23d2cf8b
2018-01-25 09:30:07 -08:00
Rafael Oleza af15faa397 Add shebang to metro cli
Summary: To be able to run the metro CLI directly (for example via `yarn run`) we need to add the shebang pointing to the nodejs binary

Reviewed By: davidaurelio

Differential Revision: D6808095

fbshipit-source-id: 89628c07a92266432a404b6bc26eaa412d7859b9
2018-01-25 09:01:59 -08:00
Peter van der Zee 4cf7b69527 Remove the full lodash dep from Metro
Reviewed By: davidaurelio

Differential Revision: D6783736

fbshipit-source-id: 8fee6cbc340a0a0c9b81a825688817d28d1be8f1
2018-01-23 08:28:38 -08:00
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
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
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