@depup/fork-ts-checker-webpack-plugin 9.1.0-depup.0

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 (169) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +42 -0
  3. package/changes.json +54 -0
  4. package/lib/files-change.d.ts +17 -0
  5. package/lib/files-change.js +57 -0
  6. package/lib/files-match.d.ts +7 -0
  7. package/lib/files-match.js +2 -0
  8. package/lib/formatter/basic-formatter.d.ts +3 -0
  9. package/lib/formatter/basic-formatter.js +13 -0
  10. package/lib/formatter/code-frame-formatter.d.ts +4 -0
  11. package/lib/formatter/code-frame-formatter.js +29 -0
  12. package/lib/formatter/formatter-config.d.ts +8 -0
  13. package/lib/formatter/formatter-config.js +36 -0
  14. package/lib/formatter/formatter-options.d.ts +14 -0
  15. package/lib/formatter/formatter-options.js +2 -0
  16. package/lib/formatter/formatter.d.ts +4 -0
  17. package/lib/formatter/formatter.js +2 -0
  18. package/lib/formatter/index.d.ts +6 -0
  19. package/lib/formatter/index.js +22 -0
  20. package/lib/formatter/stats-formatter.d.ts +3 -0
  21. package/lib/formatter/stats-formatter.js +28 -0
  22. package/lib/formatter/types/babel__code-frame.d.ts +21 -0
  23. package/lib/formatter/types/babel__code-frame.js +7 -0
  24. package/lib/formatter/webpack-formatter.d.ts +3 -0
  25. package/lib/formatter/webpack-formatter.js +32 -0
  26. package/lib/hooks/intercept-done-to-get-dev-server-tap.d.ts +5 -0
  27. package/lib/hooks/intercept-done-to-get-dev-server-tap.js +18 -0
  28. package/lib/hooks/tap-after-compile-to-add-dependencies.d.ts +5 -0
  29. package/lib/hooks/tap-after-compile-to-add-dependencies.js +31 -0
  30. package/lib/hooks/tap-after-compile-to-get-issues.d.ts +5 -0
  31. package/lib/hooks/tap-after-compile-to-get-issues.js +52 -0
  32. package/lib/hooks/tap-after-environment-to-patch-watching.d.ts +4 -0
  33. package/lib/hooks/tap-after-environment-to-patch-watching.js +22 -0
  34. package/lib/hooks/tap-done-to-async-get-issues.d.ts +5 -0
  35. package/lib/hooks/tap-done-to-async-get-issues.js +86 -0
  36. package/lib/hooks/tap-error-to-log-message.d.ts +4 -0
  37. package/lib/hooks/tap-error-to-log-message.js +32 -0
  38. package/lib/hooks/tap-start-to-run-workers.d.ts +8 -0
  39. package/lib/hooks/tap-start-to-run-workers.js +132 -0
  40. package/lib/hooks/tap-stop-to-terminate-workers.d.ts +5 -0
  41. package/lib/hooks/tap-stop-to-terminate-workers.js +26 -0
  42. package/lib/index.d.ts +2 -0
  43. package/lib/index.js +3 -0
  44. package/lib/infrastructure-logger.d.ts +9 -0
  45. package/lib/infrastructure-logger.js +14 -0
  46. package/lib/issue/index.d.ts +3 -0
  47. package/lib/issue/index.js +19 -0
  48. package/lib/issue/issue-config.d.ts +8 -0
  49. package/lib/issue/issue-config.js +29 -0
  50. package/lib/issue/issue-location.d.ts +8 -0
  51. package/lib/issue/issue-location.js +22 -0
  52. package/lib/issue/issue-match.d.ts +5 -0
  53. package/lib/issue/issue-match.js +20 -0
  54. package/lib/issue/issue-options.d.ts +8 -0
  55. package/lib/issue/issue-options.js +2 -0
  56. package/lib/issue/issue-position.d.ts +6 -0
  57. package/lib/issue/issue-position.js +16 -0
  58. package/lib/issue/issue-predicate.d.ts +5 -0
  59. package/lib/issue/issue-predicate.js +11 -0
  60. package/lib/issue/issue-severity.d.ts +4 -0
  61. package/lib/issue/issue-severity.js +12 -0
  62. package/lib/issue/issue-webpack-error.d.ts +9 -0
  63. package/lib/issue/issue-webpack-error.js +55 -0
  64. package/lib/issue/issue.d.ts +12 -0
  65. package/lib/issue/issue.js +41 -0
  66. package/lib/logger.d.ts +5 -0
  67. package/lib/logger.js +2 -0
  68. package/lib/plugin-config.d.ts +16 -0
  69. package/lib/plugin-config.js +26 -0
  70. package/lib/plugin-hooks.d.ts +20 -0
  71. package/lib/plugin-hooks.js +45 -0
  72. package/lib/plugin-options.d.ts +13 -0
  73. package/lib/plugin-options.js +2 -0
  74. package/lib/plugin-options.json +197 -0
  75. package/lib/plugin-pools.d.ts +4 -0
  76. package/lib/plugin-pools.js +32 -0
  77. package/lib/plugin-state.d.ts +18 -0
  78. package/lib/plugin-state.js +17 -0
  79. package/lib/plugin.d.ts +28 -0
  80. package/lib/plugin.js +86 -0
  81. package/lib/rpc/expose-rpc.d.ts +1 -0
  82. package/lib/rpc/expose-rpc.js +78 -0
  83. package/lib/rpc/index.d.ts +5 -0
  84. package/lib/rpc/index.js +12 -0
  85. package/lib/rpc/rpc-error.d.ts +6 -0
  86. package/lib/rpc/rpc-error.js +12 -0
  87. package/lib/rpc/rpc-worker.d.ts +13 -0
  88. package/lib/rpc/rpc-worker.js +83 -0
  89. package/lib/rpc/types.d.ts +19 -0
  90. package/lib/rpc/types.js +2 -0
  91. package/lib/rpc/wrap-rpc.d.ts +4 -0
  92. package/lib/rpc/wrap-rpc.js +79 -0
  93. package/lib/typescript/type-script-config-overwrite.d.ts +12 -0
  94. package/lib/typescript/type-script-config-overwrite.js +2 -0
  95. package/lib/typescript/type-script-diagnostics-options.d.ts +7 -0
  96. package/lib/typescript/type-script-diagnostics-options.js +2 -0
  97. package/lib/typescript/type-script-support.d.ts +3 -0
  98. package/lib/typescript/type-script-support.js +67 -0
  99. package/lib/typescript/type-script-worker-config.d.ts +17 -0
  100. package/lib/typescript/type-script-worker-config.js +18 -0
  101. package/lib/typescript/type-script-worker-options.d.ts +14 -0
  102. package/lib/typescript/type-script-worker-options.js +2 -0
  103. package/lib/typescript/worker/get-dependencies-worker.d.ts +5 -0
  104. package/lib/typescript/worker/get-dependencies-worker.js +15 -0
  105. package/lib/typescript/worker/get-issues-worker.d.ts +5 -0
  106. package/lib/typescript/worker/get-issues-worker.js +80 -0
  107. package/lib/typescript/worker/lib/artifacts.d.ts +4 -0
  108. package/lib/typescript/worker/lib/artifacts.js +94 -0
  109. package/lib/typescript/worker/lib/config.d.ts +15 -0
  110. package/lib/typescript/worker/lib/config.js +135 -0
  111. package/lib/typescript/worker/lib/dependencies.d.ts +3 -0
  112. package/lib/typescript/worker/lib/dependencies.js +85 -0
  113. package/lib/typescript/worker/lib/diagnostics.d.ts +7 -0
  114. package/lib/typescript/worker/lib/diagnostics.js +112 -0
  115. package/lib/typescript/worker/lib/emit.d.ts +2 -0
  116. package/lib/typescript/worker/lib/emit.js +13 -0
  117. package/lib/typescript/worker/lib/file-system/file-system.d.ts +18 -0
  118. package/lib/typescript/worker/lib/file-system/file-system.js +2 -0
  119. package/lib/typescript/worker/lib/file-system/mem-file-system.d.ts +5 -0
  120. package/lib/typescript/worker/lib/file-system/mem-file-system.js +78 -0
  121. package/lib/typescript/worker/lib/file-system/passive-file-system.d.ts +5 -0
  122. package/lib/typescript/worker/lib/file-system/passive-file-system.js +65 -0
  123. package/lib/typescript/worker/lib/file-system/real-file-system.d.ts +5 -0
  124. package/lib/typescript/worker/lib/file-system/real-file-system.js +191 -0
  125. package/lib/typescript/worker/lib/host/compiler-host.d.ts +2 -0
  126. package/lib/typescript/worker/lib/host/compiler-host.js +10 -0
  127. package/lib/typescript/worker/lib/host/watch-compiler-host.d.ts +2 -0
  128. package/lib/typescript/worker/lib/host/watch-compiler-host.js +20 -0
  129. package/lib/typescript/worker/lib/host/watch-solution-builder-host.d.ts +2 -0
  130. package/lib/typescript/worker/lib/host/watch-solution-builder-host.js +47 -0
  131. package/lib/typescript/worker/lib/performance.d.ts +3 -0
  132. package/lib/typescript/worker/lib/performance.js +32 -0
  133. package/lib/typescript/worker/lib/program/program.d.ts +2 -0
  134. package/lib/typescript/worker/lib/program/program.js +37 -0
  135. package/lib/typescript/worker/lib/program/solution-builder.d.ts +2 -0
  136. package/lib/typescript/worker/lib/program/solution-builder.js +39 -0
  137. package/lib/typescript/worker/lib/program/watch-program.d.ts +3 -0
  138. package/lib/typescript/worker/lib/program/watch-program.js +51 -0
  139. package/lib/typescript/worker/lib/system.d.ts +19 -0
  140. package/lib/typescript/worker/lib/system.js +232 -0
  141. package/lib/typescript/worker/lib/tracing.d.ts +4 -0
  142. package/lib/typescript/worker/lib/tracing.js +29 -0
  143. package/lib/typescript/worker/lib/tsbuildinfo.d.ts +4 -0
  144. package/lib/typescript/worker/lib/tsbuildinfo.js +96 -0
  145. package/lib/typescript/worker/lib/typescript.d.ts +2 -0
  146. package/lib/typescript/worker/lib/typescript.js +6 -0
  147. package/lib/typescript/worker/lib/worker-config.d.ts +2 -0
  148. package/lib/typescript/worker/lib/worker-config.js +5 -0
  149. package/lib/utils/async/abort-error.d.ts +6 -0
  150. package/lib/utils/async/abort-error.js +15 -0
  151. package/lib/utils/async/controlled-promise.d.ts +6 -0
  152. package/lib/utils/async/controlled-promise.js +17 -0
  153. package/lib/utils/async/is-pending.d.ts +2 -0
  154. package/lib/utils/async/is-pending.js +10 -0
  155. package/lib/utils/async/pool.d.ts +10 -0
  156. package/lib/utils/async/pool.js +47 -0
  157. package/lib/utils/async/wait.d.ts +2 -0
  158. package/lib/utils/async/wait.js +7 -0
  159. package/lib/utils/path/forward-slash.d.ts +6 -0
  160. package/lib/utils/path/forward-slash.js +15 -0
  161. package/lib/utils/path/is-inside-another-path.d.ts +2 -0
  162. package/lib/utils/path/is-inside-another-path.js +22 -0
  163. package/lib/utils/path/relative-to-context.d.ts +2 -0
  164. package/lib/utils/path/relative-to-context.js +16 -0
  165. package/lib/watch/inclusive-node-watch-file-system.d.ts +15 -0
  166. package/lib/watch/inclusive-node-watch-file-system.js +166 -0
  167. package/lib/watch/watch-file-system.d.ts +16 -0
  168. package/lib/watch/watch-file-system.js +2 -0
  169. package/package.json +182 -0
