Skip to content

Commit 387d487

Browse files
rozelefacebook-github-bot
authored andcommitted
Pass resetCache option to jest-haste-map (#223)
Summary: When the `resetCache` option is set on the bundler, it should also be passed to the `DependencyGraph` and `jest-haste-map` to clean up any cached files there. <!-- 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? --> While trying to get `react-native-windows` working against the `[email protected]` RC, I ran into a series of issues because the `jest-haste-map` cache was not cleaned up when the `--reset-cache` flag was set on the `react-native` CLI. Not only was the option not being passed to `metro` (see facebook/react-native#20706), but `metro` was not passing the `resetCache` option to the `DependencyGraph` and `jest-haste-map`. **Test plan** <!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI. --> 1. yarn test 2. Validated in `react-native-windows`, where the problem was occurring. I had a case where if my `hasteImpl` implementation from `metro.config.js` had a bug. Even after fixing the bug, the `jest-haste-map` was cached with missing haste modules. Only after deleting that file could I get back to a state where the fixed `metro.config.js` would work. After making this change, using `--reset-cache` from the `react-native` CLI could clear the haste map cache. Pull Request resolved: #223 Differential Revision: D9377632 Pulled By: rafeca fbshipit-source-id: e67b5eeb84937daedc7e9f7b5a7d93e11e0d7edb
1 parent f496be3 commit 387d487

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

packages/metro/src/Bundler.js

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class Bundler {
7878
projectRoot: opts.projectRoot,
7979
providesModuleNodeModules: opts.resolver.providesModuleNodeModules,
8080
reporter: opts.reporter,
81+
resetCache: opts.resetCache,
8182
resolveRequest: opts.resolver.resolveRequest,
8283
sourceExts: opts.resolver.sourceExts,
8384
useWatchman: opts.resolver.useWatchman,

packages/metro/src/node-haste/DependencyGraph.js

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ type Options = {|
4545
+projectRoot: string,
4646
+providesModuleNodeModules: Array<string>,
4747
+reporter: Reporter,
48+
+resetCache: boolean,
4849
+resolveRequest: ?CustomResolver,
4950
+sourceExts: Array<string>,
5051
+useWatchman: boolean,
@@ -104,6 +105,7 @@ class DependencyGraph extends EventEmitter {
104105
platforms: Array.from(opts.platforms),
105106
providesModuleNodeModules: opts.providesModuleNodeModules,
106107
retainAllFiles: true,
108+
resetCache: opts.resetCache,
107109
roots: opts.watchFolders,
108110
throwOnModuleCollision: true,
109111
useWatchman: opts.useWatchman,

0 commit comments

Comments
 (0)