fork-ts-checker-webpack-plugin 9.2.0 → 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.
Files changed (91) hide show
  1. package/README.md +23 -13
  2. package/lib/formatter/basic-formatter.js +2 -2
  3. package/lib/formatter/code-frame-formatter.d.ts +3 -2
  4. package/lib/formatter/code-frame-formatter.js +13 -3
  5. package/lib/formatter/formatter-config.js +2 -1
  6. package/lib/formatter/formatter-options.d.ts +1 -1
  7. package/lib/formatter/stats-formatter.js +3 -3
  8. package/lib/formatter/webpack-formatter.js +5 -9
  9. package/lib/hooks/report-issues.d.ts +8 -0
  10. package/lib/hooks/report-issues.js +22 -0
  11. package/lib/hooks/tap-after-compile-to-add-dependencies.js +3 -12
  12. package/lib/hooks/tap-after-compile-to-get-issues.js +6 -27
  13. package/lib/hooks/tap-done-to-async-get-issues.js +12 -32
  14. package/lib/hooks/tap-error-to-log-message.js +5 -7
  15. package/lib/hooks/tap-start-to-run-workers.js +12 -22
  16. package/lib/issue/issue-webpack-error.js +4 -11
  17. package/lib/plugin-options.json +4 -8
  18. package/lib/plugin-state.d.ts +0 -1
  19. package/lib/plugin.js +23 -23
  20. package/lib/rpc/expose-rpc.js +5 -14
  21. package/lib/rpc/rpc-error.js +2 -0
  22. package/lib/rpc/rpc-worker.d.ts +1 -1
  23. package/lib/rpc/rpc-worker.js +7 -7
  24. package/lib/rpc/wrap-rpc.js +3 -12
  25. package/lib/typescript/type-script-package.d.ts +4 -0
  26. package/lib/typescript/type-script-package.js +88 -0
  27. package/lib/typescript/type-script-support.js +8 -18
  28. package/lib/typescript/type-script-worker-config.d.ts +2 -3
  29. package/lib/typescript/type-script-worker-config.js +23 -2
  30. package/lib/typescript/type-script-worker-options.d.ts +4 -3
  31. package/lib/typescript/type-script-worker-options.js +4 -0
  32. package/lib/typescript/worker/get-dependencies-worker.js +15 -4
  33. package/lib/typescript/worker/get-issues-worker.d.ts +1 -1
  34. package/lib/typescript/worker/get-issues-worker.js +52 -64
  35. package/lib/typescript/worker/lib/api.d.ts +13 -0
  36. package/lib/typescript/worker/lib/api.js +62 -0
  37. package/lib/typescript/worker/lib/config.d.ts +13 -9
  38. package/lib/typescript/worker/lib/config.js +63 -63
  39. package/lib/typescript/worker/lib/dependencies.d.ts +6 -1
  40. package/lib/typescript/worker/lib/dependencies.js +168 -43
  41. package/lib/typescript/worker/lib/diagnostics.d.ts +5 -4
  42. package/lib/typescript/worker/lib/diagnostics.js +44 -50
  43. package/lib/typescript/worker/lib/in-memory-file-system.d.ts +14 -0
  44. package/lib/typescript/worker/lib/in-memory-file-system.js +140 -0
  45. package/lib/typescript/worker/lib/performance.d.ts +1 -2
  46. package/lib/typescript/worker/lib/performance.js +12 -19
  47. package/lib/typescript/worker/lib/program/program.d.ts +6 -2
  48. package/lib/typescript/worker/lib/program/program.js +135 -24
  49. package/lib/typescript/worker/lib/program/solution-builder.d.ts +3 -1
  50. package/lib/typescript/worker/lib/program/solution-builder.js +41 -24
  51. package/lib/typescript/worker/lib/typescript.d.ts +4 -2
  52. package/lib/typescript/worker/lib/typescript.js +69 -3
  53. package/lib/utils/async/abort-error.d.ts +0 -1
  54. package/lib/utils/async/abort-error.js +1 -1
  55. package/lib/utils/async/pool.d.ts +0 -1
  56. package/lib/utils/async/pool.js +12 -23
  57. package/lib/utils/deep-merge.d.ts +5 -0
  58. package/lib/utils/deep-merge.js +56 -0
  59. package/lib/utils/path/format-file-path.d.ts +3 -0
  60. package/lib/utils/path/format-file-path.js +15 -0
  61. package/lib/watch/inclusive-node-watch-file-system.d.ts +3 -0
  62. package/lib/watch/inclusive-node-watch-file-system.js +119 -111
  63. package/package.json +30 -38
  64. package/lib/formatter/types/babel__code-frame.d.ts +0 -21
  65. package/lib/formatter/types/babel__code-frame.js +0 -7
  66. package/lib/typescript/worker/lib/artifacts.d.ts +0 -4
  67. package/lib/typescript/worker/lib/artifacts.js +0 -103
  68. package/lib/typescript/worker/lib/emit.d.ts +0 -2
  69. package/lib/typescript/worker/lib/emit.js +0 -12
  70. package/lib/typescript/worker/lib/file-system/file-system.d.ts +0 -17
  71. package/lib/typescript/worker/lib/file-system/file-system.js +0 -2
  72. package/lib/typescript/worker/lib/file-system/mem-file-system.d.ts +0 -5
  73. package/lib/typescript/worker/lib/file-system/mem-file-system.js +0 -79
  74. package/lib/typescript/worker/lib/file-system/passive-file-system.d.ts +0 -5
  75. package/lib/typescript/worker/lib/file-system/passive-file-system.js +0 -65
  76. package/lib/typescript/worker/lib/file-system/real-file-system.d.ts +0 -5
  77. package/lib/typescript/worker/lib/file-system/real-file-system.js +0 -201
  78. package/lib/typescript/worker/lib/host/compiler-host.d.ts +0 -2
  79. package/lib/typescript/worker/lib/host/compiler-host.js +0 -9
  80. package/lib/typescript/worker/lib/host/watch-compiler-host.d.ts +0 -2
  81. package/lib/typescript/worker/lib/host/watch-compiler-host.js +0 -19
  82. package/lib/typescript/worker/lib/host/watch-solution-builder-host.d.ts +0 -2
  83. package/lib/typescript/worker/lib/host/watch-solution-builder-host.js +0 -46
  84. package/lib/typescript/worker/lib/program/watch-program.d.ts +0 -3
  85. package/lib/typescript/worker/lib/program/watch-program.js +0 -50
  86. package/lib/typescript/worker/lib/system.d.ts +0 -19
  87. package/lib/typescript/worker/lib/system.js +0 -232
  88. package/lib/typescript/worker/lib/tracing.d.ts +0 -4
  89. package/lib/typescript/worker/lib/tracing.js +0 -28
  90. package/lib/typescript/worker/lib/tsbuildinfo.d.ts +0 -4
  91. package/lib/typescript/worker/lib/tsbuildinfo.js +0 -105
