Skip to content

Commit

Permalink
Pass resetCache option to jest-haste-map (#223)
Browse files Browse the repository at this point in the history
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 `react-native@0.57` 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
  • Loading branch information
rozele authored and facebook-github-bot committed Aug 17, 2018
1 parent f496be3 commit 387d487
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/metro/src/Bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class Bundler {
projectRoot: opts.projectRoot,
providesModuleNodeModules: opts.resolver.providesModuleNodeModules,
reporter: opts.reporter,
resetCache: opts.resetCache,
resolveRequest: opts.resolver.resolveRequest,
sourceExts: opts.resolver.sourceExts,
useWatchman: opts.resolver.useWatchman,
Expand Down
2 changes: 2 additions & 0 deletions packages/metro/src/node-haste/DependencyGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type Options = {|
+projectRoot: string,
+providesModuleNodeModules: Array<string>,
+reporter: Reporter,
+resetCache: boolean,
+resolveRequest: ?CustomResolver,
+sourceExts: Array<string>,
+useWatchman: boolean,
Expand Down Expand Up @@ -104,6 +105,7 @@ class DependencyGraph extends EventEmitter {
platforms: Array.from(opts.platforms),
providesModuleNodeModules: opts.providesModuleNodeModules,
retainAllFiles: true,
resetCache: opts.resetCache,
roots: opts.watchFolders,
throwOnModuleCollision: true,
useWatchman: opts.useWatchman,
Expand Down

0 comments on commit 387d487

Please sign in to comment.