Skip to content

Commit

Permalink
Infer workspace root only if watchFolders are not explicitly specified
Browse files Browse the repository at this point in the history
  • Loading branch information
kraenhansen committed Feb 1, 2024
1 parent ab7816e commit 7fd9661
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions packages/community-cli-plugin/src/utils/loadMetroConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ function getOverrideConfig(
);
}
// Always include the project root as a watch folder, since Metro expects this
const watchFolders = [config.projectRoot];
if (typeof config.watchFolders !== 'undefined') {
watchFolders.push(...config.watchFolders);
} else {
// Fallback to inferring a workspace root
const workspaceRoot = getWorkspaceRoot(ctx.root);
if (typeof workspaceRoot === 'string') {
watchFolders.push(workspaceRoot);
}
}
const overrides: InputConfigT = {
resolver,
serializer: {
Expand All @@ -71,17 +84,9 @@ function getOverrideConfig(
),
],
},
watchFolders,
};
// Applying the heuristic of appending workspace root as watch folder,
// only if no other watch folder (beside the project root) has been given.
if (!config.watchFolders.some(folder => folder !== ctx.root)) {
const workspaceRoot = getWorkspaceRoot(ctx.root);
if (typeof workspaceRoot === 'string') {
overrides.watchFolders = [...config.watchFolders, workspaceRoot];
}
}
return overrides;
}
Expand Down

0 comments on commit 7fd9661

Please sign in to comment.