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
2017-11-30 11:56:25 +00:00
2017-12-05 11:29:42 -08:00
2017-12-20 14:29:01 -08:00
2017-11-30 11:56:25 +00:00
2017-06-26 05:08:50 -07:00
2017-01-26 12:56:40 +00:00
2017-11-30 11:56:25 +00:00
2017-01-26 12:56:40 +00:00
2017-01-26 12:56:40 +00:00
2017-01-26 12:56:40 +00:00
2017-11-30 11:56:25 +00:00
2017-11-22 02:58:16 -08:00
2017-11-30 11:56:25 +00:00
2017-12-20 19:31:01 -08:00
2017-11-30 11:56:25 +00:00
2017-12-18 05:20:08 -08:00
2017-11-30 11:56:25 +00:00
2017-11-30 11:56:25 +00:00
2017-12-18 05:20:08 -08:00

Metro Bundler

CircleCI Build Status npm version

🚇 The JavaScript bundler for React Native.

  • 🚅 Fast: We aim for sub-second reload cycles, fast startup and quick bundling speeds.
  • ⚖️ Scalable: Works with thousands of modules in a single application.
  • ⚛️ Integrated: Supports every React Native project out of the box.

This project was previously part of the react-native repository. In this smaller repository it is easier for the team working on Metro Bundler to respond to both issues and pull requests. See react-native#13976 for the initial announcement.

Installation & Documentation

See the Metro website for documentation.

Description
🚇 The JavaScript bundler for React Native.
https://facebook.github.io/metro
Readme MIT
Languages
JavaScript 100%