🚇 The JavaScript bundler for React Native. https://facebook.github.io/metro
Go to file
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
.github Initial repository structure. 2017-01-26 12:56:40 +00:00
flow-typed Backed out changeset db8638eebe2d 2017-06-14 09:53:06 -07:00
packages/metro-bundler TransformCaching: fix GC condition judgement error 2017-08-29 08:27:24 -07:00
scripts fix support for node v4 2017-06-26 05:08:50 -07:00
.babelrc fix support for node v4 2017-06-26 05:08:50 -07:00
.eslintignore Initial repository structure. 2017-01-26 12:56:40 +00:00
.eslintrc Add prettier to metro-bundler, fixing code styling issues 2017-06-12 01:20:50 -07:00
.flowconfig Don’t ignore `/build/` in `node_modules` 2017-06-09 09:56:52 -07:00
.gitignore Add nested yarn.lock 2017-06-12 18:07:19 +01:00
.npmignore Initial repository structure. 2017-01-26 12:56:40 +00:00
.travis.yml Initial repository structure. 2017-01-26 12:56:40 +00:00
CHANGELOG.md Initial repository structure. 2017-01-26 12:56:40 +00:00
CONTRIBUTING.md Initial repository structure. 2017-01-26 12:56:40 +00:00
LICENSE Initial repository structure. 2017-01-26 12:56:40 +00:00
PATENTS Initial repository structure. 2017-01-26 12:56:40 +00:00
README.md Update README 2017-06-06 03:29:08 -07:00
appveyor.yml Initial repository structure. 2017-01-26 12:56:40 +00:00
circle.yml Revert "attempt at fixing yarn install in CircleCI" 2017-07-19 17:31:28 +01:00
lerna.json metro-bundler: 0.11.0 2017-07-27 11:51:18 -07:00
package.json Update to eslint-plugin-react@7.2.1 2017-08-18 09:32:10 -07:00
yarn.lock Upgrade to babylon@6.18.0 2017-08-18 11:21:41 -07:00

README.md

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.