ts-checker-rspack-plugin 1.0.0-beta.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 (168) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +216 -0
  3. package/lib/files-change.d.ts +17 -0
  4. package/lib/files-change.js +57 -0
  5. package/lib/files-match.d.ts +7 -0
  6. package/lib/files-match.js +2 -0
  7. package/lib/formatter/basic-formatter.d.ts +3 -0
  8. package/lib/formatter/basic-formatter.js +13 -0
  9. package/lib/formatter/code-frame-formatter.d.ts +4 -0
  10. package/lib/formatter/code-frame-formatter.js +29 -0
  11. package/lib/formatter/formatter-config.d.ts +8 -0
  12. package/lib/formatter/formatter-config.js +36 -0
  13. package/lib/formatter/formatter-options.d.ts +14 -0
  14. package/lib/formatter/formatter-options.js +2 -0
  15. package/lib/formatter/formatter.d.ts +4 -0
  16. package/lib/formatter/formatter.js +2 -0
  17. package/lib/formatter/index.d.ts +6 -0
  18. package/lib/formatter/index.js +18 -0
  19. package/lib/formatter/stats-formatter.d.ts +3 -0
  20. package/lib/formatter/stats-formatter.js +28 -0
  21. package/lib/formatter/types/babel__code-frame.d.ts +21 -0
  22. package/lib/formatter/types/babel__code-frame.js +7 -0
  23. package/lib/formatter/webpack-formatter.d.ts +3 -0
  24. package/lib/formatter/webpack-formatter.js +32 -0
  25. package/lib/hooks/intercept-done-to-get-dev-server-tap.d.ts +5 -0
  26. package/lib/hooks/intercept-done-to-get-dev-server-tap.js +18 -0
  27. package/lib/hooks/tap-after-compile-to-add-dependencies.d.ts +5 -0
  28. package/lib/hooks/tap-after-compile-to-add-dependencies.js +31 -0
  29. package/lib/hooks/tap-after-compile-to-get-issues.d.ts +5 -0
  30. package/lib/hooks/tap-after-compile-to-get-issues.js +52 -0
  31. package/lib/hooks/tap-after-environment-to-patch-watching.d.ts +4 -0
  32. package/lib/hooks/tap-after-environment-to-patch-watching.js +22 -0
  33. package/lib/hooks/tap-done-to-async-get-issues.d.ts +5 -0
  34. package/lib/hooks/tap-done-to-async-get-issues.js +86 -0
  35. package/lib/hooks/tap-error-to-log-message.d.ts +4 -0
  36. package/lib/hooks/tap-error-to-log-message.js +32 -0
  37. package/lib/hooks/tap-start-to-run-workers.d.ts +8 -0
  38. package/lib/hooks/tap-start-to-run-workers.js +132 -0
  39. package/lib/hooks/tap-stop-to-terminate-workers.d.ts +5 -0
  40. package/lib/hooks/tap-stop-to-terminate-workers.js +26 -0
  41. package/lib/index.d.ts +2 -0
  42. package/lib/index.js +5 -0
  43. package/lib/infrastructure-logger.d.ts +9 -0
  44. package/lib/infrastructure-logger.js +14 -0
  45. package/lib/issue/index.d.ts +3 -0
  46. package/lib/issue/index.js +15 -0
  47. package/lib/issue/issue-config.d.ts +8 -0
  48. package/lib/issue/issue-config.js +29 -0
  49. package/lib/issue/issue-location.d.ts +8 -0
  50. package/lib/issue/issue-location.js +22 -0
  51. package/lib/issue/issue-match.d.ts +5 -0
  52. package/lib/issue/issue-match.js +20 -0
  53. package/lib/issue/issue-options.d.ts +8 -0
  54. package/lib/issue/issue-options.js +2 -0
  55. package/lib/issue/issue-position.d.ts +6 -0
  56. package/lib/issue/issue-position.js +16 -0
  57. package/lib/issue/issue-predicate.d.ts +5 -0
  58. package/lib/issue/issue-predicate.js +11 -0
  59. package/lib/issue/issue-severity.d.ts +4 -0
  60. package/lib/issue/issue-severity.js +12 -0
  61. package/lib/issue/issue-webpack-error.d.ts +10 -0
  62. package/lib/issue/issue-webpack-error.js +51 -0
  63. package/lib/issue/issue.d.ts +12 -0
  64. package/lib/issue/issue.js +41 -0
  65. package/lib/logger.d.ts +5 -0
  66. package/lib/logger.js +2 -0
  67. package/lib/plugin-config.d.ts +16 -0
  68. package/lib/plugin-config.js +26 -0
  69. package/lib/plugin-hooks.d.ts +20 -0
  70. package/lib/plugin-hooks.js +45 -0
  71. package/lib/plugin-options.d.ts +13 -0
  72. package/lib/plugin-options.js +2 -0
  73. package/lib/plugin-options.json +197 -0
  74. package/lib/plugin-pools.d.ts +4 -0
  75. package/lib/plugin-pools.js +28 -0
  76. package/lib/plugin-state.d.ts +18 -0
  77. package/lib/plugin-state.js +17 -0
  78. package/lib/plugin.d.ts +29 -0
  79. package/lib/plugin.js +79 -0
  80. package/lib/rpc/expose-rpc.d.ts +1 -0
  81. package/lib/rpc/expose-rpc.js +78 -0
  82. package/lib/rpc/index.d.ts +5 -0
  83. package/lib/rpc/index.js +12 -0
  84. package/lib/rpc/rpc-error.d.ts +6 -0
  85. package/lib/rpc/rpc-error.js +12 -0
  86. package/lib/rpc/rpc-worker.d.ts +13 -0
  87. package/lib/rpc/rpc-worker.js +79 -0
  88. package/lib/rpc/types.d.ts +19 -0
  89. package/lib/rpc/types.js +2 -0
  90. package/lib/rpc/wrap-rpc.d.ts +4 -0
  91. package/lib/rpc/wrap-rpc.js +79 -0
  92. package/lib/typescript/type-script-config-overwrite.d.ts +12 -0
  93. package/lib/typescript/type-script-config-overwrite.js +2 -0
  94. package/lib/typescript/type-script-diagnostics-options.d.ts +7 -0
  95. package/lib/typescript/type-script-diagnostics-options.js +2 -0
  96. package/lib/typescript/type-script-support.d.ts +3 -0
  97. package/lib/typescript/type-script-support.js +63 -0
  98. package/lib/typescript/type-script-worker-config.d.ts +18 -0
  99. package/lib/typescript/type-script-worker-config.js +18 -0
  100. package/lib/typescript/type-script-worker-options.d.ts +14 -0
  101. package/lib/typescript/type-script-worker-options.js +2 -0
  102. package/lib/typescript/worker/get-dependencies-worker.d.ts +5 -0
  103. package/lib/typescript/worker/get-dependencies-worker.js +15 -0
  104. package/lib/typescript/worker/get-issues-worker.d.ts +5 -0
  105. package/lib/typescript/worker/get-issues-worker.js +80 -0
  106. package/lib/typescript/worker/lib/artifacts.d.ts +4 -0
  107. package/lib/typescript/worker/lib/artifacts.js +90 -0
  108. package/lib/typescript/worker/lib/config.d.ts +15 -0
  109. package/lib/typescript/worker/lib/config.js +131 -0
  110. package/lib/typescript/worker/lib/dependencies.d.ts +3 -0
  111. package/lib/typescript/worker/lib/dependencies.js +81 -0
  112. package/lib/typescript/worker/lib/diagnostics.d.ts +7 -0
  113. package/lib/typescript/worker/lib/diagnostics.js +108 -0
  114. package/lib/typescript/worker/lib/emit.d.ts +2 -0
  115. package/lib/typescript/worker/lib/emit.js +13 -0
  116. package/lib/typescript/worker/lib/file-system/file-system.d.ts +18 -0
  117. package/lib/typescript/worker/lib/file-system/file-system.js +2 -0
  118. package/lib/typescript/worker/lib/file-system/mem-file-system.d.ts +5 -0
  119. package/lib/typescript/worker/lib/file-system/mem-file-system.js +78 -0
  120. package/lib/typescript/worker/lib/file-system/passive-file-system.d.ts +5 -0
  121. package/lib/typescript/worker/lib/file-system/passive-file-system.js +65 -0
  122. package/lib/typescript/worker/lib/file-system/real-file-system.d.ts +5 -0
  123. package/lib/typescript/worker/lib/file-system/real-file-system.js +187 -0
  124. package/lib/typescript/worker/lib/host/compiler-host.d.ts +2 -0
  125. package/lib/typescript/worker/lib/host/compiler-host.js +10 -0
  126. package/lib/typescript/worker/lib/host/watch-compiler-host.d.ts +2 -0
  127. package/lib/typescript/worker/lib/host/watch-compiler-host.js +20 -0
  128. package/lib/typescript/worker/lib/host/watch-solution-builder-host.d.ts +2 -0
  129. package/lib/typescript/worker/lib/host/watch-solution-builder-host.js +47 -0
  130. package/lib/typescript/worker/lib/performance.d.ts +3 -0
  131. package/lib/typescript/worker/lib/performance.js +32 -0
  132. package/lib/typescript/worker/lib/program/program.d.ts +2 -0
  133. package/lib/typescript/worker/lib/program/program.js +37 -0
  134. package/lib/typescript/worker/lib/program/solution-builder.d.ts +2 -0
  135. package/lib/typescript/worker/lib/program/solution-builder.js +39 -0
  136. package/lib/typescript/worker/lib/program/watch-program.d.ts +3 -0
  137. package/lib/typescript/worker/lib/program/watch-program.js +51 -0
  138. package/lib/typescript/worker/lib/system.d.ts +19 -0
  139. package/lib/typescript/worker/lib/system.js +232 -0
  140. package/lib/typescript/worker/lib/tracing.d.ts +4 -0
  141. package/lib/typescript/worker/lib/tracing.js +29 -0
  142. package/lib/typescript/worker/lib/tsbuildinfo.d.ts +4 -0
  143. package/lib/typescript/worker/lib/tsbuildinfo.js +92 -0
  144. package/lib/typescript/worker/lib/typescript.d.ts +2 -0
  145. package/lib/typescript/worker/lib/typescript.js +6 -0
  146. package/lib/typescript/worker/lib/worker-config.d.ts +2 -0
  147. package/lib/typescript/worker/lib/worker-config.js +5 -0
  148. package/lib/utils/async/abort-error.d.ts +6 -0
  149. package/lib/utils/async/abort-error.js +15 -0
  150. package/lib/utils/async/controlled-promise.d.ts +6 -0
  151. package/lib/utils/async/controlled-promise.js +17 -0
  152. package/lib/utils/async/is-pending.d.ts +2 -0
  153. package/lib/utils/async/is-pending.js +10 -0
  154. package/lib/utils/async/pool.d.ts +10 -0
  155. package/lib/utils/async/pool.js +47 -0
  156. package/lib/utils/async/wait.d.ts +2 -0
  157. package/lib/utils/async/wait.js +7 -0
  158. package/lib/utils/path/forward-slash.d.ts +6 -0
  159. package/lib/utils/path/forward-slash.js +15 -0
  160. package/lib/utils/path/is-inside-another-path.d.ts +2 -0
  161. package/lib/utils/path/is-inside-another-path.js +22 -0
  162. package/lib/utils/path/relative-to-context.d.ts +2 -0
  163. package/lib/utils/path/relative-to-context.js +16 -0
  164. package/lib/watch/inclusive-node-watch-file-system.d.ts +15 -0
  165. package/lib/watch/inclusive-node-watch-file-system.js +166 -0
  166. package/lib/watch/watch-file-system.d.ts +16 -0
  167. package/lib/watch/watch-file-system.js +2 -0
  168. package/package.json +88 -0
