ts-checker-rspack-plugin 1.1.7 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/README.md +69 -22
  2. package/lib/getDependenciesWorker.js +652 -0
  3. package/lib/getIssuesWorker.js +1095 -0
  4. package/lib/index.js +972 -4
  5. package/lib/issue/issue-config.d.ts +2 -0
  6. package/lib/issue/issue-options.d.ts +2 -0
  7. package/lib/issue/issue-severity.d.ts +4 -4
  8. package/lib/plugin-state.d.ts +0 -1
  9. package/lib/plugin.d.ts +1 -1
  10. package/lib/rpc/rpc-worker.d.ts +0 -1
  11. package/lib/rpc/wrap-rpc.d.ts +0 -1
  12. package/lib/typescript/worker/get-issues-worker.d.ts +2 -2
  13. package/lib/typescript/worker/lib/config.d.ts +2 -2
  14. package/lib/typescript/worker/lib/diagnostics.d.ts +3 -3
  15. package/lib/typescript/worker/lib/file-system/file-system.d.ts +0 -1
  16. package/lib/utils/async/abort-error.d.ts +0 -1
  17. package/lib/utils/async/pool.d.ts +0 -1
  18. package/lib/watch/watch-file-system.d.ts +0 -1
  19. package/package.json +12 -11
  20. package/lib/files-change.js +0 -57
  21. package/lib/files-match.js +0 -2
  22. package/lib/formatter/basic-formatter.js +0 -13
  23. package/lib/formatter/code-frame-formatter.js +0 -32
  24. package/lib/formatter/formatter-config.js +0 -36
  25. package/lib/formatter/formatter-options.js +0 -2
  26. package/lib/formatter/formatter.js +0 -2
  27. package/lib/formatter/index.js +0 -22
  28. package/lib/formatter/stats-formatter.js +0 -30
  29. package/lib/formatter/types/babel__code-frame.js +0 -7
  30. package/lib/formatter/webpack-formatter.js +0 -32
  31. package/lib/hooks/intercept-done-to-get-dev-server-tap.js +0 -18
  32. package/lib/hooks/tap-after-compile-to-add-dependencies.js +0 -59
  33. package/lib/hooks/tap-after-compile-to-get-issues.js +0 -43
  34. package/lib/hooks/tap-after-environment-to-patch-watching.js +0 -22
  35. package/lib/hooks/tap-done-to-async-get-issues.js +0 -74
  36. package/lib/hooks/tap-error-to-log-message.js +0 -32
  37. package/lib/hooks/tap-start-to-run-workers.js +0 -122
  38. package/lib/hooks/tap-stop-to-terminate-workers.js +0 -26
  39. package/lib/infrastructure-logger.js +0 -14
  40. package/lib/issue/index.js +0 -19
  41. package/lib/issue/issue-config.js +0 -29
  42. package/lib/issue/issue-location.js +0 -22
  43. package/lib/issue/issue-match.js +0 -20
  44. package/lib/issue/issue-options.js +0 -2
  45. package/lib/issue/issue-position.js +0 -16
  46. package/lib/issue/issue-predicate.js +0 -11
  47. package/lib/issue/issue-severity.js +0 -12
  48. package/lib/issue/issue-webpack-error.js +0 -31
  49. package/lib/issue/issue.js +0 -41
  50. package/lib/logger.js +0 -2
  51. package/lib/plugin-config.js +0 -26
  52. package/lib/plugin-hooks.js +0 -45
  53. package/lib/plugin-options.js +0 -2
  54. package/lib/plugin-pools.js +0 -32
  55. package/lib/plugin-state.js +0 -17
  56. package/lib/plugin.js +0 -74
  57. package/lib/rpc/expose-rpc.js +0 -69
  58. package/lib/rpc/index.js +0 -12
  59. package/lib/rpc/rpc-error.js +0 -12
  60. package/lib/rpc/rpc-worker.js +0 -86
  61. package/lib/rpc/types.js +0 -2
  62. package/lib/rpc/wrap-rpc.js +0 -70
  63. package/lib/typescript/type-script-config-overwrite.js +0 -2
  64. package/lib/typescript/type-script-diagnostics-options.js +0 -2
  65. package/lib/typescript/type-script-support.js +0 -31
  66. package/lib/typescript/type-script-worker-config.js +0 -36
  67. package/lib/typescript/type-script-worker-options.js +0 -2
  68. package/lib/typescript/worker/get-dependencies-worker.js +0 -15
  69. package/lib/typescript/worker/get-issues-worker.js +0 -70
  70. package/lib/typescript/worker/lib/artifacts.js +0 -94
  71. package/lib/typescript/worker/lib/config.js +0 -162
  72. package/lib/typescript/worker/lib/dependencies.js +0 -84
  73. package/lib/typescript/worker/lib/diagnostics.js +0 -112
  74. package/lib/typescript/worker/lib/emit.js +0 -13
  75. package/lib/typescript/worker/lib/file-system/file-system.js +0 -2
  76. package/lib/typescript/worker/lib/file-system/mem-file-system.js +0 -81
  77. package/lib/typescript/worker/lib/file-system/passive-file-system.js +0 -68
  78. package/lib/typescript/worker/lib/file-system/real-file-system.js +0 -171
  79. package/lib/typescript/worker/lib/host/compiler-host.js +0 -17
  80. package/lib/typescript/worker/lib/host/watch-compiler-host.js +0 -32
  81. package/lib/typescript/worker/lib/host/watch-solution-builder-host.js +0 -53
  82. package/lib/typescript/worker/lib/performance.js +0 -29
  83. package/lib/typescript/worker/lib/program/program.js +0 -37
  84. package/lib/typescript/worker/lib/program/solution-builder.js +0 -39
  85. package/lib/typescript/worker/lib/program/watch-program.js +0 -51
  86. package/lib/typescript/worker/lib/system.js +0 -229
  87. package/lib/typescript/worker/lib/tracing.js +0 -27
  88. package/lib/typescript/worker/lib/tsbuildinfo.js +0 -96
  89. package/lib/typescript/worker/lib/typescript.js +0 -6
  90. package/lib/typescript/worker/lib/worker-config.js +0 -5
  91. package/lib/utils/async/abort-error.js +0 -15
  92. package/lib/utils/async/controlled-promise.js +0 -17
  93. package/lib/utils/async/is-pending.js +0 -10
  94. package/lib/utils/async/pool.js +0 -36
  95. package/lib/utils/async/wait.js +0 -7
  96. package/lib/utils/path/forward-slash.js +0 -15
  97. package/lib/utils/path/is-inside-another-path.js +0 -22
  98. package/lib/utils/path/relative-to-context.js +0 -16
  99. package/lib/watch/inclusive-node-watch-file-system.js +0 -183
  100. package/lib/watch/watch-file-system.js +0 -2
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.dumpTracingLegendIfNeeded = exports.stopTracingIfNeeded = exports.startTracingIfNeeded = void 0;
4
- const config_1 = require("./config");
5
- const typescript_1 = require("./typescript");
6
- const worker_config_1 = require("./worker-config");
7
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
- const traceableTypescript = typescript_1.typescript;
9
- function startTracingIfNeeded(compilerOptions) {
10
- if (typeof compilerOptions.generateTrace === 'string' &&
11
- typeof traceableTypescript.startTracing === 'function') {
12
- traceableTypescript.startTracing(worker_config_1.config.build ? 'build' : 'project', compilerOptions.generateTrace, (0, config_1.getConfigFilePathFromCompilerOptions)(compilerOptions));
13
- }
14
- }
15
- exports.startTracingIfNeeded = startTracingIfNeeded;
16
- function stopTracingIfNeeded(program) {
17
- const compilerOptions = program.getCompilerOptions();
18
- if (typeof compilerOptions.generateTrace === 'string' &&
19
- typeof traceableTypescript.tracing?.stopTracing === 'function') {
20
- traceableTypescript.tracing.stopTracing();
21
- }
22
- }
23
- exports.stopTracingIfNeeded = stopTracingIfNeeded;
24
- function dumpTracingLegendIfNeeded() {
25
- traceableTypescript.tracing?.dumpLegend();
26
- }
27
- exports.dumpTracingLegendIfNeeded = dumpTracingLegendIfNeeded;
@@ -1,96 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getTsBuildInfoEmitPath = exports.emitTsBuildInfoIfNeeded = exports.invalidateTsBuildInfo = void 0;
27
- const path = __importStar(require("path"));
28
- const config_1 = require("./config");
29
- const system_1 = require("./system");
30
- const typescript_1 = require("./typescript");
31
- const worker_config_1 = require("./worker-config");
32
- function invalidateTsBuildInfo() {
33
- const parsedConfig = (0, config_1.getParsedConfig)();
34
- // try to remove outdated .tsbuildinfo file for incremental mode
35
- if (typeof typescript_1.typescript.getTsBuildInfoEmitOutputFilePath === 'function' &&
36
- worker_config_1.config.mode !== 'readonly' &&
37
- parsedConfig.options.incremental) {
38
- const tsBuildInfoPath = typescript_1.typescript.getTsBuildInfoEmitOutputFilePath(parsedConfig.options);
39
- if (tsBuildInfoPath) {
40
- try {
41
- system_1.system.deleteFile(tsBuildInfoPath);
42
- }
43
- catch (error) {
44
- // silent
45
- }
46
- }
47
- }
48
- }
49
- exports.invalidateTsBuildInfo = invalidateTsBuildInfo;
50
- function emitTsBuildInfoIfNeeded(builderProgram) {
51
- const parsedConfig = (0, config_1.getParsedConfig)();
52
- if (worker_config_1.config.mode !== 'readonly' && parsedConfig && isIncrementalEnabled(parsedConfig.options)) {
53
- const program = builderProgram.getProgram();
54
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
55
- if (typeof program.emitBuildInfo === 'function') {
56
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
57
- program.emitBuildInfo();
58
- }
59
- }
60
- }
61
- exports.emitTsBuildInfoIfNeeded = emitTsBuildInfoIfNeeded;
62
- function getTsBuildInfoEmitPath(compilerOptions) {
63
- if (typeof typescript_1.typescript.getTsBuildInfoEmitOutputFilePath === 'function') {
64
- return typescript_1.typescript.getTsBuildInfoEmitOutputFilePath(compilerOptions);
65
- }
66
- const removeJsonExtension = (filePath) => filePath.endsWith('.json') ? filePath.slice(0, -'.json'.length) : filePath;
67
- // based on the implementation from typescript
68
- const configFile = compilerOptions.configFilePath;
69
- if (!isIncrementalEnabled(compilerOptions)) {
70
- return undefined;
71
- }
72
- if (compilerOptions.tsBuildInfoFile) {
73
- return compilerOptions.tsBuildInfoFile;
74
- }
75
- const outPath = compilerOptions.outFile || compilerOptions.out;
76
- let buildInfoExtensionLess;
77
- if (outPath) {
78
- buildInfoExtensionLess = removeJsonExtension(outPath);
79
- }
80
- else {
81
- if (!configFile) {
82
- return undefined;
83
- }
84
- const configFileExtensionLess = removeJsonExtension(configFile);
85
- buildInfoExtensionLess = compilerOptions.outDir
86
- ? compilerOptions.rootDir
87
- ? path.resolve(compilerOptions.outDir, path.relative(compilerOptions.rootDir, configFileExtensionLess))
88
- : path.resolve(compilerOptions.outDir, path.basename(configFileExtensionLess))
89
- : configFileExtensionLess;
90
- }
91
- return buildInfoExtensionLess + '.tsbuildinfo';
92
- }
93
- exports.getTsBuildInfoEmitPath = getTsBuildInfoEmitPath;
94
- function isIncrementalEnabled(compilerOptions) {
95
- return Boolean((compilerOptions.incremental || compilerOptions.composite) && !compilerOptions.outFile);
96
- }
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.typescript = void 0;
4
- const worker_config_1 = require("./worker-config");
5
- // eslint-disable-next-line
6
- exports.typescript = require(worker_config_1.config.typescriptPath);
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.config = void 0;
4
- const rpc_1 = require("../../../rpc");
5
- exports.config = (0, rpc_1.getRpcWorkerData)();
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AbortError = void 0;
4
- class AbortError extends Error {
5
- constructor(message = 'Task aborted.') {
6
- super(message);
7
- this.name = 'AbortError';
8
- }
9
- static throwIfAborted(signal) {
10
- if (signal?.aborted) {
11
- throw new AbortError();
12
- }
13
- }
14
- }
15
- exports.AbortError = AbortError;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createControlledPromise = void 0;
4
- function createControlledPromise() {
5
- let resolve = () => undefined;
6
- let reject = () => undefined;
7
- const promise = new Promise((aResolve, aReject) => {
8
- resolve = aResolve;
9
- reject = aReject;
10
- });
11
- return {
12
- promise,
13
- resolve,
14
- reject,
15
- };
16
- }
17
- exports.createControlledPromise = createControlledPromise;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isPending = void 0;
4
- function isPending(promise, timeout = 100) {
5
- return Promise.race([
6
- promise.then(() => false).catch(() => false),
7
- new Promise((resolve) => setTimeout(() => resolve(true), timeout)),
8
- ]);
9
- }
10
- exports.isPending = isPending;
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createPool = void 0;
4
- const abort_error_1 = require("./abort-error");
5
- function createPool(size) {
6
- let pendingPromises = [];
7
- const pool = {
8
- async submit(task, signal) {
9
- while (pendingPromises.length >= pool.size) {
10
- abort_error_1.AbortError.throwIfAborted(signal);
11
- await Promise.race(pendingPromises).catch(() => undefined);
12
- }
13
- abort_error_1.AbortError.throwIfAborted(signal);
14
- const taskPromise = task(signal).finally(() => {
15
- pendingPromises = pendingPromises.filter((pendingPromise) => pendingPromise !== taskPromise);
16
- });
17
- pendingPromises.push(taskPromise);
18
- return taskPromise;
19
- },
20
- size,
21
- get pending() {
22
- return pendingPromises.length;
23
- },
24
- get drained() {
25
- // eslint-disable-next-line no-async-promise-executor
26
- return new Promise(async (resolve) => {
27
- while (pendingPromises.length > 0) {
28
- await Promise.race(pendingPromises).catch(() => undefined);
29
- }
30
- resolve(undefined);
31
- });
32
- },
33
- };
34
- return pool;
35
- }
36
- exports.createPool = createPool;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.wait = void 0;
4
- function wait(timeout) {
5
- return new Promise((resolve) => setTimeout(resolve, timeout));
6
- }
7
- exports.wait = wait;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.forwardSlash = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- /**
9
- * Replaces backslashes with one forward slash
10
- * @param input
11
- */
12
- function forwardSlash(input) {
13
- return path_1.default.normalize(input).replace(/\\+/g, '/');
14
- }
15
- exports.forwardSlash = forwardSlash;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isInsideAnotherPath = void 0;
4
- const path_1 = require("path");
5
- function isInsideAnotherPath(parent, directory) {
6
- const relativePart = (0, path_1.relative)(parent, directory);
7
- // Tested folder is above parent.
8
- if (relativePart.startsWith('..')) {
9
- return false;
10
- }
11
- // Tested folder is the same as parent.
12
- if (relativePart.length === 0) {
13
- return false;
14
- }
15
- // Tested directory has nothing in common with parent.
16
- if ((0, path_1.isAbsolute)(relativePart)) {
17
- return false;
18
- }
19
- // Last option, must be subfolder.
20
- return true;
21
- }
22
- exports.isInsideAnotherPath = isInsideAnotherPath;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.relativeToContext = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- const forward_slash_1 = require("./forward-slash");
9
- function relativeToContext(file, context) {
10
- let fileInContext = (0, forward_slash_1.forwardSlash)(path_1.default.relative(context, file));
11
- if (!fileInContext.startsWith('../')) {
12
- fileInContext = './' + fileInContext;
13
- }
14
- return fileInContext;
15
- }
16
- exports.relativeToContext = relativeToContext;
@@ -1,183 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.InclusiveNodeWatchFileSystem = exports.createIsIgnored = void 0;
7
- const path_1 = require("path");
8
- const chokidar_1 = __importDefault(require("chokidar"));
9
- const minimatch_1 = require("minimatch");
10
- const is_glob_1 = __importDefault(require("is-glob"));
11
- const files_change_1 = require("../files-change");
12
- const infrastructure_logger_1 = require("../infrastructure-logger");
13
- const is_inside_another_path_1 = require("../utils/path/is-inside-another-path");
14
- const BUILTIN_IGNORED_DIRS = ['.git'];
15
- function createIsIgnored(ignored, excluded) {
16
- const ignoredPatterns = ignored ? (Array.isArray(ignored) ? [...ignored] : [ignored]) : [];
17
- const filteredExcluded = excluded.filter((pattern) => {
18
- // Use `minimatch` to check if the path is a glob pattern.
19
- if ((0, is_glob_1.default)(pattern)) {
20
- // Append `/**` to the pattern to align minimatch's behavior
21
- // with the `exclude` option in tsconfig.json.
22
- const shouldAppendStar = pattern.includes('**') && !pattern.endsWith('*');
23
- if (shouldAppendStar) {
24
- ignoredPatterns.push(pattern.endsWith('/') ? `${pattern}**` : `${pattern}/**`);
25
- }
26
- else {
27
- ignoredPatterns.push(pattern);
28
- }
29
- return false;
30
- }
31
- return true;
32
- });
33
- const ignoredFunctions = ignoredPatterns.map((pattern) => {
34
- // ensure patterns are valid - see https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/issues/594
35
- if (typeof pattern === 'string') {
36
- return (path) => (0, minimatch_1.minimatch)(path, pattern);
37
- }
38
- else if (pattern instanceof RegExp) {
39
- return (path) => pattern.test(path);
40
- }
41
- else {
42
- // fallback to no-ignore function
43
- return () => false;
44
- }
45
- });
46
- ignoredFunctions.push((path) => filteredExcluded.some((excludedPath) => (0, is_inside_another_path_1.isInsideAnotherPath)(excludedPath, path)));
47
- ignoredFunctions.push((path) => BUILTIN_IGNORED_DIRS.some((ignoredDir) => path.includes(`/${ignoredDir}/`) || path.includes(`\\${ignoredDir}\\`)));
48
- return function isIgnored(path) {
49
- return ignoredFunctions.some((ignoredFunction) => ignoredFunction(path));
50
- };
51
- }
52
- exports.createIsIgnored = createIsIgnored;
53
- class InclusiveNodeWatchFileSystem {
54
- get watcher() {
55
- return this.watchFileSystem.watcher || this.watchFileSystem.wfs?.watcher;
56
- }
57
- constructor(watchFileSystem, compiler, pluginState) {
58
- this.watchFileSystem = watchFileSystem;
59
- this.compiler = compiler;
60
- this.pluginState = pluginState;
61
- this.paused = true;
62
- this.watch = (files, dirs, missing, startTime, options, callback, callbackUndelayed) => {
63
- const { debug } = (0, infrastructure_logger_1.getInfrastructureLogger)(this.compiler);
64
- (0, files_change_1.clearFilesChange)(this.compiler);
65
- const isIgnored = createIsIgnored(options?.ignored, this.pluginState.lastDependencies?.excluded || []);
66
- // use standard watch file system for files and missing
67
- const standardWatcher = this.watchFileSystem.watch(files, dirs, missing, startTime, options, callback, callbackUndelayed);
68
- this.watcher?.on('change', (file) => {
69
- if (typeof file !== 'string') {
70
- return;
71
- }
72
- if (!isIgnored(file)) {
73
- debug('Detected file change', file);
74
- this.deletedFiles.delete(file);
75
- (0, files_change_1.updateFilesChange)(this.compiler, { changedFiles: [file] });
76
- }
77
- else {
78
- debug("Detected file change but it's ignored", file);
79
- }
80
- });
81
- this.watcher?.on('remove', (file) => {
82
- if (typeof file !== 'string') {
83
- return;
84
- }
85
- if (this.deletedFiles.has(file)) {
86
- debug('Skipping duplicated remove event.');
87
- return;
88
- }
89
- if (!isIgnored(file)) {
90
- debug('Detected file remove', file);
91
- this.deletedFiles.add(file);
92
- (0, files_change_1.updateFilesChange)(this.compiler, { deletedFiles: [file] });
93
- }
94
- else {
95
- debug("Detected file remove but it's ignored", file);
96
- }
97
- });
98
- // calculate what to change
99
- const prevDirs = Array.from(this.dirsWatchers.keys());
100
- const nextDirs = Array.from(this.pluginState.lastDependencies?.dirs || []);
101
- const dirsToUnwatch = prevDirs.filter((prevDir) => !nextDirs.includes(prevDir));
102
- const dirsToWatch = nextDirs.filter((nextDir) => !prevDirs.includes(nextDir) && !isIgnored(nextDir));
103
- // update dirs watcher
104
- dirsToUnwatch.forEach((dirToUnwatch) => {
105
- this.dirsWatchers.get(dirToUnwatch)?.close();
106
- this.dirsWatchers.delete(dirToUnwatch);
107
- });
108
- dirsToWatch.forEach((dirToWatch) => {
109
- const interval = typeof options?.poll === 'number' ? options.poll : undefined;
110
- const dirWatcher = chokidar_1.default.watch(dirToWatch, {
111
- ignoreInitial: true,
112
- ignorePermissionErrors: true,
113
- ignored: (path) => isIgnored(path),
114
- usePolling: options?.poll ? true : undefined,
115
- interval: interval,
116
- binaryInterval: interval,
117
- alwaysStat: true,
118
- atomic: true,
119
- awaitWriteFinish: true,
120
- });
121
- dirWatcher.on('add', (file, stats) => {
122
- if (this.paused) {
123
- return;
124
- }
125
- const extension = (0, path_1.extname)(file);
126
- const supportedExtensions = this.pluginState.lastDependencies?.extensions || [];
127
- if (!supportedExtensions.includes(extension)) {
128
- debug('Detected new file add but extension is not supported', file);
129
- return;
130
- }
131
- debug('Detected new file add', file);
132
- this.deletedFiles.delete(file);
133
- (0, files_change_1.updateFilesChange)(this.compiler, { changedFiles: [file] });
134
- this.watcher?._onChange(file, stats?.mtimeMs || stats?.ctimeMs || 1, file, 'rename');
135
- });
136
- dirWatcher.on('unlink', (file) => {
137
- if (this.paused) {
138
- return;
139
- }
140
- const extension = (0, path_1.extname)(file);
141
- const supportedExtensions = this.pluginState.lastDependencies?.extensions || [];
142
- if (!supportedExtensions.includes(extension)) {
143
- debug('Detected new file remove but extension is not supported', file);
144
- return;
145
- }
146
- if (this.deletedFiles.has(file)) {
147
- debug('Skipping duplicated unlink event.');
148
- return;
149
- }
150
- debug('Detected new file remove', file);
151
- this.deletedFiles.add(file);
152
- (0, files_change_1.updateFilesChange)(this.compiler, { deletedFiles: [file] });
153
- this.watcher?._onRemove(dirToWatch, file, 'rename');
154
- });
155
- this.dirsWatchers.set(dirToWatch, dirWatcher);
156
- });
157
- this.paused = false;
158
- return {
159
- ...standardWatcher,
160
- close: () => {
161
- (0, files_change_1.clearFilesChange)(this.compiler);
162
- if (standardWatcher) {
163
- standardWatcher.close();
164
- }
165
- this.dirsWatchers.forEach((dirWatcher) => {
166
- dirWatcher?.close();
167
- });
168
- this.dirsWatchers.clear();
169
- this.paused = true;
170
- },
171
- pause: () => {
172
- if (standardWatcher) {
173
- standardWatcher.pause();
174
- }
175
- this.paused = true;
176
- },
177
- };
178
- };
179
- this.dirsWatchers = new Map();
180
- this.deletedFiles = new Set();
181
- }
182
- }
183
- exports.InclusiveNodeWatchFileSystem = InclusiveNodeWatchFileSystem;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });