Commit Graph

531 Commits

Author SHA1 Message Date
Jean Lauliac 3b6fddc746 RN buck: move asset work into transform worker
Reviewed By: davidaurelio

Differential Revision: D5872268

fbshipit-source-id: 829a0d26930f8893b93a5f42ef7026350dc01f29
2017-09-22 07:25:03 -07:00
Rafael Oleza e736518c43 Remove unneeded params from `getTransformOptions()`
Reviewed By: jeanlauliac

Differential Revision: D5880687

fbshipit-source-id: ef9683b1272133a9b38005cb8ba43d80b9ac6ec8
2017-09-21 09:27:05 -07:00
Sina Sabet f700c9e54d Removing unnecessary eslint enable/disable comments (round 2)
Reviewed By: TheSavior

Differential Revision: D5865725

fbshipit-source-id: 92d5e4376956a05c23aeeb84a4996626d82e0fb6
2017-09-20 23:39:49 -07:00
Jean Lauliac 39238acb78 RN: add some test to module system
Reviewed By: davidaurelio

Differential Revision: D5862757

fbshipit-source-id: cf5c88c4bb9d65368df07f6e85b207c90565bad9
2017-09-20 11:05:49 -07:00
Jean Lauliac 7d92dd2b5d RN buck: fix Flow error
Reviewed By: davidaurelio

Differential Revision: D5871509

fbshipit-source-id: 91bd020b95d33a854b5649daea1a0b8d7782706d
2017-09-20 09:22:56 -07:00
Lee Byron 9f4ca4a541 Synchronize all relay packages
Reviewed By: mjmahone

Differential Revision: D5842774

fbshipit-source-id: 40c57619901e15b0baa62c59837fc887c100652b
2017-09-19 22:56:43 -07:00
Ian Levesque 522a0460a1 Revert D5841425: Removing unnecessary eslint enable/disable comments
Differential Revision: D5841425

fbshipit-source-id: 5a5bb73eafce9e09c89fe9f0cf57676cfc962a5a
2017-09-19 13:26:30 -07:00
Sina Sabet 114b00ee34 Removing unnecessary eslint enable/disable comments
Reviewed By: TheSavior

Differential Revision: D5841425

fbshipit-source-id: cf30e47e0a544230595b8298c6bca67cbee2fb08
2017-09-19 12:52:15 -07:00
David Aurelio ad927b93dc Upgrade uglify to v3 + es support
Summary: Upgrades uglify to version 3 with (experimental) ES6 support turned on.

Reviewed By: jeanlauliac

Differential Revision: D5842410

fbshipit-source-id: 1c8ccea15785bc5bb1c68d7a83b75881432d0ce2
2017-09-19 12:23:53 -07:00
David Aurelio 025e1841d9 Get rid of `async/queue`
Summary:
This replaces `async/queue` with a hand-rolled queue that does not yield to the event loop if a unit of work can be run synchronously.

Anecdotally, this leads to a > 11x speedup for the graph traversal when all data is available synchronously, e.g. from an in-memory cache.

Reviewed By: jeanlauliac

Differential Revision: D5861763

fbshipit-source-id: f7cf5f916a13adf9ca418d7522cd2f19df596fba
2017-09-19 09:21:40 -07:00
David Aurelio c546349da4 `GraphFn` returns promise rather than taking callback
Summary: Changes `GraphFn` to return a promise rather than taking a callback. This is more in line with call sites, which so far have been using `denodeify`.

Reviewed By: jeanlauliac

Differential Revision: D5857192

fbshipit-source-id: 61bbbef4fbf24b0b91c4a3008541eaa5a1af0f7a
2017-09-19 09:21:40 -07:00
David Aurelio 5aaf148179 `@format` for `Graph-test.js`
Reviewed By: jeanlauliac

Differential Revision: D5857069

fbshipit-source-id: 38e58f11579161a94d5201d016cf8b0ba3681eb4
2017-09-19 09:21:37 -07:00
David Aurelio 6062a9bd34 `LoadFn`/`ResolveFn` without callbacks
Summary:
Changes `LoadFn` to be synchronous or return a promise, and `ResolveFn` to be synchronsous.

This makes for a nicer API, without losing the property of not yielding to the event loop for synchronous work.

Reviewed By: jeanlauliac

Differential Revision: D5855963

fbshipit-source-id: 4b3c3363f4e49a9890586462925e8e400872feb2
2017-09-19 09:21:32 -07:00
David Aurelio 3f2b200e01 Fix creation of indexed RAM bundles
Reviewed By: jeanlauliac

Differential Revision: D5852737

fbshipit-source-id: 98e16fbd69d9ad3666acfc86e5de308175102643
2017-09-18 11:08:44 -07:00
Rafael Oleza f6e2e17900 HMR: Include updated modules in the correct order
Reviewed By: davidaurelio

Differential Revision: D5852269

fbshipit-source-id: 519564a4899b22d16a2ab3be4b466e21783e8f86
2017-09-18 09:06:43 -07:00
Jean Lauliac a7ad7502aa RN buck: ModuleGraph: get rid of callbacks, async/await for the best
Reviewed By: davidaurelio

Differential Revision: D5842855

fbshipit-source-id: 71f9e799db4ad312213a20c1b1a93280e934d1e7
2017-09-18 04:21:14 -07:00
Rafael Oleza 539885386a Remove unneeded await in sync method
Reviewed By: cpojer

Differential Revision: D5851184

fbshipit-source-id: 4a6f5cbd9d1237843c349b5944bd17767f84f625
2017-09-18 03:53:19 -07:00
Rafael Oleza 77f6ac080d Handle renames/deletes of modules correctly
Reviewed By: cpojer

Differential Revision: D5845030

fbshipit-source-id: a33af56bf5a479768eaf64b42ec3251a724c0315
2017-09-16 09:07:40 -07:00
Rafael Oleza f9526cf486 Fix issue when there is transform errors
Reviewed By: mjesun

Differential Revision: D5843842

fbshipit-source-id: a9c5efde86248a5e4b188012360d8830d2049985
2017-09-15 17:24:56 -07:00
David Aurelio d56cef3493 Don’t use unnecessary transforms for node 8
Summary: When running with node 8, the babel plugins `async-to-generator` and `syntax-trailing-function-commas` are unnecessary. Removing them makes runtime transpilation faster, and the resulting code is closer to the original (useful with debugging: less unmapped code areas, better breakpoint support, less renamed variables).

Reviewed By: mjesun

Differential Revision: D5842305

fbshipit-source-id: d99f719794e4a8f48fd10b0349fbb36f2994666e
2017-09-15 12:06:42 -07:00
Christoph Nakazawa 2a64bd390e Use the Config type from Metro
Reviewed By: davidaurelio

Differential Revision: D5832633

fbshipit-source-id: 8e4e0e6a2907e485a5627c87161af2d0672b4f56
2017-09-15 05:10:08 -07:00
Christoph Nakazawa 34b1fb6abf Add Config object and loading mechanism
Summary:
This copies the basic loading mechanism and default config from the RN local cli into Metro and exposes it under `metro-bundler`, and switches internal scripts over to it.

davidaurelio: I changed the packager-worker-for-buck to hardcode the rn.cli file, like we do in other files. I would like to pull the "find" mechanism that traverses up to find a config into Metro at some point, but for now I'd prefer to keep it lean until we need it. Let me know if that doesn't work for you.

The next diff will switch the RN cli over to these functions also.

Reviewed By: davidaurelio

Differential Revision: D5832596

fbshipit-source-id: a3e167644d96c8831e5a83378e8ba143e62426db
2017-09-15 01:39:30 -07:00
Christoph Nakazawa 37a7a3b018 Add ConfigT type
Summary: As a first step in defining a new public API and CLI for Metro, I'd like to pull the generally useful pieces from the RN cli into Metro. This diff makes it as a non-breaking change (so we don't have to bump the version of Metro for RN) by updating only the imports outside of the react-native-github folder.

Reviewed By: davidaurelio

Differential Revision: D5832464

fbshipit-source-id: 11b00b5517665441763c2207d577ae0e110c681b
2017-09-15 01:39:30 -07:00
Christoph Nakazawa 80a3306448 Bump metro-bundler dependency to 0.17
Reviewed By: davidaurelio

Differential Revision: D5834180

fbshipit-source-id: 121efc7000bff7aff121d44e6b0b8eed1d4e81ae
2017-09-14 22:09:13 -07:00
Alexander Gugel db7ea0b5f7 Add hook for accessing aggregated resolution cache
Reviewed By: mjesun

Differential Revision: D5775425

fbshipit-source-id: 9e1855d9a161f60d7163a208c5539264ba67d3fd
2017-09-14 18:53:57 -07:00
Rafael Oleza 300cd924e0 Add logging for HMR changes
Reviewed By: davidaurelio

Differential Revision: D5833673

fbshipit-source-id: 5cfc9e7de6b761130093f785f2f9b829093571d0
2017-09-14 16:43:53 -07:00
Rafael Oleza bfa19e9db0 Do not include polyfills in the inlineRequiresBlacklistFiles transform option
Reviewed By: davidaurelio

Differential Revision: D5834728

fbshipit-source-id: 7c531b2464fb0bda50fdfa527112313060f11a0c
2017-09-14 14:08:34 -07:00
Rafael Oleza 4f31807cf8 Add multipart response functionality to the full bundler created by Delta Bunlder
Reviewed By: jeanlauliac

Differential Revision: D5825701

fbshipit-source-id: 481d36420396e2fcb457397905c69fb5720f43b2
2017-09-14 10:21:12 -07:00
Rafael Oleza 61fb142520 Bump babel-preset-react-native dependency in metro bundler
Reviewed By: jeanlauliac

Differential Revision: D5833281

fbshipit-source-id: 42a62e71b77467973d15d60419a33c310082d015
2017-09-14 09:05:52 -07:00
Rafael Oleza 9294f5a46a Multiple requests to the Delta Bundler when there is an error should produce an Error
Reviewed By: jeanlauliac

Differential Revision: D5814215

fbshipit-source-id: 9a72057078819d07ddbd5d4f949d7bdf13aff29e
2017-09-14 08:25:36 -07:00
David Aurelio 3401cfe768 disable all dev settings for base transform
Reviewed By: fkgozali

Differential Revision: D5824578

fbshipit-source-id: 7503700b82dc2b4de4c2d941829ba837ddcd5f3c
2017-09-13 16:53:45 -07:00
Rafael Oleza 0a1e79a820 Replace the ETag header by the Last-Modified to improve performance
Reviewed By: mjesun

Differential Revision: D5823545

fbshipit-source-id: 57eac5548e626eeed05f9b454e3f54b114193eb0
2017-09-13 13:08:05 -07:00
Rafael Oleza b64a07e38b Make DeltaBundler HMR handle errors correctly
Reviewed By: jeanlauliac

Differential Revision: D5814107

fbshipit-source-id: 2bcc52901eff5f2330453c7dc948a0b4ac0332db
2017-09-13 10:12:55 -07:00
Christoph Nakazawa 5422f802f5 Use hasteImpl in the Buck worker
Reviewed By: davidaurelio

Differential Revision: D5803422

fbshipit-source-id: de3aa40ab8ea9ec54e61173b3d6556351394089f
2017-09-13 00:09:09 -07:00
Kevin Gozali 8654b558ca fix output path for the UNBUNDLE magic file
Summary: Fixed the UNBUNDLE magic file location to match what JniJSModulesUnbundle.cpp expects.

Reviewed By: sahrens

Differential Revision: D5821637

fbshipit-source-id: 4342e4bb4d139b4eba77dd92a53b1683041fc7e9
2017-09-12 22:43:13 -07:00
Rafael Oleza 449e943d91 Add 'bundler' column to metro bundler logs
Reviewed By: davidaurelio

Differential Revision: D5809350

fbshipit-source-id: 7e1b9dcda26f3c199ff1723e21c670659d9cf747
2017-09-12 09:11:14 -07:00
Miguel Jimenez Esun 090df5c104 Make cache method public
Reviewed By: jeanlauliac

Differential Revision: D5804391

fbshipit-source-id: 8da732a440111ca5d89d51fa9e4c2727d386bbff
2017-09-12 08:11:29 -07:00
Rafael Oleza 5fa193bdee Move createModuleIdFactory() to a separate module
Reviewed By: jeanlauliac

Differential Revision: D5813714

fbshipit-source-id: 17ae2cf1751d30f6f18bb896576747871b8a0b68
2017-09-12 08:11:29 -07:00
Rafael Oleza bd51bc3c2f Use getModuleForPath() method from Resolver instead of Bundler
Reviewed By: davidaurelio

Differential Revision: D5813534

fbshipit-source-id: dbd005c2f9b478be58f33bd30df16e94159509da
2017-09-12 07:11:30 -07:00
Christoph Nakazawa d9ff4fa1dc Apply @format to root level files
Reviewed By: davidaurelio

Differential Revision: D5803464

fbshipit-source-id: e250a3ada33790b989f1e70990438c300bfb6d52
2017-09-12 01:06:05 -07:00
Rafael Oleza c51161d209 Fix issue calculating dependencyPairs when adding a new dependency
Reviewed By: cpojer

Differential Revision: D5812028

fbshipit-source-id: ced2cb19e87b3622d16f4c59d58d6711ce5161df
2017-09-12 01:06:05 -07:00
Christoph Nakazawa b3e817285b Remove HasteMap
Reviewed By: davidaurelio

Differential Revision: D5803275

fbshipit-source-id: 2e64733d8ef400a61d116b21cd53185934dd3d57
2017-09-11 23:54:09 -07:00
Christoph Nakazawa 61a0116dd4 Prevent logspew in symbolication worker-test
Reviewed By: mjesun

Differential Revision: D5803050

fbshipit-source-id: b585d073191ae521e8bc8cabb90a15d2a176d6da
2017-09-11 19:44:11 -07:00
Christoph Nakazawa 92fa17f70e Fix DependencyGraph-test log-spew
Reviewed By: mjesun

Differential Revision: D5803016

fbshipit-source-id: fc94590331fb77796cb5d2bbc96f963b7b5f8c7c
2017-09-11 19:44:11 -07:00
Christoph Nakazawa 86a943bbcd Branding: "packager" -> "Metro Bundler"
Summary:
This diff renames all the stragglers in comments and strings from variations of "packager" to "Metro Bundler". I did one of three:

* Rename "packager" to "Metro Bundler"
* Rename "react-native-packager" to "Metro Bundler"
* Remove "packager" when code inside of Metro implies that it's about Metro

I also removed `Glossary.md` because it is unmaintained and very old. mjesun is currently starting to write documentation for Metro which will supersede whatever was there before.

Reviewed By: mjesun

Differential Revision: D5802993

fbshipit-source-id: ba99cb5ed04d84b0f7b7a8a0bf28ed99280a940a
2017-09-11 19:44:11 -07:00
Rafael Oleza 8e2252d35d Implement end() method in DeltaBundler
Reviewed By: jeanlauliac

Differential Revision: D5803466

fbshipit-source-id: 78a29cd943774506694513987d97d9f37be04485
2017-09-11 08:27:56 -07:00
Rafael Oleza 197d885ec1 Add X-Metro-Files-Changed-Count HTTP header to the response when using Delta Bundler
Reviewed By: mjesun

Differential Revision: D5793977

fbshipit-source-id: 9e0783356ca7574077d4eb06489e9837f033d986
2017-09-11 08:27:56 -07:00
Rafael Oleza bf64ba58d3 Integrate the Source Map generator from Delta Bundler into the metro server
Reviewed By: mjesun

Differential Revision: D5793423

fbshipit-source-id: a26b6d67405d6ec0d59479cfe5091159a29018d1
2017-09-11 08:27:56 -07:00
Rafael Oleza e57e0002d1 Add Source Maps support to Delta Bundler
Reviewed By: jeanlauliac

Differential Revision: D5793499

fbshipit-source-id: 67e49ed5f5bc9ccae2fb4982cd506fc03259589a
2017-09-11 08:27:56 -07:00
Rafael Oleza dcf30322a5 Do not minify a bundle when calling wrapModule()
Reviewed By: jeanlauliac

Differential Revision: D5791079

fbshipit-source-id: 942d2963e17153508b4a7c5bd48e11b7cb3fdcd4
2017-09-11 08:27:56 -07:00
Rafael Oleza 2593ea2ad4 Make the sourcemaps generation module independent of ModuleTransport
Reviewed By: jeanlauliac

Differential Revision: D5789998

fbshipit-source-id: a460ccb0baa62d0edb4e0da2b6f4d4abaa7fe222
2017-09-11 08:27:56 -07:00
Rafael Oleza 5ee6de217d Disable using babel-generated sourcemaps from the metro bundler server
Reviewed By: jeanlauliac

Differential Revision: D5785354

fbshipit-source-id: be1a5c114b12af356804ff3b4ed6c4263d66fa0c
2017-09-11 08:27:56 -07:00
Jean Lauliac 36b2f8d67f RN packager: wrap-worker-fn.js: syncify
Reviewed By: davidaurelio

Differential Revision: D5803796

fbshipit-source-id: d6b7d169a2c17864e8ce68d82df8e898d966e404
2017-09-11 07:41:44 -07:00
Jean Lauliac 69eb3430b6 RN packager: transform-module.js: syncify everything
Reviewed By: davidaurelio

Differential Revision: D5803768

