fork-ts-checker-webpack-plugin 9.1.1 → 10.0.0-alpha.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.
- package/README.md +23 -13
- package/lib/files-change.js +5 -6
- package/lib/formatter/basic-formatter.js +3 -4
- package/lib/formatter/code-frame-formatter.d.ts +3 -2
- package/lib/formatter/code-frame-formatter.js +14 -5
- package/lib/formatter/formatter-config.js +3 -3
- package/lib/formatter/formatter-options.d.ts +1 -1
- package/lib/formatter/stats-formatter.js +4 -5
- package/lib/formatter/webpack-formatter.js +6 -11
- package/lib/hooks/intercept-done-to-get-dev-server-tap.js +1 -2
- package/lib/hooks/report-issues.d.ts +8 -0
- package/lib/hooks/report-issues.js +22 -0
- package/lib/hooks/tap-after-compile-to-add-dependencies.js +4 -14
- package/lib/hooks/tap-after-compile-to-get-issues.js +7 -29
- package/lib/hooks/tap-after-environment-to-patch-watching.js +1 -2
- package/lib/hooks/tap-done-to-async-get-issues.js +13 -34
- package/lib/hooks/tap-error-to-log-message.js +6 -9
- package/lib/hooks/tap-start-to-run-workers.js +13 -24
- package/lib/hooks/tap-stop-to-terminate-workers.js +1 -2
- package/lib/infrastructure-logger.js +1 -2
- package/lib/issue/issue-config.js +1 -2
- package/lib/issue/issue-location.js +2 -3
- package/lib/issue/issue-match.js +3 -4
- package/lib/issue/issue-position.js +1 -2
- package/lib/issue/issue-predicate.js +2 -3
- package/lib/issue/issue-severity.js +2 -3
- package/lib/issue/issue-webpack-error.js +21 -18
- package/lib/issue/issue.js +2 -3
- package/lib/plugin-config.js +1 -2
- package/lib/plugin-hooks.d.ts +4 -4
- package/lib/plugin-hooks.js +1 -2
- package/lib/plugin-options.json +4 -8
- package/lib/plugin-pools.js +17 -7
- package/lib/plugin-state.d.ts +0 -1
- package/lib/plugin-state.js +1 -2
- package/lib/plugin.d.ts +2 -2
- package/lib/plugin.js +39 -24
- package/lib/rpc/expose-rpc.js +6 -16
- package/lib/rpc/rpc-error.js +2 -0
- package/lib/rpc/rpc-worker.d.ts +1 -2
- package/lib/rpc/rpc-worker.js +26 -17
- package/lib/rpc/wrap-rpc.d.ts +0 -1
- package/lib/rpc/wrap-rpc.js +4 -14
- package/lib/typescript/type-script-package.d.ts +4 -0
- package/lib/typescript/type-script-package.js +88 -0
- package/lib/typescript/type-script-support.js +26 -27
- package/lib/typescript/type-script-worker-config.d.ts +2 -3
- package/lib/typescript/type-script-worker-config.js +24 -4
- package/lib/typescript/type-script-worker-options.d.ts +4 -3
- package/lib/typescript/type-script-worker-options.js +4 -0
- package/lib/typescript/worker/get-dependencies-worker.js +15 -4
- package/lib/typescript/worker/get-issues-worker.d.ts +1 -1
- package/lib/typescript/worker/get-issues-worker.js +52 -64
- package/lib/typescript/worker/lib/api.d.ts +13 -0
- package/lib/typescript/worker/lib/api.js +62 -0
- package/lib/typescript/worker/lib/config.d.ts +13 -9
- package/lib/typescript/worker/lib/config.js +93 -65
- package/lib/typescript/worker/lib/dependencies.d.ts +6 -1
- package/lib/typescript/worker/lib/dependencies.js +187 -53
- package/lib/typescript/worker/lib/diagnostics.d.ts +5 -4
- package/lib/typescript/worker/lib/diagnostics.js +67 -51
- package/lib/typescript/worker/lib/in-memory-file-system.d.ts +14 -0
- package/lib/typescript/worker/lib/in-memory-file-system.js +140 -0
- package/lib/typescript/worker/lib/performance.d.ts +1 -2
- package/lib/typescript/worker/lib/performance.js +13 -21
- package/lib/typescript/worker/lib/program/program.d.ts +6 -2
- package/lib/typescript/worker/lib/program/program.js +136 -26
- package/lib/typescript/worker/lib/program/solution-builder.d.ts +3 -1
- package/lib/typescript/worker/lib/program/solution-builder.js +43 -27
- package/lib/typescript/worker/lib/typescript.d.ts +4 -2
- package/lib/typescript/worker/lib/typescript.js +69 -3
- package/lib/utils/async/abort-error.d.ts +0 -1
- package/lib/utils/async/abort-error.js +1 -1
- package/lib/utils/async/controlled-promise.js +1 -2
- package/lib/utils/async/is-pending.js +1 -2
- package/lib/utils/async/pool.d.ts +0 -1
- package/lib/utils/async/pool.js +13 -25
- package/lib/utils/async/wait.js +1 -2
- package/lib/utils/deep-merge.d.ts +5 -0
- package/lib/utils/deep-merge.js +56 -0
- package/lib/utils/path/format-file-path.d.ts +3 -0
- package/lib/utils/path/format-file-path.js +15 -0
- package/lib/utils/path/forward-slash.js +1 -2
- package/lib/utils/path/is-inside-another-path.js +1 -2
- package/lib/utils/path/relative-to-context.js +1 -2
- package/lib/watch/inclusive-node-watch-file-system.d.ts +3 -0
- package/lib/watch/inclusive-node-watch-file-system.js +121 -113
- package/lib/watch/watch-file-system.d.ts +0 -1
- package/package.json +43 -53
- package/lib/formatter/types/babel__code-frame.d.ts +0 -21
- package/lib/formatter/types/babel__code-frame.js +0 -7
- package/lib/typescript/worker/lib/artifacts.d.ts +0 -4
- package/lib/typescript/worker/lib/artifacts.js +0 -94
- package/lib/typescript/worker/lib/emit.d.ts +0 -2
- package/lib/typescript/worker/lib/emit.js +0 -13
- package/lib/typescript/worker/lib/file-system/file-system.d.ts +0 -18
- package/lib/typescript/worker/lib/file-system/file-system.js +0 -2
- package/lib/typescript/worker/lib/file-system/mem-file-system.d.ts +0 -5
- package/lib/typescript/worker/lib/file-system/mem-file-system.js +0 -78
- package/lib/typescript/worker/lib/file-system/passive-file-system.d.ts +0 -5
- package/lib/typescript/worker/lib/file-system/passive-file-system.js +0 -65
- package/lib/typescript/worker/lib/file-system/real-file-system.d.ts +0 -5
- package/lib/typescript/worker/lib/file-system/real-file-system.js +0 -191
- package/lib/typescript/worker/lib/host/compiler-host.d.ts +0 -2
- package/lib/typescript/worker/lib/host/compiler-host.js +0 -10
- package/lib/typescript/worker/lib/host/watch-compiler-host.d.ts +0 -2
- package/lib/typescript/worker/lib/host/watch-compiler-host.js +0 -20
- package/lib/typescript/worker/lib/host/watch-solution-builder-host.d.ts +0 -2
- package/lib/typescript/worker/lib/host/watch-solution-builder-host.js +0 -47
- package/lib/typescript/worker/lib/program/watch-program.d.ts +0 -3
- package/lib/typescript/worker/lib/program/watch-program.js +0 -51
- package/lib/typescript/worker/lib/system.d.ts +0 -19
- package/lib/typescript/worker/lib/system.js +0 -232
- package/lib/typescript/worker/lib/tracing.d.ts +0 -4
- package/lib/typescript/worker/lib/tracing.js +0 -29
- package/lib/typescript/worker/lib/tsbuildinfo.d.ts +0 -4
- package/lib/typescript/worker/lib/tsbuildinfo.js +0 -96
|
@@ -1,6 +1,72 @@
|
|
|
1
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 () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
36
|
+
exports.typescriptFs = exports.typescriptSync = void 0;
|
|
37
|
+
const path = __importStar(require("path"));
|
|
38
|
+
const type_script_package_1 = require("../../type-script-package");
|
|
4
39
|
const worker_config_1 = require("./worker-config");
|
|
5
|
-
|
|
6
|
-
|
|
40
|
+
/** Picks the file a `require` of an `exports` entry resolves to, through nested conditions. */
|
|
41
|
+
function resolveExportTarget(target) {
|
|
42
|
+
if (typeof target === 'string') {
|
|
43
|
+
return target;
|
|
44
|
+
}
|
|
45
|
+
if (Array.isArray(target)) {
|
|
46
|
+
return target.map(resolveExportTarget).find((file) => file !== undefined);
|
|
47
|
+
}
|
|
48
|
+
if (typeof target === 'object' && target !== null) {
|
|
49
|
+
const conditions = target;
|
|
50
|
+
for (const condition of ['require', 'node', 'default']) {
|
|
51
|
+
const file = resolveExportTarget(conditions[condition]);
|
|
52
|
+
if (file !== undefined) {
|
|
53
|
+
return file;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
function resolveExport(packageDirectory, subpath) {
|
|
60
|
+
const packageJson = (0, type_script_package_1.readTypeScriptPackageJson)(packageDirectory);
|
|
61
|
+
const file = resolveExportTarget(packageJson.exports?.[subpath]);
|
|
62
|
+
if (typeof file !== 'string') {
|
|
63
|
+
throw new Error(`The TypeScript package at "${packageDirectory}" doesn't expose "${subpath}". ` +
|
|
64
|
+
'ForkTsCheckerWebpackPlugin requires TypeScript 7.1 or newer.');
|
|
65
|
+
}
|
|
66
|
+
return path.join(packageDirectory, file);
|
|
67
|
+
}
|
|
68
|
+
const packageDirectory = (0, type_script_package_1.findTypeScriptPackageDirectory)(worker_config_1.config.typescriptPath);
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
70
|
+
exports.typescriptSync = require(resolveExport(packageDirectory, './sync'));
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
72
|
+
exports.typescriptFs = require(resolveExport(packageDirectory, './fs'));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createControlledPromise =
|
|
3
|
+
exports.createControlledPromise = createControlledPromise;
|
|
4
4
|
function createControlledPromise() {
|
|
5
5
|
let resolve = () => undefined;
|
|
6
6
|
let reject = () => undefined;
|
|
@@ -14,4 +14,3 @@ function createControlledPromise() {
|
|
|
14
14
|
reject,
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
exports.createControlledPromise = createControlledPromise;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isPending =
|
|
3
|
+
exports.isPending = isPending;
|
|
4
4
|
function isPending(promise, timeout = 100) {
|
|
5
5
|
return Promise.race([
|
|
6
6
|
promise.then(() => false).catch(() => false),
|
|
7
7
|
new Promise((resolve) => setTimeout(() => resolve(true), timeout)),
|
|
8
8
|
]);
|
|
9
9
|
}
|
|
10
|
-
exports.isPending = isPending;
|
package/lib/utils/async/pool.js
CHANGED
|
@@ -1,32 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.createPool =
|
|
3
|
+
exports.createPool = createPool;
|
|
13
4
|
const abort_error_1 = require("./abort-error");
|
|
14
5
|
function createPool(size) {
|
|
15
6
|
let pendingPromises = [];
|
|
16
7
|
const pool = {
|
|
17
|
-
submit(task, signal) {
|
|
18
|
-
|
|
19
|
-
while (pendingPromises.length >= pool.size) {
|
|
20
|
-
abort_error_1.AbortError.throwIfAborted(signal);
|
|
21
|
-
yield Promise.race(pendingPromises).catch(() => undefined);
|
|
22
|
-
}
|
|
8
|
+
async submit(task, signal) {
|
|
9
|
+
while (pendingPromises.length >= pool.size) {
|
|
23
10
|
abort_error_1.AbortError.throwIfAborted(signal);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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);
|
|
29
16
|
});
|
|
17
|
+
pendingPromises.push(taskPromise);
|
|
18
|
+
return taskPromise;
|
|
30
19
|
},
|
|
31
20
|
size,
|
|
32
21
|
get pending() {
|
|
@@ -34,14 +23,13 @@ function createPool(size) {
|
|
|
34
23
|
},
|
|
35
24
|
get drained() {
|
|
36
25
|
// eslint-disable-next-line no-async-promise-executor
|
|
37
|
-
return new Promise((resolve) =>
|
|
26
|
+
return new Promise(async (resolve) => {
|
|
38
27
|
while (pendingPromises.length > 0) {
|
|
39
|
-
|
|
28
|
+
await Promise.race(pendingPromises).catch(() => undefined);
|
|
40
29
|
}
|
|
41
30
|
resolve(undefined);
|
|
42
|
-
})
|
|
31
|
+
});
|
|
43
32
|
},
|
|
44
33
|
};
|
|
45
34
|
return pool;
|
|
46
35
|
}
|
|
47
|
-
exports.createPool = createPool;
|
package/lib/utils/async/wait.js
CHANGED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Merges `source` into a copy of `target`: objects are merged key by key, arrays
|
|
3
|
+
* are concatenated, and anything else in `source` wins. Neither input is modified.
|
|
4
|
+
*/
|
|
5
|
+
export declare function deepMerge<TTarget extends object, TSource extends object>(target: TTarget, source: TSource): TTarget & TSource;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deepMerge = deepMerge;
|
|
4
|
+
function isMergeable(value) {
|
|
5
|
+
return (typeof value === 'object' &&
|
|
6
|
+
value !== null &&
|
|
7
|
+
!(value instanceof RegExp) &&
|
|
8
|
+
!(value instanceof Date));
|
|
9
|
+
}
|
|
10
|
+
function clone(value) {
|
|
11
|
+
return isMergeable(value) ? merge(Array.isArray(value) ? [] : {}, value) : value;
|
|
12
|
+
}
|
|
13
|
+
function getKeys(value) {
|
|
14
|
+
return [
|
|
15
|
+
...Object.keys(value),
|
|
16
|
+
...Object.getOwnPropertySymbols(value).filter((symbol) => Object.prototype.propertyIsEnumerable.call(value, symbol)),
|
|
17
|
+
];
|
|
18
|
+
}
|
|
19
|
+
function merge(target, source) {
|
|
20
|
+
if (Array.isArray(target) !== Array.isArray(source)) {
|
|
21
|
+
return clone(source);
|
|
22
|
+
}
|
|
23
|
+
if (Array.isArray(target) && Array.isArray(source)) {
|
|
24
|
+
return [...target, ...source].map(clone);
|
|
25
|
+
}
|
|
26
|
+
const targetObject = target;
|
|
27
|
+
const sourceObject = source;
|
|
28
|
+
const result = {};
|
|
29
|
+
for (const key of getKeys(targetObject)) {
|
|
30
|
+
// assigning `__proto__` would replace the prototype of the result
|
|
31
|
+
if (key !== '__proto__') {
|
|
32
|
+
result[key] = clone(targetObject[key]);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
for (const key of getKeys(sourceObject)) {
|
|
36
|
+
if (key === '__proto__') {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const targetValue = Object.prototype.hasOwnProperty.call(targetObject, key)
|
|
40
|
+
? targetObject[key]
|
|
41
|
+
: undefined;
|
|
42
|
+
const sourceValue = sourceObject[key];
|
|
43
|
+
result[key] =
|
|
44
|
+
isMergeable(targetValue) && isMergeable(sourceValue)
|
|
45
|
+
? merge(targetValue, sourceValue)
|
|
46
|
+
: clone(sourceValue);
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Merges `source` into a copy of `target`: objects are merged key by key, arrays
|
|
52
|
+
* are concatenated, and anything else in `source` wins. Neither input is modified.
|
|
53
|
+
*/
|
|
54
|
+
function deepMerge(target, source) {
|
|
55
|
+
return merge(target, source);
|
|
56
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
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.formatFilePath = formatFilePath;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const forward_slash_1 = require("./forward-slash");
|
|
9
|
+
const relative_to_context_1 = require("./relative-to-context");
|
|
10
|
+
/** The file path as shown in issues: absolute, or relative to the current working directory. */
|
|
11
|
+
function formatFilePath(file, pathType) {
|
|
12
|
+
return pathType === 'absolute'
|
|
13
|
+
? (0, forward_slash_1.forwardSlash)(path_1.default.resolve(file))
|
|
14
|
+
: (0, relative_to_context_1.relativeToContext)(file, process.cwd());
|
|
15
|
+
}
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.forwardSlash =
|
|
6
|
+
exports.forwardSlash = forwardSlash;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
/**
|
|
9
9
|
* Replaces backslashes with one forward slash
|
|
@@ -12,4 +12,3 @@ const path_1 = __importDefault(require("path"));
|
|
|
12
12
|
function forwardSlash(input) {
|
|
13
13
|
return path_1.default.normalize(input).replace(/\\+/g, '/');
|
|
14
14
|
}
|
|
15
|
-
exports.forwardSlash = forwardSlash;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isInsideAnotherPath =
|
|
3
|
+
exports.isInsideAnotherPath = isInsideAnotherPath;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
function isInsideAnotherPath(parent, directory) {
|
|
6
6
|
const relativePart = (0, path_1.relative)(parent, directory);
|
|
@@ -19,4 +19,3 @@ function isInsideAnotherPath(parent, directory) {
|
|
|
19
19
|
// Last option, must be subfolder.
|
|
20
20
|
return true;
|
|
21
21
|
}
|
|
22
|
-
exports.isInsideAnotherPath = isInsideAnotherPath;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.relativeToContext =
|
|
6
|
+
exports.relativeToContext = relativeToContext;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const forward_slash_1 = require("./forward-slash");
|
|
9
9
|
function relativeToContext(file, context) {
|
|
@@ -13,4 +13,3 @@ function relativeToContext(file, context) {
|
|
|
13
13
|
}
|
|
14
14
|
return fileInContext;
|
|
15
15
|
}
|
|
16
|
-
exports.relativeToContext = relativeToContext;
|
|
@@ -10,6 +10,9 @@ declare class InclusiveNodeWatchFileSystem implements WatchFileSystem {
|
|
|
10
10
|
private paused;
|
|
11
11
|
private deletedFiles;
|
|
12
12
|
constructor(watchFileSystem: WatchFileSystem, compiler: Compiler, pluginState: ForkTsCheckerWebpackPluginState);
|
|
13
|
+
private hasSupportedExtension;
|
|
14
|
+
private addChangedFile;
|
|
15
|
+
private addDeletedFile;
|
|
13
16
|
watch: WatchFileSystem['watch'];
|
|
14
17
|
}
|
|
15
18
|
export { InclusiveNodeWatchFileSystem };
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.InclusiveNodeWatchFileSystem = void 0;
|
|
7
7
|
const path_1 = require("path");
|
|
8
8
|
const chokidar_1 = __importDefault(require("chokidar"));
|
|
9
|
-
const minimatch_1 =
|
|
9
|
+
const minimatch_1 = require("minimatch");
|
|
10
10
|
const files_change_1 = require("../files-change");
|
|
11
11
|
const infrastructure_logger_1 = require("../infrastructure-logger");
|
|
12
12
|
const is_inside_another_path_1 = require("../utils/path/is-inside-another-path");
|
|
@@ -16,7 +16,7 @@ function createIsIgnored(ignored, excluded) {
|
|
|
16
16
|
const ignoredFunctions = ignoredPatterns.map((pattern) => {
|
|
17
17
|
// ensure patterns are valid - see https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/issues/594
|
|
18
18
|
if (typeof pattern === 'string') {
|
|
19
|
-
return (path) => (0, minimatch_1.
|
|
19
|
+
return (path) => (0, minimatch_1.minimatch)(path, pattern);
|
|
20
20
|
}
|
|
21
21
|
else if (pattern instanceof RegExp) {
|
|
22
22
|
return (path) => pattern.test(path);
|
|
@@ -33,134 +33,142 @@ function createIsIgnored(ignored, excluded) {
|
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
class InclusiveNodeWatchFileSystem {
|
|
36
|
+
watchFileSystem;
|
|
37
|
+
compiler;
|
|
38
|
+
pluginState;
|
|
36
39
|
get watcher() {
|
|
37
|
-
|
|
38
|
-
return this.watchFileSystem.watcher || ((_a = this.watchFileSystem.wfs) === null || _a === void 0 ? void 0 : _a.watcher);
|
|
40
|
+
return this.watchFileSystem.watcher || this.watchFileSystem.wfs?.watcher;
|
|
39
41
|
}
|
|
42
|
+
dirsWatchers;
|
|
43
|
+
paused = true;
|
|
44
|
+
deletedFiles;
|
|
40
45
|
constructor(watchFileSystem, compiler, pluginState) {
|
|
41
46
|
this.watchFileSystem = watchFileSystem;
|
|
42
47
|
this.compiler = compiler;
|
|
43
48
|
this.pluginState = pluginState;
|
|
44
|
-
this.
|
|
45
|
-
this.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
this.dirsWatchers = new Map();
|
|
50
|
+
this.deletedFiles = new Set();
|
|
51
|
+
}
|
|
52
|
+
hasSupportedExtension(file) {
|
|
53
|
+
const supportedExtensions = this.pluginState.lastDependencies?.extensions || [];
|
|
54
|
+
return supportedExtensions.includes((0, path_1.extname)(file));
|
|
55
|
+
}
|
|
56
|
+
addChangedFile(file) {
|
|
57
|
+
this.deletedFiles.delete(file);
|
|
58
|
+
(0, files_change_1.updateFilesChange)(this.compiler, { changedFiles: [file] });
|
|
59
|
+
}
|
|
60
|
+
addDeletedFile(file) {
|
|
61
|
+
this.deletedFiles.add(file);
|
|
62
|
+
(0, files_change_1.updateFilesChange)(this.compiler, { deletedFiles: [file] });
|
|
63
|
+
}
|
|
64
|
+
watch = (files, dirs, missing, startTime, options, callback, callbackUndelayed) => {
|
|
65
|
+
const { debug } = (0, infrastructure_logger_1.getInfrastructureLogger)(this.compiler);
|
|
66
|
+
(0, files_change_1.clearFilesChange)(this.compiler);
|
|
67
|
+
const isIgnored = createIsIgnored(options?.ignored, this.pluginState.lastDependencies?.excluded || []);
|
|
68
|
+
// use standard watch file system for files and missing
|
|
69
|
+
const standardWatcher = this.watchFileSystem.watch(files, dirs, missing, startTime, options, callback, callbackUndelayed);
|
|
70
|
+
this.watcher?.on('change', (file) => {
|
|
71
|
+
if (typeof file !== 'string') {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (!isIgnored(file)) {
|
|
75
|
+
debug('Detected file change', file);
|
|
76
|
+
this.addChangedFile(file);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
debug("Detected file change but it's ignored", file);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
this.watcher?.on('remove', (file) => {
|
|
83
|
+
if (typeof file !== 'string') {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (this.deletedFiles.has(file)) {
|
|
87
|
+
debug('Skipping duplicated remove event.');
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (!isIgnored(file)) {
|
|
91
|
+
debug('Detected file remove', file);
|
|
92
|
+
this.addDeletedFile(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) {
|
|
54
123
|
return;
|
|
55
124
|
}
|
|
56
|
-
if (!
|
|
57
|
-
debug('Detected file
|
|
58
|
-
|
|
59
|
-
(0, files_change_1.updateFilesChange)(this.compiler, { changedFiles: [file] });
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
debug("Detected file change but it's ignored", file);
|
|
125
|
+
if (!this.hasSupportedExtension(file)) {
|
|
126
|
+
debug('Detected new file add but extension is not supported', file);
|
|
127
|
+
return;
|
|
63
128
|
}
|
|
129
|
+
debug('Detected new file add', file);
|
|
130
|
+
this.addChangedFile(file);
|
|
131
|
+
this.watcher?._onChange(dirToWatch, stats?.mtimeMs || stats?.ctimeMs || 1, file, 'rename');
|
|
64
132
|
});
|
|
65
|
-
|
|
66
|
-
if (
|
|
133
|
+
dirWatcher.on('unlink', (file) => {
|
|
134
|
+
if (this.paused) {
|
|
67
135
|
return;
|
|
68
136
|
}
|
|
69
|
-
if (this.
|
|
70
|
-
debug('
|
|
137
|
+
if (!this.hasSupportedExtension(file)) {
|
|
138
|
+
debug('Detected new file remove but extension is not supported', file);
|
|
71
139
|
return;
|
|
72
140
|
}
|
|
73
|
-
if (
|
|
74
|
-
debug('
|
|
75
|
-
|
|
76
|
-
(0, files_change_1.updateFilesChange)(this.compiler, { deletedFiles: [file] });
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
debug("Detected file remove but it's ignored", file);
|
|
141
|
+
if (this.deletedFiles.has(file)) {
|
|
142
|
+
debug('Skipping duplicated unlink event.');
|
|
143
|
+
return;
|
|
80
144
|
}
|
|
145
|
+
debug('Detected new file remove', file);
|
|
146
|
+
this.addDeletedFile(file);
|
|
147
|
+
this.watcher?._onRemove(dirToWatch, file, 'rename');
|
|
81
148
|
});
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const interval = typeof (options === null || options === void 0 ? void 0 : options.poll) === 'number' ? options.poll : undefined;
|
|
95
|
-
const dirWatcher = chokidar_1.default.watch(dirToWatch, {
|
|
96
|
-
ignoreInitial: true,
|
|
97
|
-
ignorePermissionErrors: true,
|
|
98
|
-
ignored: (path) => isIgnored(path),
|
|
99
|
-
usePolling: (options === null || options === void 0 ? void 0 : options.poll) ? true : undefined,
|
|
100
|
-
interval: interval,
|
|
101
|
-
binaryInterval: interval,
|
|
102
|
-
alwaysStat: true,
|
|
103
|
-
atomic: true,
|
|
104
|
-
awaitWriteFinish: true,
|
|
105
|
-
});
|
|
106
|
-
dirWatcher.on('add', (file, stats) => {
|
|
107
|
-
var _a, _b;
|
|
108
|
-
if (this.paused) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
const extension = (0, path_1.extname)(file);
|
|
112
|
-
const supportedExtensions = ((_a = this.pluginState.lastDependencies) === null || _a === void 0 ? void 0 : _a.extensions) || [];
|
|
113
|
-
if (!supportedExtensions.includes(extension)) {
|
|
114
|
-
debug('Detected new file add but extension is not supported', file);
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
debug('Detected new file add', file);
|
|
118
|
-
this.deletedFiles.delete(file);
|
|
119
|
-
(0, files_change_1.updateFilesChange)(this.compiler, { changedFiles: [file] });
|
|
120
|
-
(_b = this.watcher) === null || _b === void 0 ? void 0 : _b._onChange(dirToWatch, (stats === null || stats === void 0 ? void 0 : stats.mtimeMs) || (stats === null || stats === void 0 ? void 0 : stats.ctimeMs) || 1, file, 'rename');
|
|
121
|
-
});
|
|
122
|
-
dirWatcher.on('unlink', (file) => {
|
|
123
|
-
var _a, _b;
|
|
124
|
-
if (this.paused) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
const extension = (0, path_1.extname)(file);
|
|
128
|
-
const supportedExtensions = ((_a = this.pluginState.lastDependencies) === null || _a === void 0 ? void 0 : _a.extensions) || [];
|
|
129
|
-
if (!supportedExtensions.includes(extension)) {
|
|
130
|
-
debug('Detected new file remove but extension is not supported', file);
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
if (this.deletedFiles.has(file)) {
|
|
134
|
-
debug('Skipping duplicated unlink event.');
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
debug('Detected new file remove', file);
|
|
138
|
-
this.deletedFiles.add(file);
|
|
139
|
-
(0, files_change_1.updateFilesChange)(this.compiler, { deletedFiles: [file] });
|
|
140
|
-
(_b = this.watcher) === null || _b === void 0 ? void 0 : _b._onRemove(dirToWatch, file, 'rename');
|
|
149
|
+
this.dirsWatchers.set(dirToWatch, dirWatcher);
|
|
150
|
+
});
|
|
151
|
+
this.paused = false;
|
|
152
|
+
return {
|
|
153
|
+
...standardWatcher,
|
|
154
|
+
close: () => {
|
|
155
|
+
(0, files_change_1.clearFilesChange)(this.compiler);
|
|
156
|
+
if (standardWatcher) {
|
|
157
|
+
standardWatcher.close();
|
|
158
|
+
}
|
|
159
|
+
this.dirsWatchers.forEach((dirWatcher) => {
|
|
160
|
+
dirWatcher?.close();
|
|
141
161
|
});
|
|
142
|
-
this.dirsWatchers.
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
dirWatcher === null || dirWatcher === void 0 ? void 0 : dirWatcher.close();
|
|
152
|
-
});
|
|
153
|
-
this.dirsWatchers.clear();
|
|
154
|
-
this.paused = true;
|
|
155
|
-
}, pause: () => {
|
|
156
|
-
if (standardWatcher) {
|
|
157
|
-
standardWatcher.pause();
|
|
158
|
-
}
|
|
159
|
-
this.paused = true;
|
|
160
|
-
} });
|
|
162
|
+
this.dirsWatchers.clear();
|
|
163
|
+
this.paused = true;
|
|
164
|
+
},
|
|
165
|
+
pause: () => {
|
|
166
|
+
if (standardWatcher) {
|
|
167
|
+
standardWatcher.pause();
|
|
168
|
+
}
|
|
169
|
+
this.paused = true;
|
|
170
|
+
},
|
|
161
171
|
};
|
|
162
|
-
|
|
163
|
-
this.deletedFiles = new Set();
|
|
164
|
-
}
|
|
172
|
+
};
|
|
165
173
|
}
|
|
166
174
|
exports.InclusiveNodeWatchFileSystem = InclusiveNodeWatchFileSystem;
|