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
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
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
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
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