fbshipit-source-id: 06c28e6c30fce347780d953312646a449d0026d9
2017-09-11 07:41:44 -07:00
Jean Lauliac 7ccbcc5ebc metro-bundler: fix Flow errors in OSS
Reviewed By: cpojer

Differential Revision: D5775151

fbshipit-source-id: 730ab160fdf5ea35f8047eb55a7e2844ba7a7c14
2017-09-08 06:39:36 -07:00
Rafael Oleza 286c5ccdd9 Bump metro-bundler to 0.16.0
Reviewed By: davidaurelio

Differential Revision: D5793558

fbshipit-source-id: c5d7f3029b889987613034150ba13a72b4850421
2017-09-08 06:23:47 -07:00
Jean Lauliac 890de8436f xplat/js: switch to new oncall javascript_foundation
Reviewed By: cpojer

Differential Revision: D5774897

fbshipit-source-id: 6b3246aeda9fe3bee89065ed2ac244282e496373
2017-09-08 03:39:34 -07:00
Rafael Oleza 177c4fb1ab Do not bundle deleted modules in HMR
Reviewed By: mjesun

Differential Revision: D5777831

fbshipit-source-id: dd3551194eca99097cea5a1944555cd8adff9f19
2017-09-07 10:21:19 -07:00
Marshall Roch 14428a67e5 @allow-large-files Flow v0.54.0
Reviewed By: leebyron

Differential Revision: D5773490

fbshipit-source-id: 2c54bb6326f23edbe9a969f3010f79da8189923e
2017-09-06 03:31:10 -07:00
Jean Lauliac a94654255b packager-worker-for-buck: include all entries point for getting extra configuration
Reviewed By: davidaurelio

Differential Revision: D5764794

fbshipit-source-id: a9bddd05a66c1d5a45f5dd4d04517dbe86ea5b76
2017-09-05 10:54:17 -07:00
Rafael Oleza 0265758e5e Create brand-new HMR server using the Delta Bundler
Reviewed By: mjesun

Differential Revision: D5765024

fbshipit-source-id: 3f51ab1564a93b8268e51c0a0a97ea3ef5bd6681
2017-09-05 07:21:06 -07:00
Rafael Oleza 387a55de40 Make the DeltaCalculator and the DeltaTransformer emit change events
Reviewed By: jeanlauliac

Differential Revision: D5765042

fbshipit-source-id: 5b45cc425b6afb4f8cead80ce967263936baa8c1
2017-09-05 07:21:06 -07:00
Rafael Oleza 8b6d69b645 Return the inverseDependencies from the Delta Bundler to support HMR
Reviewed By: jeanlauliac

Differential Revision: D5763905

fbshipit-source-id: 6b95c8dfded5fc30ec2e7a558ab25550d9a1c333
2017-09-05 07:21:06 -07:00
Miguel Jimenez Esun d4a93eb2fa Update Jest to v21
Reviewed By: cpojer

Differential Revision: D5765333

fbshipit-source-id: 94ea448c4380fdc68f42f84eb3963322ea18ec70
2017-09-05 05:25:02 -07:00
Rafael Oleza 1f90522a13 Upgrade metro-bunder to v0.15.0
Summary: Some breaking changes require a new release.

Reviewed By: cpojer

Differential Revision: D5766207

fbshipit-source-id: d0ebc5cb46fbd2ad167c0a3369d0f354346f61b9
2017-09-05 05:25:02 -07:00
Rafael Oleza e18d4e1b89 Enable delta bundler on metro-bundler behind a cli argument
Reviewed By: mjesun

Differential Revision: D5761110

fbshipit-source-id: 83127f63679caffbc4f335f52f6f5eda398e8c05
2017-09-04 13:53:55 -07:00
Rafael Oleza 7b17ca335d Add DeltaPatcher module to handle Delta bundles
Reviewed By: jeanlauliac

Differential Revision: D5761096

fbshipit-source-id: 8c8ef5fb720b08e3f4f097c5a76f793dc4f1c1da
2017-09-04 13:53:55 -07:00
Rafael Oleza 52fcaf4a10 Delta Bundler: Initial implementation of the Delta Bundler
Reviewed By: jeanlauliac

Differential Revision: D5760233

fbshipit-source-id: 5f829d48401889b1391719564119951a1cf3c792
2017-09-04 13:53:55 -07:00
Rafael Oleza 8c8cfb364f Expose some private methods from the Bundler and the DependencyGraph
Reviewed By: jeanlauliac

Differential Revision: D5755556

