Commit Graph

1834 Commits

Author SHA1 Message Date
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
Jan Kassens 2596f0f362 use babylon 7 to allow React fragments to parse
Summary: For React's new fragment syntax (`<>Foo</>`) to work, we need to upgrade from Babylon 6.

Reviewed By: dwwoelfel

Differential Revision: D6888282

fbshipit-source-id: 5212cc9439a2f79febc72e0f9eef1a7f6b700266
2018-02-05 14:47:39 -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 7a3275a1e8 Writes documentation for Metro's API
Reviewed By: davidaurelio

Differential Revision: D6808245

fbshipit-source-id: 4c153c2c9dc8ddef3ebc564507281792267a2cc0
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 d986aac32b Add flow types for Babel 7 (but not the library, these are only declares)
Reviewed By: davidaurelio

Differential Revision: D6834294

fbshipit-source-id: ffe66a6e7b683a4ed6361622049206869c635b71
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
James Pearce 0a2ea391a9 Redundant parenthesis
Summary: Closes https://github.com/facebook/metro/pull/129

Reviewed By: rafeca

Differential Revision: D6804796

Pulled By: jamesgpearce

fbshipit-source-id: d94222607d0198a9dfab7c967ba1371adb3d330e
2018-01-24 19:00:21 -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
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