diff --git a/CHANGELOG.md b/CHANGELOG.md index eed248652f..2d675fd6c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -325,7 +325,7 @@ Notes: web developers are advised to use [`~` (tilde range)](https://github.com/ - 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) - 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) - 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) -- Fixed `npm start` for efficiency and reliability, in PR [#5621](https://github.com/microsoft/BotFramework-WebChat/pull/5621), by [@compulim](https://github.com/compulim) +- 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) ### Removed diff --git a/scripts/buildWatch.mjs b/scripts/buildWatch.mjs index a0c222612d..1020448088 100644 --- a/scripts/buildWatch.mjs +++ b/scripts/buildWatch.mjs @@ -12,18 +12,32 @@ const { const root = resolve(rootPackageJSONPath, '../'); -const watchPaths = new Set(['./src/']); +const dependingLocalPackages = new Set(Object.keys(currentPackageJSON.localDependencies || {})); +/** @type Map */ +const localPackageJSONPath = new Map(); -for (const [packageName] of Object.entries(currentPackageJSON.localDependencies || {})) { +for (const packageName of Array.from(dependingLocalPackages)) { for (const workspace of workspaces) { const packageJSON = await readPackage({ cwd: resolve(root, workspace) }); if (packageJSON.name === packageName) { - watchPaths.add(resolve(root, workspace, 'package.json')); + for (const transientLocalPackageName of Object.keys(packageJSON.localDependencies)) { + dependingLocalPackages.delete(transientLocalPackageName); + } + + localPackageJSONPath.set(packageName, resolve(root, workspace, 'package.json')); } } } +const watchPaths = new Set(['./src/']); + +// Only includes packages that are absolutely needed to watch. +// For example, "api -> api-graph -> core" and "api -> core". Then we only need to watch "api-graph" but not "core". +for (const packageName of dependingLocalPackages) { + localPackageJSONPath.has(packageName) && watchPaths.add(localPackageJSONPath.get(packageName)); +} + // "nodemon" will pick up every file change, trigger build too many times. // console.log( // `node --watch ${watchPaths.map(path => `--watch-path "${path}"`).join(' ')} --watch-preserve-output $(which npm) run build:run`