@@ -0,0 +1,80 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const rpc_1 = require("../../rpc");
13
+ const artifacts_1 = require("./lib/artifacts");
14
+ const config_1 = require("./lib/config");
15
+ const dependencies_1 = require("./lib/dependencies");
16
+ const diagnostics_1 = require("./lib/diagnostics");
17
+ const performance_1 = require("./lib/performance");
18
+ const program_1 = require("./lib/program/program");
19
+ const solution_builder_1 = require("./lib/program/solution-builder");
20
+ const watch_program_1 = require("./lib/program/watch-program");
21
+ const system_1 = require("./lib/system");
22
+ const tracing_1 = require("./lib/tracing");
23
+ const tsbuildinfo_1 = require("./lib/tsbuildinfo");
24
+ const worker_config_1 = require("./lib/worker-config");
25
+ const getIssuesWorker = (change, watching) => __awaiter(void 0, void 0, void 0, function* () {
26
+ var _a, _b;
27
+ system_1.system.invalidateCache();
28
+ if ((0, config_1.didConfigFileChanged)(change)) {
29
+ (0, config_1.invalidateConfig)();
30
+ (0, dependencies_1.invalidateDependencies)();
31
+ (0, artifacts_1.invalidateArtifacts)();
32
+ (0, diagnostics_1.invalidateDiagnostics)();
33
+ (0, program_1.invalidateProgram)(true);
34
+ (0, watch_program_1.invalidateWatchProgram)(true);
35
+ (0, solution_builder_1.invalidateSolutionBuilder)(true);
36
+ (0, tsbuildinfo_1.invalidateTsBuildInfo)();
37
+ }
38
+ else if ((0, config_1.didDependenciesProbablyChanged)((0, dependencies_1.getDependencies)(), change)) {
39
+ (0, config_1.invalidateConfig)();
40
+ (0, dependencies_1.invalidateDependencies)();
41
+ (0, artifacts_1.invalidateArtifacts)();
42
+ if ((0, config_1.didRootFilesChanged)()) {
43
+ (0, watch_program_1.invalidateWatchProgramRootFileNames)();
44
+ (0, solution_builder_1.invalidateSolutionBuilder)();
45
+ }
46
+ }
47
+ (0, artifacts_1.registerArtifacts)();
48
+ (0, performance_1.enablePerformanceIfNeeded)();
49
+ const parseConfigIssues = (0, config_1.getParseConfigIssues)();
50
+ if (parseConfigIssues.length) {
51
+ // report config parse issues and exit
52
+ return parseConfigIssues;
53
+ }
54
+ // use proper implementation based on the config
55
+ if (worker_config_1.config.build) {
56
+ (0, solution_builder_1.useSolutionBuilder)();
57
+ }
58
+ else if (watching) {
59
+ (0, watch_program_1.useWatchProgram)();
60
+ }
61
+ else {
62
+ (0, program_1.useProgram)();
63
+ }
64
+ // simulate file system events
65
+ (_a = change.changedFiles) === null || _a === void 0 ? void 0 : _a.forEach((changedFile) => {
66
+ system_1.system === null || system_1.system === void 0 ? void 0 : system_1.system.invokeFileChanged(changedFile);
67
+ });
68
+ (_b = change.deletedFiles) === null || _b === void 0 ? void 0 : _b.forEach((deletedFile) => {
69
+ system_1.system === null || system_1.system === void 0 ? void 0 : system_1.system.invokeFileDeleted(deletedFile);
70
+ });
71
+ // wait for all queued events to be processed
72
+ yield system_1.system.waitForQueued();
73
+ // retrieve all collected diagnostics as normalized issues
74
+ const issues = (0, diagnostics_1.getIssues)();
75
+ (0, tracing_1.dumpTracingLegendIfNeeded)();
76
+ (0, performance_1.printPerformanceMeasuresIfNeeded)();
77
+ (0, performance_1.disablePerformanceIfNeeded)();
78
+ return issues;
79
+ });
80
+ (0, rpc_1.exposeRpc)(getIssuesWorker);
@@ -0,0 +1,4 @@
1
+ import type { FilesMatch } from '../../../files-match';
2
+ export declare function getArtifacts(force?: boolean): FilesMatch;
3
+ export declare function invalidateArtifacts(): void;
4
+ export declare function registerArtifacts(): void;
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.registerArtifacts = exports.invalidateArtifacts = exports.getArtifacts = void 0;
23
+ const path = __importStar(require("path"));
24
+ const config_1 = require("./config");
25
+ const system_1 = require("./system");
26
+ const tsbuildinfo_1 = require("./tsbuildinfo");
27
+ const typescript_1 = require("./typescript");
28
+ const worker_config_1 = require("./worker-config");
29
+ let artifacts;
30
+ function getArtifacts(force = false) {
31
+ if (!artifacts || force) {
32
+ const parsedConfig = (0, config_1.getParsedConfig)();
33
+ artifacts = getArtifactsWorker(parsedConfig, worker_config_1.config.context);
34
+ }
35
+ return artifacts;
36
+ }
37
+ exports.getArtifacts = getArtifacts;
38
+ function invalidateArtifacts() {
39
+ artifacts = undefined;
40
+ }
41
+ exports.invalidateArtifacts = invalidateArtifacts;
42
+ function registerArtifacts() {
43
+ system_1.system.setArtifacts(getArtifacts());
44
+ }
45
+ exports.registerArtifacts = registerArtifacts;
46
+ function getArtifactsWorker(parsedConfig, configFileContext, processedConfigFiles = []) {
47
+ const files = new Set();
48
+ const dirs = new Set();
49
+ if (parsedConfig.fileNames.length > 0) {
50
+ if (parsedConfig.options.outFile) {
51
+ files.add(path.resolve(configFileContext, parsedConfig.options.outFile));
52
+ }
53
+ const tsBuildInfoPath = (0, tsbuildinfo_1.getTsBuildInfoEmitPath)(parsedConfig.options);
54
+ if (tsBuildInfoPath) {
55
+ files.add(path.resolve(configFileContext, tsBuildInfoPath));
56
+ }
57
+ if (parsedConfig.options.outDir) {
58
+ dirs.add(path.resolve(configFileContext, parsedConfig.options.outDir));
59
+ }
60
+ }
61
+ for (const projectReference of parsedConfig.projectReferences || []) {
62
+ const configFile = typescript_1.typescript.resolveProjectReferencePath(projectReference);
63
+ if (processedConfigFiles.includes(configFile)) {
64
+ // handle circular dependencies
65
+ continue;
66
+ }
67
+ const parsedConfig = (0, config_1.parseConfig)(configFile, path.dirname(configFile));
68
+ const childArtifacts = getArtifactsWorker(parsedConfig, configFileContext, [
69
+ ...processedConfigFiles,
70
+ configFile,
71
+ ]);
72
+ childArtifacts.files.forEach((file) => {
73
+ files.add(file);
74
+ });
75
+ childArtifacts.dirs.forEach((dir) => {
76
+ dirs.add(dir);
77
+ });
78
+ }
79
+ const extensions = [
80
+ typescript_1.typescript.Extension.Dts,
81
+ typescript_1.typescript.Extension.Js,
82
+ typescript_1.typescript.Extension.TsBuildInfo,
83
+ ];
84
+ return {
85
+ files: Array.from(files).map((file) => path.normalize(file)),
86
+ dirs: Array.from(dirs).map((dir) => path.normalize(dir)),
87
+ excluded: [],
88
+ extensions,
89
+ };
90
+ }
@@ -0,0 +1,15 @@
1
+ import type * as ts from 'typescript';
2
+ import type { FilesChange } from '../../../files-change';
3
+ import type { FilesMatch } from '../../../files-match';
4
+ import type { Issue } from '../../../issue';
5
+ export declare function parseConfig(configFileName: string, configFileContext: string): ts.ParsedCommandLine;
6
+ export declare function getParseConfigIssues(): Issue[];
7
+ export declare function getParsedConfig(force?: boolean): ts.ParsedCommandLine;
8
+ export declare function parseNextConfig(): readonly [ts.ParsedCommandLine | undefined, ts.ParsedCommandLine];
9
+ export declare function invalidateConfig(): void;
10
+ export declare function getConfigFilePathFromCompilerOptions(compilerOptions: ts.CompilerOptions): string;
11
+ export declare function getConfigFilePathFromProgram(program: ts.Program): string;
12
+ export declare function getConfigFilePathFromBuilderProgram(builderProgram: ts.BuilderProgram): string;
13
+ export declare function didConfigFileChanged({ changedFiles, deletedFiles }: FilesChange): boolean;
14
+ export declare function didDependenciesProbablyChanged(dependencies: FilesMatch, { changedFiles, deletedFiles }: FilesChange): boolean;
15
+ export declare function didRootFilesChanged(): boolean | undefined;
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.didRootFilesChanged = exports.didDependenciesProbablyChanged = exports.didConfigFileChanged = exports.getConfigFilePathFromBuilderProgram = exports.getConfigFilePathFromProgram = exports.getConfigFilePathFromCompilerOptions = exports.invalidateConfig = exports.parseNextConfig = exports.getParsedConfig = exports.getParseConfigIssues = exports.parseConfig = void 0;
23
+ const path = __importStar(require("path"));
24
+ const forward_slash_1 = require("../../../utils/path/forward-slash");
25
+ const diagnostics_1 = require("./diagnostics");
26
+ const system_1 = require("./system");
27
+ const typescript_1 = require("./typescript");
28
+ const worker_config_1 = require("./worker-config");
29
+ let parsedConfig;
30
+ let parseConfigDiagnostics = [];
31
+ // initialize ParseConfigFileHost
32
+ const parseConfigFileHost = Object.assign(Object.assign({}, system_1.system), { onUnRecoverableConfigFileDiagnostic: (diagnostic) => {
33
+ parseConfigDiagnostics.push(diagnostic);
34
+ } });
35
+ function getUserProvidedConfigOverwrite() {
36
+ return worker_config_1.config.configOverwrite || {};
37
+ }
38
+ function getImplicitConfigOverwrite() {
39
+ const baseCompilerOptionsOverwrite = {
40
+ skipLibCheck: true,
41
+ sourceMap: false,
42
+ inlineSourceMap: false,
43
+ };
44
+ switch (worker_config_1.config.mode) {
45
+ case 'write-dts':
46
+ return {
47
+ compilerOptions: Object.assign(Object.assign({}, baseCompilerOptionsOverwrite), { declaration: true, emitDeclarationOnly: true, noEmit: false }),
48
+ };
49
+ case 'write-tsbuildinfo':
50
+ case 'write-references':
51
+ return {
52
+ compilerOptions: Object.assign(Object.assign({}, baseCompilerOptionsOverwrite), { declaration: true, emitDeclarationOnly: false, noEmit: false }),
53
+ };
54
+ }
55
+ return {
56
+ compilerOptions: baseCompilerOptionsOverwrite,
57
+ };
58
+ }
59
+ function applyConfigOverwrite(baseConfig, ...overwriteConfigs) {
60
+ let config = baseConfig;
61
+ for (const overwriteConfig of overwriteConfigs) {
62
+ 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) || {})) });
63
+ }
64
+ return config;
65
+ }
66
+ function parseConfig(configFileName, configFileContext) {
67
+ const configFilePath = (0, forward_slash_1.forwardSlash)(configFileName);
68
+ const { config: baseConfig, error: readConfigError } = typescript_1.typescript.readConfigFile(configFilePath, parseConfigFileHost.readFile);
69
+ const overwrittenConfig = applyConfigOverwrite(baseConfig || {}, getImplicitConfigOverwrite(), getUserProvidedConfigOverwrite());
70
+ const parsedConfigFile = typescript_1.typescript.parseJsonConfigFileContent(overwrittenConfig, parseConfigFileHost, configFileContext);
71
+ return Object.assign(Object.assign({}, parsedConfigFile), { options: Object.assign(Object.assign({}, parsedConfigFile.options), { configFilePath: configFilePath }), errors: readConfigError ? [readConfigError] : parsedConfigFile.errors });
72
+ }
73
+ exports.parseConfig = parseConfig;
74
+ function getParseConfigIssues() {
75
+ const issues = (0, diagnostics_1.createIssuesFromDiagnostics)(parseConfigDiagnostics);
76
+ issues.forEach((issue) => {
77
+ if (!issue.file) {
78
+ issue.file = worker_config_1.config.configFile;
79
+ }
80
+ });
81
+ return issues;
82
+ }
83
+ exports.getParseConfigIssues = getParseConfigIssues;
84
+ function getParsedConfig(force = false) {
85
+ if (!parsedConfig || force) {
86
+ parsedConfig = parseConfig(worker_config_1.config.configFile, worker_config_1.config.context);
87
+ parseConfigDiagnostics = parsedConfig.errors || [];
88
+ }
89
+ return parsedConfig;
90
+ }
91
+ exports.getParsedConfig = getParsedConfig;
92
+ function parseNextConfig() {
93
+ const prevParsedConfig = parsedConfig;
94
+ const nextParsedConfig = getParsedConfig(true);
95
+ return [prevParsedConfig, nextParsedConfig];
96
+ }
97
+ exports.parseNextConfig = parseNextConfig;
98
+ function invalidateConfig() {
99
+ parsedConfig = undefined;
100
+ parseConfigDiagnostics = [];
101
+ }
102
+ exports.invalidateConfig = invalidateConfig;
103
+ function getConfigFilePathFromCompilerOptions(compilerOptions) {
104
+ return compilerOptions.configFilePath;
105
+ }
106
+ exports.getConfigFilePathFromCompilerOptions = getConfigFilePathFromCompilerOptions;
107
+ function getConfigFilePathFromProgram(program) {
108
+ return getConfigFilePathFromCompilerOptions(program.getCompilerOptions());
109
+ }
110
+ exports.getConfigFilePathFromProgram = getConfigFilePathFromProgram;
111
+ function getConfigFilePathFromBuilderProgram(builderProgram) {
112
+ return getConfigFilePathFromCompilerOptions(builderProgram.getProgram().getCompilerOptions());
113
+ }
114
+ exports.getConfigFilePathFromBuilderProgram = getConfigFilePathFromBuilderProgram;
115
+ function didConfigFileChanged({ changedFiles = [], deletedFiles = [] }) {
116
+ return [...changedFiles, ...deletedFiles]
117
+ .map((file) => path.normalize(file))
118
+ .includes(path.normalize(worker_config_1.config.configFile));
119
+ }
120
+ exports.didConfigFileChanged = didConfigFileChanged;
121
+ function didDependenciesProbablyChanged(dependencies, { changedFiles = [], deletedFiles = [] }) {
122
+ const didSomeDependencyHasBeenAdded = changedFiles.some((changeFile) => !dependencies.files.includes(changeFile));
123
+ const didSomeDependencyHasBeenDeleted = deletedFiles.some((deletedFile) => dependencies.files.includes(deletedFile));
124
+ return didSomeDependencyHasBeenAdded || didSomeDependencyHasBeenDeleted;
125
+ }
126
+ exports.didDependenciesProbablyChanged = didDependenciesProbablyChanged;
127
+ function didRootFilesChanged() {
128
+ const [prevConfig, nextConfig] = parseNextConfig();
129
+ return (prevConfig && JSON.stringify(prevConfig.fileNames) !== JSON.stringify(nextConfig.fileNames));
130
+ }
131
+ 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,81 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.invalidateDependencies = exports.getDependencies = void 0;
23
+ const path = __importStar(require("path"));
24
+ const config_1 = require("./config");
25
+ const typescript_1 = require("./typescript");
26
+ const worker_config_1 = require("./worker-config");
27
+ let dependencies;
28
+ function getDependencies(force = false) {
29
+ if (!dependencies || force) {
30
+ const parsedConfig = (0, config_1.getParsedConfig)();
31
+ dependencies = getDependenciesWorker(parsedConfig, worker_config_1.config.context);
32
+ }
33
+ return dependencies;
34
+ }
35
+ exports.getDependencies = getDependencies;
36
+ function invalidateDependencies() {
37
+ dependencies = undefined;
38
+ }
39
+ exports.invalidateDependencies = invalidateDependencies;
40
+ function getDependenciesWorker(parsedConfig, configFileContext, processedConfigFiles = []) {
41
+ var _a;
42
+ const files = new Set(parsedConfig.fileNames);
43
+ const configFilePath = parsedConfig.options.configFilePath;
44
+ if (typeof configFilePath === 'string') {
45
+ files.add(configFilePath);
46
+ }
47
+ const dirs = new Set(Object.keys(parsedConfig.wildcardDirectories || {}));
48
+ const excluded = new Set((((_a = parsedConfig.raw) === null || _a === void 0 ? void 0 : _a.exclude) || []).map((filePath) => path.resolve(configFileContext, filePath)));
49
+ for (const projectReference of parsedConfig.projectReferences || []) {
50
+ const childConfigFilePath = typescript_1.typescript.resolveProjectReferencePath(projectReference);
51
+ const childConfigContext = path.dirname(childConfigFilePath);
52
+ if (processedConfigFiles.includes(childConfigFilePath)) {
53
+ // handle circular dependencies
54
+ continue;
55
+ }
56
+ const childParsedConfig = (0, config_1.parseConfig)(childConfigFilePath, childConfigContext);
57
+ const childDependencies = getDependenciesWorker(childParsedConfig, childConfigContext, [
58
+ ...processedConfigFiles,
59
+ childConfigFilePath,
60
+ ]);
61
+ childDependencies.files.forEach((file) => {
62
+ files.add(file);
63
+ });
64
+ childDependencies.dirs.forEach((dir) => {
65
+ dirs.add(dir);
66
+ });
67
+ }
68
+ const extensions = [
69
+ typescript_1.typescript.Extension.Ts,
70
+ typescript_1.typescript.Extension.Tsx,
71
+ typescript_1.typescript.Extension.Js,
72
+ typescript_1.typescript.Extension.Jsx,
73
+ typescript_1.typescript.Extension.TsBuildInfo,
74
+ ];
75
+ return {
76
+ files: Array.from(files).map((file) => path.normalize(file)),
77
+ dirs: Array.from(dirs).map((dir) => path.normalize(dir)),
78
+ excluded: Array.from(excluded).map((aPath) => path.normalize(aPath)),
79
+ extensions: extensions,
80
+ };
81
+ }
@@ -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,108 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.createIssuesFromDiagnostics = exports.getDiagnosticsOfProgram = exports.invalidateDiagnostics = exports.getIssues = exports.updateDiagnostics = void 0;
23
+ const os = __importStar(require("os"));
24
+ const issue_1 = require("../../../issue");
25
+ const typescript_1 = require("./typescript");
26
+ const worker_config_1 = require("./worker-config");
27
+ const diagnosticsPerConfigFile = new Map();
28
+ function updateDiagnostics(configFile, diagnostics) {
29
+ diagnosticsPerConfigFile.set(configFile, diagnostics);
30
+ }
31
+ exports.updateDiagnostics = updateDiagnostics;
32
+ function getIssues() {
33
+ const allDiagnostics = [];
34
+ diagnosticsPerConfigFile.forEach((diagnostics) => {
35
+ allDiagnostics.push(...diagnostics);
36
+ });
37
+ return createIssuesFromDiagnostics(allDiagnostics);
38
+ }
39
+ exports.getIssues = getIssues;
40
+ function invalidateDiagnostics() {
41
+ diagnosticsPerConfigFile.clear();
42
+ }
43
+ exports.invalidateDiagnostics = invalidateDiagnostics;
44
+ function getDiagnosticsOfProgram(program) {
45
+ const programDiagnostics = [];
46
+ try {
47
+ if (worker_config_1.config.diagnosticOptions.syntactic) {
48
+ programDiagnostics.push(...program.getSyntacticDiagnostics());
49
+ }
50
+ if (worker_config_1.config.diagnosticOptions.global) {
51
+ programDiagnostics.push(...program.getGlobalDiagnostics());
52
+ }
53
+ if (worker_config_1.config.diagnosticOptions.semantic) {
54
+ programDiagnostics.push(...program.getSemanticDiagnostics());
55
+ }
56
+ if (worker_config_1.config.diagnosticOptions.declaration) {
57
+ programDiagnostics.push(...program.getDeclarationDiagnostics());
58
+ }
59
+ }
60
+ catch (e) {
61
+ if (e instanceof Error) {
62
+ programDiagnostics.push({
63
+ code: 1,
64
+ category: 1,
65
+ messageText: `TSC compiler crashed: ${e.message}
66
+ ${e.stack}`,
67
+ file: undefined,
68
+ start: undefined,
69
+ length: undefined,
70
+ });
71
+ }
72
+ }
73
+ return programDiagnostics;
74
+ }
75
+ exports.getDiagnosticsOfProgram = getDiagnosticsOfProgram;
76
+ function createIssueFromDiagnostic(diagnostic) {
77
+ let file;
78
+ let location;
79
+ if (diagnostic.file) {
80
+ file = diagnostic.file.fileName;
81
+ if (diagnostic.start && diagnostic.length) {
82
+ const { line: startLine, character: startCharacter } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
83
+ const { line: endLine, character: endCharacter } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start + diagnostic.length);
84
+ location = {
85
+ start: {
86
+ line: startLine + 1,
87
+ column: startCharacter + 1,
88
+ },
89
+ end: {
90
+ line: endLine + 1,
91
+ column: endCharacter + 1,
92
+ },
93
+ };
94
+ }
95
+ }
96
+ return {
97
+ code: 'TS' + String(diagnostic.code),
98
+ // we don't handle Suggestion and Message diagnostics
99
+ severity: diagnostic.category === 0 ? 'warning' : 'error',
100
+ message: typescript_1.typescript.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL),
101
+ file,
102
+ location,
103
+ };
104
+ }
105
+ function createIssuesFromDiagnostics(diagnostics) {
106
+ return (0, issue_1.deduplicateAndSortIssues)(diagnostics.map((diagnostic) => createIssueFromDiagnostic(diagnostic)));
107
+ }
108
+ 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;