@@ -1,36 +1,147 @@
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
36
  exports.useProgram = useProgram;
4
- exports.invalidateProgram = invalidateProgram;
37
+ exports.invalidateProgramConfig = invalidateProgramConfig;
38
+ exports.invalidateProgramRootFileNames = invalidateProgramRootFileNames;
39
+ exports.resetProgram = resetProgram;
40
+ const fs = __importStar(require("fs"));
41
+ const path = __importStar(require("path"));
42
+ const api_1 = require("../api");
5
43
  const config_1 = require("../config");
6
44
  const diagnostics_1 = require("../diagnostics");
7
- const emit_1 = require("../emit");
8
- const compiler_host_1 = require("../host/compiler-host");
9
- const tracing_1 = require("../tracing");
10
45
  const typescript_1 = require("../typescript");
11
- let compilerHost;
12
- let program;
13
- function useProgram() {
46
+ const worker_config_1 = require("../worker-config");
47
+ let snapshot;
48
+ let programId;
49
+ let didRootFileNamesChange = false;
50
+ let didConfigChange = false;
51
+ function getProgramParams() {
14
52
  const parsedConfig = (0, config_1.getParsedConfig)();
15
- if (!compilerHost) {
16
- compilerHost = (0, compiler_host_1.createCompilerHost)(parsedConfig);
17
- }
18
- if (!program) {
19
- (0, tracing_1.startTracingIfNeeded)(parsedConfig.options);
20
- program = typescript_1.typescript.createProgram({
21
- rootNames: parsedConfig.fileNames,
22
- options: parsedConfig.options,
53
+ return {
54
+ rootFiles: parsedConfig.fileNames,
55
+ compilerOptions: parsedConfig.options,
56
+ options: {
23
57
  projectReferences: parsedConfig.projectReferences,
24
- host: compilerHost,
25
- });
58
+ },
59
+ };
60
+ }
61
+ function getFileNotifications({ changedFiles = [], deletedFiles = [], }) {
62
+ if (changedFiles.length === 0 && deletedFiles.length === 0) {
63
+ return undefined;
64
+ }
65
+ // webpack's watcher doesn't distinguish created from changed files
66
+ return {
67
+ changed: changedFiles.map((file) => path.resolve(file)),
68
+ deleted: deletedFiles.map((file) => path.resolve(file)),
69
+ };
70
+ }
71
+ function updateSnapshot(params) {
72
+ const previousSnapshot = snapshot;
73
+ // each snapshot must be derived from the previous one to keep the API's cache
74
+ const nextSnapshot = previousSnapshot
75
+ ? previousSnapshot.update(params)
76
+ : (0, api_1.getApi)().createSnapshot(params);
77
+ previousSnapshot?.dispose();
78
+ snapshot = nextSnapshot;
79
+ return nextSnapshot;
80
+ }
81
+ /**
82
+ * Writes the program's .d.ts files, skipping unchanged ones: the program re-emits
83
+ * every file each time, and rewriting them all would trigger more watch events.
84
+ */
85
+ function emitDeclarations(program) {
86
+ // `configOverwrite` can turn `emitDeclarationOnly` off, so don't rely on it
87
+ const { diagnostics, outputFiles } = program.emitToString(typescript_1.typescriptSync.EmitOnly.OnlyDts);
88
+ for (const [fileName, { text }] of outputFiles) {
89
+ let previousText;
90
+ try {
91
+ previousText = fs.readFileSync(fileName, 'utf8');
92
+ }
93
+ catch (error) {
94
+ // not written yet
95
+ }
96
+ if (previousText !== text) {
97
+ fs.mkdirSync(path.dirname(fileName), { recursive: true });
98
+ fs.writeFileSync(fileName, text);
99
+ }
26
100
  }
27
- (0, diagnostics_1.updateDiagnostics)((0, config_1.getConfigFilePathFromProgram)(program), (0, diagnostics_1.getDiagnosticsOfProgram)(program));
28
- (0, emit_1.emitDtsIfNeeded)(program);
29
- (0, tracing_1.stopTracingIfNeeded)(program);
101
+ return diagnostics;
30
102
  }
31
- function invalidateProgram(withHost = false) {
32
- if (withHost) {
33
- compilerHost = undefined;
103
+ function useProgram(change) {
104
+ const fileNotifications = getFileNotifications(change);
105
+ if (programId === undefined) {
106
+ const nextSnapshot = updateSnapshot({ createPrograms: [getProgramParams()] });
107
+ programId = nextSnapshot.operation.createdPrograms[0].id;
34
108
  }
35
- program = undefined;
109
+ else {
110
+ updateSnapshot({
111
+ // a config change can affect how any file is read, so start afresh
112
+ fileNotifications: didConfigChange ? { invalidateAll: true } : fileNotifications,
113
+ // reconfigure in place: `removePrograms` + `createPrograms` in a single
114
+ // update crashes the 7.1 beta compiler process
115
+ reconfigurePrograms: didRootFileNamesChange || didConfigChange
116
+ ? [{ id: programId, ...getProgramParams() }]
117
+ : undefined,
118
+ // without it, a synthetic program keeps the old contents of changed files
119
+ ensurePrograms: true,
120
+ });
121
+ }
122
+ didRootFileNamesChange = false;
123
+ didConfigChange = false;
124
+ const program = snapshot?.getProgram(programId);
125
+ if (!program) {
126
+ throw new Error('TypeScript program is missing from the snapshot.');
127
+ }
128
+ const diagnostics = (0, diagnostics_1.getDiagnosticsOfProgram)(program);
129
+ // `configOverwrite` can turn `declaration` off, as with `tsc`
130
+ if (worker_config_1.config.mode === 'write' && (0, config_1.getParsedConfig)().options.declaration) {
131
+ diagnostics.push(...emitDeclarations(program));
132
+ }
133
+ (0, diagnostics_1.updateDiagnostics)(worker_config_1.config.configFile, diagnostics);
134
+ }
135
+ function invalidateProgramConfig() {
136
+ didConfigChange = true;
137
+ }
138
+ function invalidateProgramRootFileNames() {
139
+ didRootFileNamesChange = true;
140
+ }
141
+ /** Forgets the program without talking to the compiler, which may be gone. */
142
+ function resetProgram() {
143
+ snapshot = undefined;
144
+ programId = undefined;
145
+ didRootFileNamesChange = false;
146
+ didConfigChange = false;
36
147
  }
@@ -1,2 +1,4 @@
1
1
  export declare function useSolutionBuilder(): void;
2
- export declare function invalidateSolutionBuilder(withHost?: boolean): void;
2
+ export declare function invalidateSolutionBuilder(): void;
3
+ /** Forgets the orchestrator without talking to the compiler, which may be gone. */
4
+ export declare function resetSolutionBuilder(): void;
@@ -2,37 +2,54 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useSolutionBuilder = useSolutionBuilder;
4
4
  exports.invalidateSolutionBuilder = invalidateSolutionBuilder;
5
+ exports.resetSolutionBuilder = resetSolutionBuilder;
6
+ const api_1 = require("../api");
5
7
  const config_1 = require("../config");
6
8
  const diagnostics_1 = require("../diagnostics");
7
- const watch_solution_builder_host_1 = require("../host/watch-solution-builder-host");
8
- const tracing_1 = require("../tracing");
9
- const tsbuildinfo_1 = require("../tsbuildinfo");
10
- const typescript_1 = require("../typescript");
11
9
  const worker_config_1 = require("../worker-config");
12
- let solutionBuilderHost;
10
+ const OVERRIDABLE_COMPILER_OPTIONS = [
11
+ 'incremental',
12
+ 'assumeChangesOnlyAffectDirectDependencies',
13
+ 'declaration',
14
+ 'declarationMap',
15
+ 'emitDeclarationOnly',
16
+ 'sourceMap',
17
+ 'inlineSourceMap',
18
+ 'traceResolution',
19
+ ];
20
+ /**
21
+ * The build orchestrator reads each project's tsconfig.json from disk and only
22
+ * accepts this small set of overrides, so the rest of `configOverwrite` can't apply.
23
+ */
24
+ function getOverrideCompilerOptions() {
25
+ const userCompilerOptions = worker_config_1.config.configOverwrite?.compilerOptions || {};
26
+ const overrides = (0, config_1.getSharedImplicitCompilerOptions)();
27
+ for (const option of OVERRIDABLE_COMPILER_OPTIONS) {
28
+ if (option in userCompilerOptions) {
29
+ overrides[option] = userCompilerOptions[option];
30
+ }
31
+ }
32
+ return overrides;
33
+ }
13
34
  let solutionBuilder;
14
35
  function useSolutionBuilder() {
15
- if (!solutionBuilderHost) {
16
- const parsedConfig = (0, config_1.getParsedConfig)();
17
- solutionBuilderHost = (0, watch_solution_builder_host_1.createWatchSolutionBuilderHost)(parsedConfig, (rootNames, compilerOptions, host, oldProgram, configFileParsingDiagnostics, projectReferences) => {
18
- if (compilerOptions) {
19
- (0, tracing_1.startTracingIfNeeded)(compilerOptions);
20
- }
21
- return typescript_1.typescript.createSemanticDiagnosticsBuilderProgram(rootNames, compilerOptions, host, oldProgram, configFileParsingDiagnostics, projectReferences);
22
- }, undefined, undefined, undefined, undefined, (builderProgram) => {
23
- (0, diagnostics_1.updateDiagnostics)((0, config_1.getConfigFilePathFromBuilderProgram)(builderProgram), (0, diagnostics_1.getDiagnosticsOfProgram)(builderProgram));
24
- (0, tsbuildinfo_1.emitTsBuildInfoIfNeeded)(builderProgram);
25
- (0, tracing_1.stopTracingIfNeeded)(builderProgram);
26
- });
27
- }
28
36
  if (!solutionBuilder) {
29
- solutionBuilder = typescript_1.typescript.createSolutionBuilderWithWatch(solutionBuilderHost, [worker_config_1.config.configFile], { watch: true });
30
- solutionBuilder.build();
37
+ solutionBuilder = (0, api_1.createBuildOrchestrator)([worker_config_1.config.configFile], {
38
+ cwd: worker_config_1.config.context,
39
+ overrideCompilerOptions: getOverrideCompilerOptions(),
40
+ });
31
41
  }
42
+ // the orchestrator checks the file system for changes itself, but a
43
+ // `yarn install` can relink workspace packages between builds
44
+ (0, api_1.invalidateRealDirectories)();
45
+ const result = solutionBuilder.build();
46
+ (0, diagnostics_1.updateDiagnostics)(worker_config_1.config.configFile, result.diagnostics || []);
32
47
  }
33
- function invalidateSolutionBuilder(withHost = false) {
34
- if (withHost) {
35
- solutionBuilderHost = undefined;
36
- }
48
+ function invalidateSolutionBuilder() {
49
+ solutionBuilder?.dispose();
50
+ solutionBuilder = undefined;
51
+ }
52
+ /** Forgets the orchestrator without talking to the compiler, which may be gone. */
53
+ function resetSolutionBuilder() {
37
54
  solutionBuilder = undefined;
38
55
  }
@@ -1,2 +1,4 @@
1
- import type * as ts from 'typescript';
2
- export declare const typescript: typeof ts;
1
+ import type * as TypeScriptFs from 'typescript/fs';
2
+ import type * as TypeScriptSync from 'typescript/sync';
3
+ export declare const typescriptSync: typeof TypeScriptSync;
4
+ export declare const typescriptFs: typeof TypeScriptFs;
@@ -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.typescript = void 0;
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
- // eslint-disable-next-line
6
- exports.typescript = require(worker_config_1.config.typescriptPath);
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,4 +1,3 @@
1
- import type { AbortSignal } from 'node-abort-controller';
2
1
  declare class AbortError extends Error {
3
2
  constructor(message?: string);
4
3
  static throwIfAborted(signal: AbortSignal | undefined): void;
@@ -7,7 +7,7 @@ class AbortError extends Error {
7
7
  this.name = 'AbortError';
8
8
  }
9
9
  static throwIfAborted(signal) {
10
- if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
10
+ if (signal?.aborted) {
11
11
  throw new AbortError();
12
12
  }
13
13
  }
@@ -1,4 +1,3 @@
1
- import type { AbortSignal } from 'node-abort-controller';
2
1
  type Task<T> = (signal?: AbortSignal) => Promise<T>;
3
2
  interface Pool {
4
3
  submit<T>(task: Task<T>, signal?: AbortSignal): Promise<T>;
@@ -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
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
- return __awaiter(this, void 0, void 0, function* () {
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
- const taskPromise = task(signal).finally(() => {
25
- pendingPromises = pendingPromises.filter((pendingPromise) => pendingPromise !== taskPromise);
26
- });
27
- pendingPromises.push(taskPromise);
28
- return taskPromise;
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,12 +23,12 @@ function createPool(size) {
34
23
  },
35
24
  get drained() {
36
25
  // eslint-disable-next-line no-async-promise-executor
37
- return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
26
+ return new Promise(async (resolve) => {
38
27
  while (pendingPromises.length > 0) {
39
- yield Promise.race(pendingPromises).catch(() => undefined);
28
+ await Promise.race(pendingPromises).catch(() => undefined);
40
29
  }
41
30
  resolve(undefined);
42
- }));
31
+ });
43
32
  },
44
33
  };
45
34
  return pool;
@@ -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,3 @@
1
+ /** The file path as shown in issues: absolute, or relative to the current working directory. */
2
+ declare function formatFilePath(file: string, pathType: 'relative' | 'absolute'): string;
3
+ export { formatFilePath };
@@ -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
+ }
@@ -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 };