@@ -0,0 +1,135 @@
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.didRootFilesChanged = exports.didDependenciesProbablyChanged = exports.didConfigFileChanged = exports.getConfigFilePathFromBuilderProgram = exports.getConfigFilePathFromProgram = exports.getConfigFilePathFromCompilerOptions = exports.invalidateConfig = exports.parseNextConfig = exports.getParsedConfig = exports.getParseConfigIssues = exports.parseConfig = void 0;
27
+ const path = __importStar(require("path"));
28
+ const forward_slash_1 = require("../../../utils/path/forward-slash");
29
+ const diagnostics_1 = require("./diagnostics");
30
+ const system_1 = require("./system");
31
+ const typescript_1 = require("./typescript");
32
+ const worker_config_1 = require("./worker-config");
33
+ let parsedConfig;
34
+ let parseConfigDiagnostics = [];
35
+ // initialize ParseConfigFileHost
36
+ const parseConfigFileHost = Object.assign(Object.assign({}, system_1.system), { onUnRecoverableConfigFileDiagnostic: (diagnostic) => {
37
+ parseConfigDiagnostics.push(diagnostic);
38
+ } });
39
+ function getUserProvidedConfigOverwrite() {
40
+ return worker_config_1.config.configOverwrite || {};
41
+ }
42
+ function getImplicitConfigOverwrite() {
43
+ const baseCompilerOptionsOverwrite = {
44
+ skipLibCheck: true,
45
+ sourceMap: false,
46
+ inlineSourceMap: false,
47
+ };
48
+ switch (worker_config_1.config.mode) {
49
+ case 'write-dts':
50
+ return {
51
+ compilerOptions: Object.assign(Object.assign({}, baseCompilerOptionsOverwrite), { declaration: true, emitDeclarationOnly: true, noEmit: false }),
52
+ };
53
+ case 'write-tsbuildinfo':
54
+ case 'write-references':
55
+ return {
56
+ compilerOptions: Object.assign(Object.assign({}, baseCompilerOptionsOverwrite), { declaration: true, emitDeclarationOnly: false, noEmit: false }),
57
+ };
58
+ }
59
+ return {
60
+ compilerOptions: baseCompilerOptionsOverwrite,
61
+ };
62
+ }
63
+ function applyConfigOverwrite(baseConfig, ...overwriteConfigs) {
64
+ let config = baseConfig;
65
+ for (const overwriteConfig of overwriteConfigs) {
66
+ config = Object.assign(Object.assign(Object.assign({}, (config || {})), (overwriteConfig || {})), { compilerOptions: Object.assign(Object.assign({}, ((config === null || config === void 0 ? void 0 : config.compilerOptions) || {})), ((overwriteConfig === null || overwriteConfig === void 0 ? void 0 : overwriteConfig.compilerOptions) || {})) });
67
+ }
68
+ return config;
69
+ }
70
+ function parseConfig(configFileName, configFileContext) {
71
+ const configFilePath = (0, forward_slash_1.forwardSlash)(configFileName);
72
+ const { config: baseConfig, error: readConfigError } = typescript_1.typescript.readConfigFile(configFilePath, parseConfigFileHost.readFile);
73
+ const overwrittenConfig = applyConfigOverwrite(baseConfig || {}, getImplicitConfigOverwrite(), getUserProvidedConfigOverwrite());
74
+ const parsedConfigFile = typescript_1.typescript.parseJsonConfigFileContent(overwrittenConfig, parseConfigFileHost, configFileContext);
75
+ return Object.assign(Object.assign({}, parsedConfigFile), { options: Object.assign(Object.assign({}, parsedConfigFile.options), { configFilePath: configFilePath }), errors: readConfigError ? [readConfigError] : parsedConfigFile.errors });
76
+ }
77
+ exports.parseConfig = parseConfig;
78
+ function getParseConfigIssues() {
79
+ const issues = (0, diagnostics_1.createIssuesFromDiagnostics)(parseConfigDiagnostics);
80
+ issues.forEach((issue) => {
81
+ if (!issue.file) {
82
+ issue.file = worker_config_1.config.configFile;
83
+ }
84
+ });
85
+ return issues;
86
+ }
87
+ exports.getParseConfigIssues = getParseConfigIssues;
88
+ function getParsedConfig(force = false) {
89
+ if (!parsedConfig || force) {
90
+ parsedConfig = parseConfig(worker_config_1.config.configFile, worker_config_1.config.context);
91
+ parseConfigDiagnostics = parsedConfig.errors || [];
92
+ }
93
+ return parsedConfig;
94
+ }
95
+ exports.getParsedConfig = getParsedConfig;
96
+ function parseNextConfig() {
97
+ const prevParsedConfig = parsedConfig;
98
+ const nextParsedConfig = getParsedConfig(true);
99
+ return [prevParsedConfig, nextParsedConfig];
100
+ }
101
+ exports.parseNextConfig = parseNextConfig;
102
+ function invalidateConfig() {
103
+ parsedConfig = undefined;
104
+ parseConfigDiagnostics = [];
105
+ }
106
+ exports.invalidateConfig = invalidateConfig;
107
+ function getConfigFilePathFromCompilerOptions(compilerOptions) {
108
+ return compilerOptions.configFilePath;
109
+ }
110
+ exports.getConfigFilePathFromCompilerOptions = getConfigFilePathFromCompilerOptions;
111
+ function getConfigFilePathFromProgram(program) {
112
+ return getConfigFilePathFromCompilerOptions(program.getCompilerOptions());
113
+ }
114
+ exports.getConfigFilePathFromProgram = getConfigFilePathFromProgram;
115
+ function getConfigFilePathFromBuilderProgram(builderProgram) {
116
+ return getConfigFilePathFromCompilerOptions(builderProgram.getProgram().getCompilerOptions());
117
+ }
118
+ exports.getConfigFilePathFromBuilderProgram = getConfigFilePathFromBuilderProgram;
119
+ function didConfigFileChanged({ changedFiles = [], deletedFiles = [] }) {
120
+ return [...changedFiles, ...deletedFiles]
121
+ .map((file) => path.normalize(file))
122
+ .includes(path.normalize(worker_config_1.config.configFile));
123
+ }
124
+ exports.didConfigFileChanged = didConfigFileChanged;
125
+ function didDependenciesProbablyChanged(dependencies, { changedFiles = [], deletedFiles = [] }) {
126
+ const didSomeDependencyHasBeenAdded = changedFiles.some((changeFile) => !dependencies.files.includes(changeFile));
127
+ const didSomeDependencyHasBeenDeleted = deletedFiles.some((deletedFile) => dependencies.files.includes(deletedFile));
128
+ return didSomeDependencyHasBeenAdded || didSomeDependencyHasBeenDeleted;
129
+ }
130
+ exports.didDependenciesProbablyChanged = didDependenciesProbablyChanged;
131
+ function didRootFilesChanged() {
132
+ const [prevConfig, nextConfig] = parseNextConfig();
133
+ return (prevConfig && JSON.stringify(prevConfig.fileNames) !== JSON.stringify(nextConfig.fileNames));
134
+ }
135
+ exports.didRootFilesChanged = didRootFilesChanged;
@@ -0,0 +1,3 @@
1
+ import type { FilesMatch } from '../../../files-match';
2
+ export declare function getDependencies(force?: boolean): FilesMatch;
3
+ export declare function invalidateDependencies(): void;
@@ -0,0 +1,85 @@
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.invalidateDependencies = exports.getDependencies = void 0;
27
+ const path = __importStar(require("path"));
28
+ const config_1 = require("./config");
29
+ const typescript_1 = require("./typescript");
30
+ const worker_config_1 = require("./worker-config");
31
+ let dependencies;
32
+ function getDependencies(force = false) {
33
+ if (!dependencies || force) {
34
+ const parsedConfig = (0, config_1.getParsedConfig)();
35
+ dependencies = getDependenciesWorker(parsedConfig, worker_config_1.config.context);
36
+ }
37
+ return dependencies;
38
+ }
39
+ exports.getDependencies = getDependencies;
40
+ function invalidateDependencies() {
41
+ dependencies = undefined;
42
+ }
43
+ exports.invalidateDependencies = invalidateDependencies;
44
+ function getDependenciesWorker(parsedConfig, configFileContext, processedConfigFiles = []) {
45
+ var _a;
46
+ const files = new Set(parsedConfig.fileNames);
47
+ const configFilePath = parsedConfig.options.configFilePath;
48
+ if (typeof configFilePath === 'string') {
49
+ files.add(configFilePath);
50
+ }
51
+ const dirs = new Set(Object.keys(parsedConfig.wildcardDirectories || {}));
52
+ const excluded = new Set((((_a = parsedConfig.raw) === null || _a === void 0 ? void 0 : _a.exclude) || []).map((filePath) => path.resolve(configFileContext, filePath)));
53
+ for (const projectReference of parsedConfig.projectReferences || []) {
54
+ const childConfigFilePath = typescript_1.typescript.resolveProjectReferencePath(projectReference);
55
+ const childConfigContext = path.dirname(childConfigFilePath);
56
+ if (processedConfigFiles.includes(childConfigFilePath)) {
57
+ // handle circular dependencies
58
+ continue;
59
+ }
60
+ const childParsedConfig = (0, config_1.parseConfig)(childConfigFilePath, childConfigContext);
61
+ const childDependencies = getDependenciesWorker(childParsedConfig, childConfigContext, [
62
+ ...processedConfigFiles,
63
+ childConfigFilePath,
64
+ ]);
65
+ childDependencies.files.forEach((file) => {
66
+ files.add(file);
67
+ });
68
+ childDependencies.dirs.forEach((dir) => {
69
+ dirs.add(dir);
70
+ });
71
+ }
72
+ const extensions = [
73
+ typescript_1.typescript.Extension.Ts,
74
+ typescript_1.typescript.Extension.Tsx,
75
+ typescript_1.typescript.Extension.Js,
76
+ typescript_1.typescript.Extension.Jsx,
77
+ typescript_1.typescript.Extension.TsBuildInfo,
78
+ ];
79
+ return {
80
+ files: Array.from(files).map((file) => path.normalize(file)),
81
+ dirs: Array.from(dirs).map((dir) => path.normalize(dir)),
82
+ excluded: Array.from(excluded).map((aPath) => path.normalize(aPath)),
83
+ extensions: extensions,
84
+ };
85
+ }
@@ -0,0 +1,7 @@
1
+ import type * as ts from 'typescript';
2
+ import type { Issue } from '../../../issue';
3
+ export declare function updateDiagnostics(configFile: string, diagnostics: ts.Diagnostic[]): void;
4
+ export declare function getIssues(): Issue[];
5
+ export declare function invalidateDiagnostics(): void;
6
+ export declare function getDiagnosticsOfProgram(program: ts.Program | ts.BuilderProgram): ts.Diagnostic[];
7
+ export declare function createIssuesFromDiagnostics(diagnostics: ts.Diagnostic[]): Issue[];
@@ -0,0 +1,112 @@
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.createIssuesFromDiagnostics = exports.getDiagnosticsOfProgram = exports.invalidateDiagnostics = exports.getIssues = exports.updateDiagnostics = void 0;
27
+ const os = __importStar(require("os"));
28
+ const issue_1 = require("../../../issue");
29
+ const typescript_1 = require("./typescript");
30
+ const worker_config_1 = require("./worker-config");
31
+ const diagnosticsPerConfigFile = new Map();
32
+ function updateDiagnostics(configFile, diagnostics) {
33
+ diagnosticsPerConfigFile.set(configFile, diagnostics);
34
+ }
35
+ exports.updateDiagnostics = updateDiagnostics;
36
+ function getIssues() {
37
+ const allDiagnostics = [];
38
+ diagnosticsPerConfigFile.forEach((diagnostics) => {
39
+ allDiagnostics.push(...diagnostics);
40
+ });
41
+ return createIssuesFromDiagnostics(allDiagnostics);
42
+ }
43
+ exports.getIssues = getIssues;
44
+ function invalidateDiagnostics() {
45
+ diagnosticsPerConfigFile.clear();
46
+ }
47
+ exports.invalidateDiagnostics = invalidateDiagnostics;
48
+ function getDiagnosticsOfProgram(program) {
49
+ const programDiagnostics = [];
50
+ try {
51
+ if (worker_config_1.config.diagnosticOptions.syntactic) {
52
+ programDiagnostics.push(...program.getSyntacticDiagnostics());
53
+ }
54
+ if (worker_config_1.config.diagnosticOptions.global) {
55
+ programDiagnostics.push(...program.getGlobalDiagnostics());
56
+ }
57
+ if (worker_config_1.config.diagnosticOptions.semantic) {
58
+ programDiagnostics.push(...program.getSemanticDiagnostics());
59
+ }
60
+ if (worker_config_1.config.diagnosticOptions.declaration) {
61
+ programDiagnostics.push(...program.getDeclarationDiagnostics());
62
+ }
63
+ }
64
+ catch (e) {
65
+ if (e instanceof Error) {
66
+ programDiagnostics.push({
67
+ code: 1,
68
+ category: 1,
69
+ messageText: `TSC compiler crashed: ${e.message}
70
+ ${e.stack}`,
71
+ file: undefined,
72
+ start: undefined,
73
+ length: undefined,
74
+ });
75
+ }
76
+ }
77
+ return programDiagnostics;
78
+ }
79
+ exports.getDiagnosticsOfProgram = getDiagnosticsOfProgram;
80
+ function createIssueFromDiagnostic(diagnostic) {
81
+ let file;
82
+ let location;
83
+ if (diagnostic.file) {
84
+ file = diagnostic.file.fileName;
85
+ if (diagnostic.start && diagnostic.length) {
86
+ const { line: startLine, character: startCharacter } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
87
+ const { line: endLine, character: endCharacter } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start + diagnostic.length);
88
+ location = {
89
+ start: {
90
+ line: startLine + 1,
91
+ column: startCharacter + 1,
92
+ },
93
+ end: {
94
+ line: endLine + 1,
95
+ column: endCharacter + 1,
96
+ },
97
+ };
98
+ }
99
+ }
100
+ return {
101
+ code: 'TS' + String(diagnostic.code),
102
+ // we don't handle Suggestion and Message diagnostics
103
+ severity: diagnostic.category === 0 ? 'warning' : 'error',
104
+ message: typescript_1.typescript.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL),
105
+ file,
106
+ location,
107
+ };
108
+ }
109
+ function createIssuesFromDiagnostics(diagnostics) {
110
+ return (0, issue_1.deduplicateAndSortIssues)(diagnostics.map((diagnostic) => createIssueFromDiagnostic(diagnostic)));
111
+ }
112
+ exports.createIssuesFromDiagnostics = createIssuesFromDiagnostics;
@@ -0,0 +1,2 @@
1
+ import type * as ts from 'typescript';
2
+ export declare function emitDtsIfNeeded(program: ts.Program | ts.BuilderProgram): void;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.emitDtsIfNeeded = void 0;
4
+ const config_1 = require("./config");
5
+ const worker_config_1 = require("./worker-config");
6
+ function emitDtsIfNeeded(program) {
7
+ const parsedConfig = (0, config_1.getParsedConfig)();
8
+ if (worker_config_1.config.mode === 'write-dts' && parsedConfig.options.declaration) {
9
+ // emit .d.ts files only
10
+ program.emit(undefined, undefined, undefined, true);
11
+ }
12
+ }
13
+ exports.emitDtsIfNeeded = emitDtsIfNeeded;
@@ -0,0 +1,18 @@
1
+ /// <reference types="node" />
2
+ import type { Dirent, Stats } from 'fs';
3
+ /**
4
+ * Interface to abstract file system implementation details.
5
+ */
6
+ export interface FileSystem {
7
+ exists(path: string): boolean;
8
+ readFile(path: string, encoding?: string): string | undefined;
9
+ readDir(path: string): Dirent[];
10
+ readStats(path: string): Stats | undefined;
11
+ realPath(path: string): string;
12
+ normalizePath(path: string): string;
13
+ writeFile(path: string, data: string): void;
14
+ deleteFile(path: string): void;
15
+ createDir(path: string): void;
16
+ updateTimes(path: string, atime: Date, mtime: Date): void;
17
+ clearCache(): void;
18
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ import type { FileSystem } from './file-system';
2
+ /**
3
+ * It's an implementation of FileSystem interface which reads and writes to the in-memory file system.
4
+ */
5
+ export declare const memFileSystem: FileSystem;
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.memFileSystem = void 0;
4
+ const path_1 = require("path");
5
+ const memfs_1 = require("memfs");
6
+ const real_file_system_1 = require("./real-file-system");
7
+ /**
8
+ * It's an implementation of FileSystem interface which reads and writes to the in-memory file system.
9
+ */
10
+ exports.memFileSystem = Object.assign(Object.assign({}, real_file_system_1.realFileSystem), { exists(path) {
11
+ return exists(real_file_system_1.realFileSystem.realPath(path));
12
+ },
13
+ readFile(path, encoding) {
14
+ return readFile(real_file_system_1.realFileSystem.realPath(path), encoding);
15
+ },
16
+ readDir(path) {
17
+ return readDir(real_file_system_1.realFileSystem.realPath(path));
18
+ },
19
+ readStats(path) {
20
+ return readStats(real_file_system_1.realFileSystem.realPath(path));
21
+ },
22
+ writeFile(path, data) {
23
+ writeFile(real_file_system_1.realFileSystem.realPath(path), data);
24
+ },
25
+ deleteFile(path) {
26
+ deleteFile(real_file_system_1.realFileSystem.realPath(path));
27
+ },
28
+ createDir(path) {
29
+ createDir(real_file_system_1.realFileSystem.realPath(path));
30
+ },
31
+ updateTimes(path, atime, mtime) {
32
+ updateTimes(real_file_system_1.realFileSystem.realPath(path), atime, mtime);
33
+ },
34
+ clearCache() {
35
+ real_file_system_1.realFileSystem.clearCache();
36
+ } });
37
+ function exists(path) {
38
+ return memfs_1.fs.existsSync(real_file_system_1.realFileSystem.normalizePath(path));
39
+ }
40
+ function readStats(path) {
41
+ return exists(path) ? memfs_1.fs.statSync(real_file_system_1.realFileSystem.normalizePath(path)) : undefined;
42
+ }
43
+ function readFile(path, encoding) {
44
+ const stats = readStats(path);
45
+ if (stats && stats.isFile()) {
46
+ return memfs_1.fs
47
+ .readFileSync(real_file_system_1.realFileSystem.normalizePath(path), { encoding: encoding })
48
+ .toString();
49
+ }
50
+ }
51
+ function readDir(path) {
52
+ const stats = readStats(path);
53
+ if (stats && stats.isDirectory()) {
54
+ return memfs_1.fs.readdirSync(real_file_system_1.realFileSystem.normalizePath(path), {
55
+ withFileTypes: true,
56
+ });
57
+ }
58
+ return [];
59
+ }
60
+ function createDir(path) {
61
+ memfs_1.fs.mkdirSync(real_file_system_1.realFileSystem.normalizePath(path), { recursive: true });
62
+ }
63
+ function writeFile(path, data) {
64
+ if (!exists((0, path_1.dirname)(path))) {
65
+ createDir((0, path_1.dirname)(path));
66
+ }
67
+ memfs_1.fs.writeFileSync(real_file_system_1.realFileSystem.normalizePath(path), data);
68
+ }
69
+ function deleteFile(path) {
70
+ if (exists(path)) {
71
+ memfs_1.fs.unlinkSync(real_file_system_1.realFileSystem.normalizePath(path));
72
+ }
73
+ }
74
+ function updateTimes(path, atime, mtime) {
75
+ if (exists(path)) {
76
+ memfs_1.fs.utimesSync(real_file_system_1.realFileSystem.normalizePath(path), atime, mtime);
77
+ }
78
+ }
@@ -0,0 +1,5 @@
1
+ import type { FileSystem } from './file-system';
2
+ /**
3
+ * It's an implementation of FileSystem interface which reads from the real file system, but write to the in-memory file system.
4
+ */
5
+ export declare const passiveFileSystem: FileSystem;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.passiveFileSystem = void 0;
4
+ const mem_file_system_1 = require("./mem-file-system");
5
+ const real_file_system_1 = require("./real-file-system");
6
+ /**
7
+ * It's an implementation of FileSystem interface which reads from the real file system, but write to the in-memory file system.
8
+ */
9
+ exports.passiveFileSystem = Object.assign(Object.assign({}, mem_file_system_1.memFileSystem), { exists(path) {
10
+ return exists(real_file_system_1.realFileSystem.realPath(path));
11
+ },
12
+ readFile(path, encoding) {
13
+ return readFile(real_file_system_1.realFileSystem.realPath(path), encoding);
14
+ },
15
+ readDir(path) {
16
+ return readDir(real_file_system_1.realFileSystem.realPath(path));
17
+ },
18
+ readStats(path) {
19
+ return readStats(real_file_system_1.realFileSystem.realPath(path));
20
+ },
21
+ realPath(path) {
22
+ return real_file_system_1.realFileSystem.realPath(path);
23
+ },
24
+ clearCache() {
25
+ real_file_system_1.realFileSystem.clearCache();
26
+ } });
27
+ function exists(path) {
28
+ return real_file_system_1.realFileSystem.exists(path) || mem_file_system_1.memFileSystem.exists(path);
29
+ }
30
+ function readFile(path, encoding) {
31
+ const fsStats = real_file_system_1.realFileSystem.readStats(path);
32
+ const memStats = mem_file_system_1.memFileSystem.readStats(path);
33
+ if (fsStats && memStats) {
34
+ return fsStats.mtimeMs > memStats.mtimeMs
35
+ ? real_file_system_1.realFileSystem.readFile(path, encoding)
36
+ : mem_file_system_1.memFileSystem.readFile(path, encoding);
37
+ }
38
+ else if (fsStats) {
39
+ return real_file_system_1.realFileSystem.readFile(path, encoding);
40
+ }
41
+ else if (memStats) {
42
+ return mem_file_system_1.memFileSystem.readFile(path, encoding);
43
+ }
44
+ }
45
+ function readDir(path) {
46
+ const fsDirents = real_file_system_1.realFileSystem.readDir(path);
47
+ const memDirents = mem_file_system_1.memFileSystem.readDir(path);
48
+ // merge list of dirents from fs and mem
49
+ return fsDirents
50
+ .filter((fsDirent) => !memDirents.some((memDirent) => memDirent.name === fsDirent.name))
51
+ .concat(memDirents);
52
+ }
53
+ function readStats(path) {
54
+ const fsStats = real_file_system_1.realFileSystem.readStats(path);
55
+ const memStats = mem_file_system_1.memFileSystem.readStats(path);
56
+ if (fsStats && memStats) {
57
+ return fsStats.mtimeMs > memStats.mtimeMs ? fsStats : memStats;
58
+ }
59
+ else if (fsStats) {
60
+ return fsStats;
61
+ }
62
+ else if (memStats) {
63
+ return memStats;
64
+ }
65
+ }
@@ -0,0 +1,5 @@
1
+ import type { FileSystem } from './file-system';
2
+ /**
3
+ * It's an implementation of the FileSystem interface which reads and writes directly to the real file system.
4
+ */
5
+ export declare const realFileSystem: FileSystem;