fbshipit-source-id: cff95e3464154883fd872bf8ab916276a1f09027
2017-09-04 13:53:55 -07:00
Rafael Oleza 70a0916dd2 Change signature of Resolver.wrapModule() to not depend on ResolutionResponse
Reviewed By: mjesun

Differential Revision: D5757102

fbshipit-source-id: 1cb514612ec431e48d669607c5332f26d19f53a0
2017-09-04 13:53:55 -07:00
Rafael Oleza ebb14a56c6 Add prependPolyfills option param to getDependencies()
Reviewed By: jeanlauliac

Differential Revision: D5755548

fbshipit-source-id: 599d3fb6d9acb34f5970ad83947daeb5f28f86d3
2017-09-04 13:53:55 -07:00
Rafael Oleza 9c251076cf Fix sourceMap flow annotations by making them nullable
Reviewed By: mjesun

Differential Revision: D5755671

fbshipit-source-id: 19be8475b1f1b54bc55b64a1de4b8a446e125c65
2017-09-04 13:53:55 -07:00
Miguel Jimenez Esun 2377f04f4a Always report filename
Reviewed By: cpojer

Differential Revision: D5764824

fbshipit-source-id: cb90e429176764d4a1043fd57bbfee223361a182
2017-09-04 13:53:55 -07:00
Jean Lauliac 6e415bcb2f metro-bunder: v0.14.0
Summary: Some breaking changes require a new release.

Reviewed By: cpojer

Differential Revision: D5763898

fbshipit-source-id: 0580c9b1256c2c019adc5fb2f771c54d7e7a0bf1
2017-09-04 04:42:16 -07:00
Rafael Oleza 717a8c7f61 Improve HMR performance by allowing to specify bundlingOptions to getShallowDependencies() method
Reviewed By: jeanlauliac

Differential Revision: D5745205

fbshipit-source-id: a69ac40bb676a809e3786681179e2b4bac392ce6
2017-09-01 08:51:22 -07:00
Jean Lauliac 8907de28ac metro-bundler: v0.13
Reviewed By: cpojer

Differential Revision: D5754623

fbshipit-source-id: b70bfa105e6752db5350b82433bd64e1ca45f33b
2017-09-01 07:36:11 -07:00
Jean Lauliac 1142f05d59 metro-bundler: v0.12
Reviewed By: cpojer

Differential Revision: D5745702

fbshipit-source-id: 6dc88811525e1595f58b23b7d0ebd5cc9f309785
2017-08-31 10:52:51 -07:00
Jean Lauliac 1c6a96f2b3 metro-bundler: ModuleGraph/output: @format
Reviewed By: cpojer

Differential Revision: D5745469

fbshipit-source-id: 7aa923736d6eb257f547a6d41b4329ce3406c805
2017-08-31 07:24:33 -07:00
Miguel Jimenez Esun 9254941133 Treat package.json's first
Reviewed By: fkgozali

Differential Revision: D5736600

fbshipit-source-id: f2947d4b1fb057ea33dd84e3c8cd878d5bfeda49
2017-08-30 12:08:48 -07:00
Rafael Oleza 909480887e Fix flow types of getShallowDependencies()
Reviewed By: mjesun

Differential Revision: D5735278

fbshipit-source-id: b9a2797a89a3893a5196ef8fe15d2ab8aa00e544
2017-08-30 08:20:38 -07:00
Rafael Oleza 21cc11c5ae Only include hmr transforms when in dev mode
Reviewed By: arcanis

Differential Revision: D5732348

fbshipit-source-id: cc70d3ee6531f1f8345d6a04827ca802382525d8
2017-08-30 03:54:59 -07:00
Miguel Jimenez Esun 84ae805e78 Make metro-bundler use a no-op transformer by default
Summary: When starting to use `metro-bundler` as a standalone server, I found quite complicated the fact that it needs a transformer by default. Moreover, the transformer is not passed as a reference to a JS object, but as a path to a required file. I removed the need to be required, and defaulted to a dummy, basic transform, that does nothing by default. This avoids having to create an extra file and linking to it (potentially needing to involve `path` and other extra modules).

Reviewed By: cpojer

Differential Revision: D5622906

