Skip to content

Commit bdf0917

Browse files
authored
[Build] Only watch direct local packages and skip transient (#5629)
* [Build] Only watch direct local packages and skip transient local packages * Update entry
1 parent e5e0f7c commit bdf0917

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ Notes: web developers are advised to use [`~` (tilde range)](https://github.com/
325325
- Fixed published package types containing internal package references, in PR [#5610](https://github.com/microsoft/BotFramework-WebChat/pull/5610), by [@OEvgeny](https://github.com/OEvgeny)
326326
- Fixed citation links are not properly matched against markdown links, in PR [#5614](https://github.com/microsoft/BotFramework-WebChat/pull/5614), by [@OEvgeny](https://github.com/OEvgeny)
327327
- Fixed `botframework-webchat/decorator` import in legacy CommonJS environments, in [#5616](https://github.com/microsoft/BotFramework-WebChat/pull/5616), by [@OEvgeny](https://github.com/OEvgeny)
328-
- Fixed `npm start` for efficiency and reliability, in PR [#5621](https://github.com/microsoft/BotFramework-WebChat/pull/5621), by [@compulim](https://github.com/compulim)
328+
- Fixed `npm start` for efficiency and reliability, in PR [#5621](https://github.com/microsoft/BotFramework-WebChat/pull/5621) and [#5629](https://github.com/microsoft/BotFramework-WebChat/pull/5629), by [@compulim](https://github.com/compulim)
329329

330330
### Removed
331331

scripts/buildWatch.mjs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,32 @@ const {
1212

1313
const root = resolve(rootPackageJSONPath, '../');
1414

15-
const watchPaths = new Set(['./src/']);
15+
const dependingLocalPackages = new Set(Object.keys(currentPackageJSON.localDependencies || {}));
16+
/** @type Map<string, string> */
17+
const localPackageJSONPath = new Map();
1618

17-
for (const [packageName] of Object.entries(currentPackageJSON.localDependencies || {})) {
19+
for (const packageName of Array.from(dependingLocalPackages)) {
1820
for (const workspace of workspaces) {
1921
const packageJSON = await readPackage({ cwd: resolve(root, workspace) });
2022

2123
if (packageJSON.name === packageName) {
22-
watchPaths.add(resolve(root, workspace, 'package.json'));
24+
for (const transientLocalPackageName of Object.keys(packageJSON.localDependencies)) {
25+
dependingLocalPackages.delete(transientLocalPackageName);
26+
}
27+
28+
localPackageJSONPath.set(packageName, resolve(root, workspace, 'package.json'));
2329
}
2430
}
2531
}
2632

33+
const watchPaths = new Set(['./src/']);
34+
35+
// Only includes packages that are absolutely needed to watch.
36+
// For example, "api -> api-graph -> core" and "api -> core". Then we only need to watch "api-graph" but not "core".
37+
for (const packageName of dependingLocalPackages) {
38+
localPackageJSONPath.has(packageName) && watchPaths.add(localPackageJSONPath.get(packageName));
39+
}
40+
2741
// "nodemon" will pick up every file change, trigger build too many times.
2842
// console.log(
2943
// `node --watch ${watchPaths.map(path => `--watch-path "${path}"`).join(' ')} --watch-preserve-output $(which npm) run build:run`

0 commit comments

Comments
 (0)