mirror of https://github.com/status-im/metro.git
🚇 The JavaScript bundler for React Native.
https://facebook.github.io/metro
3731fa7c3c
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 |
||
---|---|---|
.github | ||
flow-typed | ||
packages/metro-bundler | ||
scripts | ||
.babelrc | ||
.eslintignore | ||
.eslintrc | ||
.flowconfig | ||
.gitignore | ||
.npmignore | ||
.travis.yml | ||
CHANGELOG.md | ||
CONTRIBUTING.md | ||
LICENSE | ||
PATENTS | ||
README.md | ||
appveyor.yml | ||
circle.yml | ||
lerna.json | ||
package.json | ||
yarn.lock |
README.md
metro-bundler
🚇 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.