fbshipit-source-id: 0c2b1bec86fa542b3c05de42c89d4b5bb4384b34
2017-08-29 09:42:50 -07:00
yeyuanfeng 3731fa7c3c TransformCaching: fix GC condition judgement error
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? -->
I am sending this PR to fix an error in TransformCaching module. See this issue [TransformCaching module try to collect cache every time I build bundle #46](https://github.com/facebook/metro-bundler/issues/46).

**Test plan**

<!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI. -->
```
/**
   * When restarting packager we want to avoid running the collection over
   * again, so we store the last collection time in a file and we check that
   * first.
   */
  _collectCacheIfOldSync() {
    const {_rootPath} = this;
    const cacheCollectionFilePath = path.join(_rootPath, 'last_collected');
    const lastCollected = Number.parseInt(
      tryReadFileSync(cacheCollectionFilePath) || '',
      10,
    );
    if (
      Number.isInteger(lastCollected) &&
      Date.now() - lastCollected < GARBAGE_COLLECTION_PERIOD
    ) {
      return;
    }
    const effectiveCacheDirPath = path.join(_rootPath, CACHE_SUB_DIR);
    mkdirp.sync(effectiveCacheDirPath);
    collectCacheSync(effectiveCacheDirPath);
    fs.writeFileSync(cacheCollectionFilePath, Date.now().toString());
  }
```
Steps:
1. Create a new react-native project.
2. Put your breakpoint at this sentence `collectCacheSync(effectiveCacheDirPath);`.
3. Bundle the project, program will break at `collectCacheSync(effectiveCacheDirPath);`
4. Resume the program, finish the first time bundle.
5. Bundle again, this time program won't break.
Closes https://github.com/facebook/metro-bundler/pull/48

Differential Revision: D5726161

Pulled By: jeanlauliac

fbshipit-source-id: 0865f1bf25d6eb36f067ac3dc7764df9fd5026dc
2017-08-29 08:27:24 -07:00
Rafael Oleza 50ef3138cf Metro HMR: Add file parameter to getShallowDependencies()
Reviewed By: jeanlauliac

Differential Revision: D5687991

fbshipit-source-id: c2db3986c6a5ec81ed1350ded92dfcf1b529c2bc
2017-08-24 08:20:34 -07:00
Rafael Oleza 679309987b Fix HMR when adding/renaming assets
Summary:
The HMR logic used to try to calculate the dependencies of every new added (or modified) file, including assets. This resulted in a TransformError.

This commit adds a check that stops the HMR bundling once it finds out that the updated file is an asset

Reviewed By: cpojer

Differential Revision: D5697391

fbshipit-source-id: faf7ccad76ac4922b70ed1c7ce8ce32b03c4e8ee
2017-08-24 07:40:35 -07:00
Miguel Jimenez Esun b2331471d5 Remove the timeout
Summary: We were not using the timeout at all, so we decided to remove it. Also, the current value is pretty high, so it should never fail unless there's something really bad.

Reviewed By: jeanlauliac

Differential Revision: D5640839

fbshipit-source-id: 3eaa567a6828902376fe5df9fe3f4e96b83a23bd
2017-08-23 07:50:36 -07:00
Jean Lauliac 87aa1cc166 worker-farm: add @format
Reviewed By: davidaurelio

Differential Revision: D5658177

fbshipit-source-id: 59565a57243c6f8ce0d9aceaad5dc542992cd45b
2017-08-21 04:50:46 -07:00
Jean Lauliac bf25e49665 metro-bundler: collect-dependencies: harden requirements for require()
Reviewed By: davidaurelio

Differential Revision: D5658522

fbshipit-source-id: 2970d62bcb18d57595c666d680407a23eccda77b
2017-08-21 04:35:59 -07:00
Jean Lauliac 6a0efc0853 metro-bundler: ModuleGraph worker: @format
Reviewed By: davidaurelio

Differential Revision: D5658384

fbshipit-source-id: 918017a117e5fb574b3f6801104b4db2708a0eff
2017-08-21 04:35:59 -07:00
Ben Nham 72455941ba add number of files changed to bundle response
Reviewed By: davidaurelio

Differential Revision: D5650181

fbshipit-source-id: 16c7842a79bec6cf4fb5bfeffc4bc8a835c7ce83
2017-08-21 04:06:22 -07:00
Andres Suarez 6d4b8e0c8d Upgrade to babylon@6.18.0
Reviewed By: davidaurelio

Differential Revision: D5652526

fbshipit-source-id: 4e1f217c924b9eee33e9f9eae447962617af7e22
2017-08-18 11:21:41 -07:00
Alex Dvornikov 5cd43a675b Default to "compact: false" in the code generate phase
Reviewed By: davidaurelio

Differential Revision: D5630578

fbshipit-source-id: 5049be735f41f1207b8ca329f4a78fc92f683c23
2017-08-18 05:05:43 -07:00
Jean Lauliac 936b8c31e7 metro-bundler: elaborate the global cache test a bit
Reviewed By: davidaurelio

Differential Revision: D5650882

fbshipit-source-id: b1f283f00e6e200f3b731126ed7a273fe782aeaa
2017-08-18 04:13:53 -07:00
Jean Lauliac 55986976b1 metro-bundler: temporary increase of the transform timeout
Summary:
We'll revert when the root problem is fixed, that should mitigate for now.

What might be the root problem, I believe, is that when there are some cached files already on the machine, we immediately try to build all the dependencies, but the worker farm is queuing these and it takes a long time to finish. The timeout should include only the transformation time, not the queuing. I'll fix that separately.

Reviewed By: mjesun

Differential Revision: D5650380

fbshipit-source-id: f4b045876cc822caee3998f69ca98ea986709bf4
2017-08-17 11:36:12 -07:00
Jean Lauliac c6794aabd9 metro-bundler: extract calls to require.async()
Reviewed By: davidaurelio

Differential Revision: D5639493

fbshipit-source-id: d74aae95a238cf97b7daafad41ce9cbdccc84c1b
2017-08-17 06:41:18 -07:00
Jean Lauliac 66182916de metro-bundler: extract-dependencies: nit fix
Reviewed By: davidaurelio

Differential Revision: D5639285

fbshipit-source-id: 1f163160e72cb8a63c0c23846ad1b6cc3da13602
2017-08-17 06:41:15 -07:00
David Aurelio 35979c7b00 JSTransformer: pass on `--heap-growing-percent`
Reviewed By: jeanlauliac

Differential Revision: D5648906

fbshipit-source-id: 240b3044dd1268cf5f8bb41710647050368ddefb
2017-08-17 05:08:49 -07:00
Miguel Jimenez Esun b3b2d10500 Do not assume we are using processRequest in an express app
Summary: It might be that Metro bundler is getting used directly with the `http` module and not within an express app. If that's the case, the `next` method will not exist, so we have to guard against it.

Reviewed By: davidaurelio

Differential Revision: D5639944

fbshipit-source-id: bcee4a70f6a7b643218b11af0d8aedbc7762eead
2017-08-17 04:42:10 -07:00
Rafael Oleza e4acb91914 Remove hot parameter from HMR url
Summary: This is the last piece of work to make all the clients do a single request for both HMR/non-HMR modes. I'm not completely sure how this URL is used by the client, but it does not need the `hot` param.

Reviewed By: davidaurelio

Differential Revision: D5639946

fbshipit-source-id: a76f9ba7b9ace625352a156761d3ee2809f80c92
2017-08-16 19:12:43 -07:00
Rafael Oleza 409a2ae809 Always use the HMR transforms when building the bundle from the metro-bundler server
Summary:
This diff enables the HMR transforms for any bundle requested through the metro-bundler HTTP server, so it ignores the `hot` parameter passed in the URL.

This allows much faster switches when enabling/disabling HMR, since metro-bundler does not need to re-compile each single file again, while not impacting substantially build times when HMR is off.

I've done some lightweight benchmarks on my machine and these are the results (all the tests have been done after running metro-bundler with a clean cache and restarting the app).

**Before**

Time to build (HMR off): 1x (baseline)
Time to build (HMR on): 1.90x

**This diff**

Time to build (HMR off): 1.009x
Time to build (HMR on): 1.036x

(The reason why now it takes double the time to load the HMR bundle than the non-HMR bundle after launching the app is because the device after a restart always asks for the non-HMR bundle and afterwards the HMR bundle, causing the server to have to build both bundles).

**Bundle size**
In terms of bundle size, adding the HMR transforms increases the size by around 3-4% (this regression is due to the wrappers added around React components, and will depend on the app).

**Next steps**

There are two improvements to do after this diff:

1. Remove the `hot=true` parameter from the clients when they request the bundle. This will reduce by half the memory used by metro-bundler when switching from non-HMR to HMR (or when opening the app with HMR enabled), since metro-bundler caches the bundles based on url.
2. After this diff, the `hot` parameter in the various options objects will not make much sense, so my suggestion is to just remove it from everywhere and instead of checking for that parameter in the transformer, check for `dev=true` there.

Reviewed By: davidaurelio

Differential Revision: D5623623

fbshipit-source-id: cb76b9182e55f442e2987fcf59eee2ba2571578e
2017-08-15 18:44:03 -07:00