Replace projectRoots with projectRoot + watchRoots

Summary:
We use projectRoots to limit crawling of jest-haste-map in large codebases. Since this implies multiple projects roots, it makes it very hard (or impossible) to reliably cache dependency resolutions.

If we can replace this with a single project root and a set of watch roots, we can have relative path resolutions for all dependencies which van be cached.

Reviewed By: rafeca

Differential Revision: D8450498

fbshipit-source-id: 830c21e847c3236e42d5414a8587508cb73864bd
This commit is contained in:
Alexey Kureev
2018-06-19 13:45:17 -07:00
committed by Facebook Github Bot
parent d7e0fe2c2c
commit c5ce762697
6 changed files with 23 additions and 16 deletions

View File

@@ -60,6 +60,7 @@ export type Args = {|
+resetCache: boolean,
+sourceExts: $ReadOnlyArray<string>,
+verbose: boolean,
+watchFolders: $ReadOnlyArray<string>,
|};
function runServer(
@@ -100,7 +101,7 @@ function runServer(
.use(indexPageMiddleware)
.use(packagerServer.processRequest.bind(packagerServer));
args.projectRoots.forEach(root => app.use(serveStatic(root)));
args.watchFolders.forEach(root => app.use(serveStatic(root)));
app.use(morgan('combined')).use(errorhandler());
@@ -196,7 +197,7 @@ function getPackagerServer(args, config, reporter) {
polyfillModuleNames: config.getPolyfillModuleNames(),
postMinifyProcess: config.postMinifyProcess,
postProcessBundleSourcemap: config.postProcessBundleSourcemap,
projectRoots: args.projectRoots,
projectRoot: config.getProjectRoot(),
providesModuleNodeModules: providesModuleNodeModules,
reporter,
resetCache: args.resetCache,
@@ -205,6 +206,7 @@ function getPackagerServer(args, config, reporter) {
transformModulePath: transformModulePath,
verbose: args.verbose,
watch: !args.nonPersistent,
watchFolders: config.getWatchFolders(),
workerPath: config.getWorkerPath(),
});
}