From 58e56ed5d6da917d756b94f25b496376c66b1c80 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 30 Aug 2021 11:18:37 -0700 Subject: [PATCH] Close package json watches in watch mode on close --- src/compiler/watchPublic.ts | 4 ++++ .../incremental/editing-module-augmentation-watch.js | 5 ++--- .../importHelpers-backing-types-removed-watch.js | 5 ++--- .../jsxImportSource-backing-types-removed-watch.js | 10 ++++------ .../jsxImportSource-option-changed-watch.js | 4 ---- 5 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/compiler/watchPublic.ts b/src/compiler/watchPublic.ts index bfcdc4c8a1d2a..1cc21a0bc9400 100644 --- a/src/compiler/watchPublic.ts +++ b/src/compiler/watchPublic.ts @@ -404,6 +404,10 @@ namespace ts { }); parsedConfigs = undefined; } + if (packageJsonMap) { + clearMap(packageJsonMap, closeFileWatcher); + packageJsonMap = undefined!; + } } function getCurrentBuilderProgram() { diff --git a/tests/baselines/reference/tscWatch/incremental/editing-module-augmentation-watch.js b/tests/baselines/reference/tscWatch/incremental/editing-module-augmentation-watch.js index 381d2d4f0f640..14d6f7c11844c 100644 --- a/tests/baselines/reference/tscWatch/incremental/editing-module-augmentation-watch.js +++ b/tests/baselines/reference/tscWatch/incremental/editing-module-augmentation-watch.js @@ -203,9 +203,6 @@ Shape signatures in builder refreshed for:: /users/username/projects/project/src/index.ts (computed .d.ts) WatchedFiles:: -/users/username/projects/project/node_modules/classnames/package.json: - {"fileName":"/users/username/projects/project/node_modules/classnames/package.json","pollingInterval":250} - {"fileName":"/users/username/projects/project/node_modules/classnames/package.json","pollingInterval":250} /users/username/projects/project/tsconfig.json: {"fileName":"/users/username/projects/project/tsconfig.json","pollingInterval":250} /users/username/projects/project/src/index.ts: @@ -216,6 +213,8 @@ WatchedFiles:: {"fileName":"/users/username/projects/project/src/types/classnames.d.ts","pollingInterval":250} /a/lib/lib.d.ts: {"fileName":"/a/lib/lib.d.ts","pollingInterval":250} +/users/username/projects/project/node_modules/classnames/package.json: + {"fileName":"/users/username/projects/project/node_modules/classnames/package.json","pollingInterval":250} FsWatches:: diff --git a/tests/baselines/reference/tscWatch/incremental/importHelpers-backing-types-removed-watch.js b/tests/baselines/reference/tscWatch/incremental/importHelpers-backing-types-removed-watch.js index 49041b04874bf..54acbbd1a410d 100644 --- a/tests/baselines/reference/tscWatch/incremental/importHelpers-backing-types-removed-watch.js +++ b/tests/baselines/reference/tscWatch/incremental/importHelpers-backing-types-removed-watch.js @@ -122,15 +122,14 @@ Shape signatures in builder refreshed for:: /users/username/projects/project/index.tsx (used version) WatchedFiles:: -/users/username/projects/project/node_modules/tslib/package.json: - {"fileName":"/users/username/projects/project/node_modules/tslib/package.json","pollingInterval":250} - {"fileName":"/users/username/projects/project/node_modules/tslib/package.json","pollingInterval":250} /users/username/projects/project/tsconfig.json: {"fileName":"/users/username/projects/project/tsconfig.json","pollingInterval":250} /users/username/projects/project/index.tsx: {"fileName":"/users/username/projects/project/index.tsx","pollingInterval":250} /a/lib/lib.d.ts: {"fileName":"/a/lib/lib.d.ts","pollingInterval":250} +/users/username/projects/project/node_modules/tslib/package.json: + {"fileName":"/users/username/projects/project/node_modules/tslib/package.json","pollingInterval":250} FsWatches:: diff --git a/tests/baselines/reference/tscWatch/incremental/jsxImportSource-backing-types-removed-watch.js b/tests/baselines/reference/tscWatch/incremental/jsxImportSource-backing-types-removed-watch.js index 9f5e8e47e58e1..641134714d966 100644 --- a/tests/baselines/reference/tscWatch/incremental/jsxImportSource-backing-types-removed-watch.js +++ b/tests/baselines/reference/tscWatch/incremental/jsxImportSource-backing-types-removed-watch.js @@ -190,18 +190,16 @@ Shape signatures in builder refreshed for:: /users/username/projects/project/index.tsx (computed .d.ts) WatchedFiles:: -/users/username/projects/project/node_modules/react/jsx-runtime/package.json: - {"fileName":"/users/username/projects/project/node_modules/react/jsx-runtime/package.json","pollingInterval":250} - {"fileName":"/users/username/projects/project/node_modules/react/jsx-runtime/package.json","pollingInterval":250} -/users/username/projects/project/node_modules/react/package.json: - {"fileName":"/users/username/projects/project/node_modules/react/package.json","pollingInterval":250} - {"fileName":"/users/username/projects/project/node_modules/react/package.json","pollingInterval":250} /users/username/projects/project/tsconfig.json: {"fileName":"/users/username/projects/project/tsconfig.json","pollingInterval":250} /users/username/projects/project/index.tsx: {"fileName":"/users/username/projects/project/index.tsx","pollingInterval":250} /a/lib/lib.d.ts: {"fileName":"/a/lib/lib.d.ts","pollingInterval":250} +/users/username/projects/project/node_modules/react/jsx-runtime/package.json: + {"fileName":"/users/username/projects/project/node_modules/react/jsx-runtime/package.json","pollingInterval":250} +/users/username/projects/project/node_modules/react/package.json: + {"fileName":"/users/username/projects/project/node_modules/react/package.json","pollingInterval":250} FsWatches:: diff --git a/tests/baselines/reference/tscWatch/incremental/jsxImportSource-option-changed-watch.js b/tests/baselines/reference/tscWatch/incremental/jsxImportSource-option-changed-watch.js index cd4b2d10192ef..0d39109590ffe 100644 --- a/tests/baselines/reference/tscWatch/incremental/jsxImportSource-option-changed-watch.js +++ b/tests/baselines/reference/tscWatch/incremental/jsxImportSource-option-changed-watch.js @@ -225,10 +225,6 @@ Shape signatures in builder refreshed for:: /users/username/projects/project/index.tsx (computed .d.ts) WatchedFiles:: -/users/username/projects/project/node_modules/react/jsx-runtime/package.json: - {"fileName":"/users/username/projects/project/node_modules/react/jsx-runtime/package.json","pollingInterval":250} -/users/username/projects/project/node_modules/react/package.json: - {"fileName":"/users/username/projects/project/node_modules/react/package.json","pollingInterval":250} /users/username/projects/project/tsconfig.json: {"fileName":"/users/username/projects/project/tsconfig.json","pollingInterval":250} /users/username/projects/project/index.tsx: