ts-checker-rspack-plugin 1.1.6 → 1.2.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 (93) hide show
  1. package/lib/getDependenciesWorker.js +652 -0
  2. package/lib/getIssuesWorker.js +1091 -0
  3. package/lib/index.js +970 -4
  4. package/lib/plugin-state.d.ts +0 -1
  5. package/lib/plugin.d.ts +1 -1
  6. package/lib/rpc/rpc-worker.d.ts +0 -1
  7. package/lib/rpc/wrap-rpc.d.ts +0 -1
  8. package/lib/typescript/worker/lib/file-system/file-system.d.ts +0 -1
  9. package/lib/utils/async/abort-error.d.ts +0 -1
  10. package/lib/utils/async/pool.d.ts +0 -1
  11. package/lib/watch/watch-file-system.d.ts +0 -1
  12. package/package.json +11 -10
  13. package/lib/files-change.js +0 -57
  14. package/lib/files-match.js +0 -2
  15. package/lib/formatter/basic-formatter.js +0 -13
  16. package/lib/formatter/code-frame-formatter.js +0 -32
  17. package/lib/formatter/formatter-config.js +0 -36
  18. package/lib/formatter/formatter-options.js +0 -2
  19. package/lib/formatter/formatter.js +0 -2
  20. package/lib/formatter/index.js +0 -22
  21. package/lib/formatter/stats-formatter.js +0 -30
  22. package/lib/formatter/types/babel__code-frame.js +0 -7
  23. package/lib/formatter/webpack-formatter.js +0 -32
  24. package/lib/hooks/intercept-done-to-get-dev-server-tap.js +0 -18
  25. package/lib/hooks/tap-after-compile-to-add-dependencies.js +0 -22
  26. package/lib/hooks/tap-after-compile-to-get-issues.js +0 -43
  27. package/lib/hooks/tap-after-environment-to-patch-watching.js +0 -22
  28. package/lib/hooks/tap-done-to-async-get-issues.js +0 -74
  29. package/lib/hooks/tap-error-to-log-message.js +0 -32
  30. package/lib/hooks/tap-start-to-run-workers.js +0 -122
  31. package/lib/hooks/tap-stop-to-terminate-workers.js +0 -26
  32. package/lib/infrastructure-logger.js +0 -14
  33. package/lib/issue/index.js +0 -19
  34. package/lib/issue/issue-config.js +0 -29
  35. package/lib/issue/issue-location.js +0 -22
  36. package/lib/issue/issue-match.js +0 -20
  37. package/lib/issue/issue-options.js +0 -2
  38. package/lib/issue/issue-position.js +0 -16
  39. package/lib/issue/issue-predicate.js +0 -11
  40. package/lib/issue/issue-severity.js +0 -12
  41. package/lib/issue/issue-webpack-error.js +0 -31
  42. package/lib/issue/issue.js +0 -41
  43. package/lib/logger.js +0 -2
  44. package/lib/plugin-config.js +0 -26
  45. package/lib/plugin-hooks.js +0 -45
  46. package/lib/plugin-options.js +0 -2
  47. package/lib/plugin-pools.js +0 -32
  48. package/lib/plugin-state.js +0 -17
  49. package/lib/plugin.js +0 -74
  50. package/lib/rpc/expose-rpc.js +0 -69
  51. package/lib/rpc/index.js +0 -12
  52. package/lib/rpc/rpc-error.js +0 -12
  53. package/lib/rpc/rpc-worker.js +0 -86
  54. package/lib/rpc/types.js +0 -2
  55. package/lib/rpc/wrap-rpc.js +0 -70
  56. package/lib/typescript/type-script-config-overwrite.js +0 -2
  57. package/lib/typescript/type-script-diagnostics-options.js +0 -2
  58. package/lib/typescript/type-script-support.js +0 -31
  59. package/lib/typescript/type-script-worker-config.js +0 -36
  60. package/lib/typescript/type-script-worker-options.js +0 -2
  61. package/lib/typescript/worker/get-dependencies-worker.js +0 -15
  62. package/lib/typescript/worker/get-issues-worker.js +0 -70
  63. package/lib/typescript/worker/lib/artifacts.js +0 -94
  64. package/lib/typescript/worker/lib/config.js +0 -162
  65. package/lib/typescript/worker/lib/dependencies.js +0 -84
  66. package/lib/typescript/worker/lib/diagnostics.js +0 -112
  67. package/lib/typescript/worker/lib/emit.js +0 -13
  68. package/lib/typescript/worker/lib/file-system/file-system.js +0 -2
  69. package/lib/typescript/worker/lib/file-system/mem-file-system.js +0 -81
  70. package/lib/typescript/worker/lib/file-system/passive-file-system.js +0 -68
  71. package/lib/typescript/worker/lib/file-system/real-file-system.js +0 -171
  72. package/lib/typescript/worker/lib/host/compiler-host.js +0 -17
  73. package/lib/typescript/worker/lib/host/watch-compiler-host.js +0 -32
  74. package/lib/typescript/worker/lib/host/watch-solution-builder-host.js +0 -53
  75. package/lib/typescript/worker/lib/performance.js +0 -29
  76. package/lib/typescript/worker/lib/program/program.js +0 -37
  77. package/lib/typescript/worker/lib/program/solution-builder.js +0 -39
  78. package/lib/typescript/worker/lib/program/watch-program.js +0 -51
  79. package/lib/typescript/worker/lib/system.js +0 -229
  80. package/lib/typescript/worker/lib/tracing.js +0 -27
  81. package/lib/typescript/worker/lib/tsbuildinfo.js +0 -96
  82. package/lib/typescript/worker/lib/typescript.js +0 -6
  83. package/lib/typescript/worker/lib/worker-config.js +0 -5
  84. package/lib/utils/async/abort-error.js +0 -15
  85. package/lib/utils/async/controlled-promise.js +0 -17
  86. package/lib/utils/async/is-pending.js +0 -10
  87. package/lib/utils/async/pool.js +0 -36
  88. package/lib/utils/async/wait.js +0 -7
  89. package/lib/utils/path/forward-slash.js +0 -15
  90. package/lib/utils/path/is-inside-another-path.js +0 -22
  91. package/lib/utils/path/relative-to-context.js +0 -16
  92. package/lib/watch/inclusive-node-watch-file-system.js +0 -183
  93. package/lib/watch/watch-file-system.js +0 -2
package/lib/rpc/index.js DELETED
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RpcExitError = exports.getRpcWorkerData = exports.createRpcWorker = exports.wrapRpc = exports.exposeRpc = void 0;
4
- var expose_rpc_1 = require("./expose-rpc");
5
- Object.defineProperty(exports, "exposeRpc", { enumerable: true, get: function () { return expose_rpc_1.exposeRpc; } });
6
- var wrap_rpc_1 = require("./wrap-rpc");
7
- Object.defineProperty(exports, "wrapRpc", { enumerable: true, get: function () { return wrap_rpc_1.wrapRpc; } });
8
- var rpc_worker_1 = require("./rpc-worker");
9
- Object.defineProperty(exports, "createRpcWorker", { enumerable: true, get: function () { return rpc_worker_1.createRpcWorker; } });
10
- Object.defineProperty(exports, "getRpcWorkerData", { enumerable: true, get: function () { return rpc_worker_1.getRpcWorkerData; } });
11
- var rpc_error_1 = require("./rpc-error");
12
- Object.defineProperty(exports, "RpcExitError", { enumerable: true, get: function () { return rpc_error_1.RpcExitError; } });
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RpcExitError = void 0;
4
- class RpcExitError extends Error {
5
- constructor(message, code, signal) {
6
- super(message);
7
- this.code = code;
8
- this.signal = signal;
9
- this.name = 'RpcExitError';
10
- }
11
- }
12
- exports.RpcExitError = RpcExitError;
@@ -1,86 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getRpcWorkerData = exports.createRpcWorker = void 0;
27
- const child_process = __importStar(require("child_process"));
28
- const process = __importStar(require("process"));
29
- const wrap_rpc_1 = require("./wrap-rpc");
30
- const WORKER_DATA_ENV_KEY = 'WORKER_DATA';
31
- function createRpcWorker(modulePath, data, memoryLimit) {
32
- const options = {
33
- env: {
34
- ...process.env,
35
- [WORKER_DATA_ENV_KEY]: JSON.stringify(data || {}),
36
- },
37
- stdio: ['inherit', 'inherit', 'inherit', 'ipc'],
38
- serialization: 'advanced',
39
- };
40
- if (memoryLimit) {
41
- options.execArgv = [`--max-old-space-size=${memoryLimit}`];
42
- }
43
- let childProcess;
44
- let remoteMethod;
45
- const worker = {
46
- connect() {
47
- if (childProcess && !childProcess.connected) {
48
- childProcess.kill('SIGTERM');
49
- childProcess = undefined;
50
- remoteMethod = undefined;
51
- }
52
- if (!childProcess?.connected) {
53
- childProcess = child_process.fork(modulePath, options);
54
- remoteMethod = (0, wrap_rpc_1.wrapRpc)(childProcess);
55
- }
56
- },
57
- terminate() {
58
- if (childProcess) {
59
- childProcess.kill('SIGTERM');
60
- childProcess = undefined;
61
- remoteMethod = undefined;
62
- }
63
- },
64
- get connected() {
65
- return Boolean(childProcess?.connected);
66
- },
67
- get process() {
68
- return childProcess;
69
- },
70
- };
71
- return Object.assign((...args) => {
72
- if (!worker.connected) {
73
- // try to auto-connect
74
- worker.connect();
75
- }
76
- if (!remoteMethod) {
77
- return Promise.reject('Worker is not connected - cannot perform RPC.');
78
- }
79
- return remoteMethod(...args);
80
- }, worker);
81
- }
82
- exports.createRpcWorker = createRpcWorker;
83
- function getRpcWorkerData() {
84
- return JSON.parse(process.env[WORKER_DATA_ENV_KEY] || '{}');
85
- }
86
- exports.getRpcWorkerData = getRpcWorkerData;
package/lib/rpc/types.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,70 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.wrapRpc = void 0;
4
- const controlled_promise_1 = require("../utils/async/controlled-promise");
5
- const rpc_error_1 = require("./rpc-error");
6
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
- function wrapRpc(childProcess) {
8
- return (async (...args) => {
9
- if (!childProcess.send) {
10
- throw new Error(`Process ${childProcess.pid} doesn't have IPC channels`);
11
- }
12
- else if (!childProcess.connected) {
13
- throw new Error(`Process ${childProcess.pid} doesn't have open IPC channels`);
14
- }
15
- const id = uuid();
16
- // create promises
17
- const { promise: resultPromise, resolve: resolveResult, reject: rejectResult, } = (0, controlled_promise_1.createControlledPromise)();
18
- const { promise: sendPromise, resolve: resolveSend, reject: rejectSend, } = (0, controlled_promise_1.createControlledPromise)();
19
- const handleMessage = (message) => {
20
- if (message?.id === id) {
21
- if (message.type === 'resolve') {
22
- // assume the contract is respected
23
- resolveResult(message.value);
24
- removeHandlers();
25
- }
26
- else if (message.type === 'reject') {
27
- rejectResult(message.error);
28
- removeHandlers();
29
- }
30
- }
31
- };
32
- const handleClose = (code, signal) => {
33
- rejectResult(new rpc_error_1.RpcExitError(code
34
- ? `Process ${childProcess.pid} exited with code ${code}` +
35
- (signal ? ` [${signal}]` : '')
36
- : `Process ${childProcess.pid} exited` + (signal ? ` [${signal}]` : ''), code, signal));
37
- removeHandlers();
38
- };
39
- // to prevent event handler leaks
40
- const removeHandlers = () => {
41
- childProcess.off('message', handleMessage);
42
- childProcess.off('close', handleClose);
43
- };
44
- // add event listeners
45
- childProcess.on('message', handleMessage);
46
- childProcess.on('close', handleClose);
47
- // send call message
48
- childProcess.send({
49
- type: 'call',
50
- id,
51
- args,
52
- }, (error) => {
53
- if (error) {
54
- rejectSend(error);
55
- removeHandlers();
56
- }
57
- else {
58
- resolveSend(undefined);
59
- }
60
- });
61
- return sendPromise.then(() => resultPromise);
62
- });
63
- }
64
- exports.wrapRpc = wrapRpc;
65
- function uuid() {
66
- return new Array(4)
67
- .fill(0)
68
- .map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16))
69
- .join('-');
70
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,31 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.assertTypeScriptSupport = void 0;
7
- const os_1 = __importDefault(require("os"));
8
- const node_fs_1 = __importDefault(require("node:fs"));
9
- function assertTypeScriptSupport(config) {
10
- let typescriptVersion;
11
- try {
12
- // eslint-disable-next-line @typescript-eslint/no-var-requires
13
- typescriptVersion = require(config.typescriptPath).version;
14
- }
15
- catch (error) {
16
- // silent catch
17
- }
18
- if (!typescriptVersion) {
19
- throw new Error('When you use TsCheckerRspackPlugin with typescript reporter enabled, you must install `typescript` package.');
20
- }
21
- if (!node_fs_1.default.existsSync(config.configFile)) {
22
- throw new Error([
23
- `Cannot find the "${config.configFile}" file.`,
24
- `Please check webpack and TsCheckerRspackPlugin configuration.`,
25
- `Possible errors:`,
26
- ' - wrong `context` directory in webpack configuration (if `configFile` is not set or is a relative path in the fork plugin configuration)',
27
- ' - wrong `typescript.configFile` path in the plugin configuration (should be a relative or absolute path)',
28
- ].join(os_1.default.EOL));
29
- }
30
- }
31
- exports.assertTypeScriptSupport = assertTypeScriptSupport;
@@ -1,36 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createTypeScriptWorkerConfig = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- function createTypeScriptWorkerConfig(compiler, options) {
9
- let configFile = typeof options === 'object' ? options.configFile || 'tsconfig.json' : 'tsconfig.json';
10
- // ensure that `configFile` is an absolute normalized path
11
- configFile = path_1.default.normalize(path_1.default.isAbsolute(configFile)
12
- ? configFile
13
- : path_1.default.resolve(compiler.options.context || process.cwd(), configFile));
14
- const optionsAsObject = typeof options === 'object' ? options : {};
15
- const typescriptPath = optionsAsObject.typescriptPath || require.resolve('typescript');
16
- return {
17
- enabled: Boolean(options) || options === undefined,
18
- memoryLimit: 8192,
19
- build: false,
20
- mode: optionsAsObject.build ? 'write-tsbuildinfo' : 'readonly',
21
- profile: false,
22
- ...optionsAsObject,
23
- configFile: configFile,
24
- configOverwrite: optionsAsObject.configOverwrite || {},
25
- context: optionsAsObject.context || path_1.default.dirname(configFile),
26
- diagnosticOptions: {
27
- syntactic: false,
28
- semantic: true,
29
- declaration: false,
30
- global: false,
31
- ...(optionsAsObject.diagnosticOptions || {}),
32
- },
33
- typescriptPath: typescriptPath,
34
- };
35
- }
36
- exports.createTypeScriptWorkerConfig = createTypeScriptWorkerConfig;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const rpc_1 = require("../../rpc");
4
- const config_1 = require("./lib/config");
5
- const dependencies_1 = require("./lib/dependencies");
6
- const system_1 = require("./lib/system");
7
- const getDependenciesWorker = (change) => {
8
- system_1.system.invalidateCache();
9
- if ((0, config_1.didConfigFileChanged)(change) || (0, config_1.didDependenciesProbablyChanged)((0, dependencies_1.getDependencies)(), change)) {
10
- (0, config_1.invalidateConfig)();
11
- (0, dependencies_1.invalidateDependencies)();
12
- }
13
- return (0, dependencies_1.getDependencies)();
14
- };
15
- (0, rpc_1.exposeRpc)(getDependenciesWorker);
@@ -1,70 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const rpc_1 = require("../../rpc");
4
- const artifacts_1 = require("./lib/artifacts");
5
- const config_1 = require("./lib/config");
6
- const dependencies_1 = require("./lib/dependencies");
7
- const diagnostics_1 = require("./lib/diagnostics");
8
- const performance_1 = require("./lib/performance");
9
- const program_1 = require("./lib/program/program");
10
- const solution_builder_1 = require("./lib/program/solution-builder");
11
- const watch_program_1 = require("./lib/program/watch-program");
12
- const system_1 = require("./lib/system");
13
- const tracing_1 = require("./lib/tracing");
14
- const tsbuildinfo_1 = require("./lib/tsbuildinfo");
15
- const worker_config_1 = require("./lib/worker-config");
16
- const getIssuesWorker = async (change, watching) => {
17
- system_1.system.invalidateCache();
18
- if ((0, config_1.didConfigFileChanged)(change)) {
19
- (0, config_1.invalidateConfig)();
20
- (0, dependencies_1.invalidateDependencies)();
21
- (0, artifacts_1.invalidateArtifacts)();
22
- (0, diagnostics_1.invalidateDiagnostics)();
23
- (0, program_1.invalidateProgram)(true);
24
- (0, watch_program_1.invalidateWatchProgram)(true);
25
- (0, solution_builder_1.invalidateSolutionBuilder)(true);
26
- (0, tsbuildinfo_1.invalidateTsBuildInfo)();
27
- }
28
- else if ((0, config_1.didDependenciesProbablyChanged)((0, dependencies_1.getDependencies)(), change)) {
29
- (0, config_1.invalidateConfig)();
30
- (0, dependencies_1.invalidateDependencies)();
31
- (0, artifacts_1.invalidateArtifacts)();
32
- if ((0, config_1.didRootFilesChanged)()) {
33
- (0, watch_program_1.invalidateWatchProgramRootFileNames)();
34
- (0, solution_builder_1.invalidateSolutionBuilder)();
35
- }
36
- }
37
- (0, artifacts_1.registerArtifacts)();
38
- (0, performance_1.enablePerformanceIfNeeded)();
39
- const parseConfigIssues = (0, config_1.getParseConfigIssues)();
40
- if (parseConfigIssues.length) {
41
- // report config parse issues and exit
42
- return parseConfigIssues;
43
- }
44
- // use proper implementation based on the config
45
- if (worker_config_1.config.build) {
46
- (0, solution_builder_1.useSolutionBuilder)();
47
- }
48
- else if (watching) {
49
- (0, watch_program_1.useWatchProgram)();
50
- }
51
- else {
52
- (0, program_1.useProgram)();
53
- }
54
- // simulate file system events
55
- change.changedFiles?.forEach((changedFile) => {
56
- system_1.system?.invokeFileChanged(changedFile);
57
- });
58
- change.deletedFiles?.forEach((deletedFile) => {
59
- system_1.system?.invokeFileDeleted(deletedFile);
60
- });
61
- // wait for all queued events to be processed
62
- await system_1.system.waitForQueued();
63
- // retrieve all collected diagnostics as normalized issues
64
- const issues = (0, diagnostics_1.getIssues)();
65
- (0, tracing_1.dumpTracingLegendIfNeeded)();
66
- (0, performance_1.printPerformanceMeasuresIfNeeded)();
67
- (0, performance_1.disablePerformanceIfNeeded)();
68
- return issues;
69
- };
70
- (0, rpc_1.exposeRpc)(getIssuesWorker);
@@ -1,94 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.registerArtifacts = exports.invalidateArtifacts = exports.getArtifacts = void 0;
27
- const path = __importStar(require("path"));
28
- const config_1 = require("./config");
29
- const system_1 = require("./system");
30
- const tsbuildinfo_1 = require("./tsbuildinfo");
31
- const typescript_1 = require("./typescript");
32
- const worker_config_1 = require("./worker-config");
33
- let artifacts;
34
- function getArtifacts(force = false) {
35
- if (!artifacts || force) {
36
- const parsedConfig = (0, config_1.getParsedConfig)();
37
- artifacts = getArtifactsWorker(parsedConfig, worker_config_1.config.context);
38
- }
39
- return artifacts;
40
- }
41
- exports.getArtifacts = getArtifacts;
42
- function invalidateArtifacts() {
43
- artifacts = undefined;
44
- }
45
- exports.invalidateArtifacts = invalidateArtifacts;
46
- function registerArtifacts() {
47
- system_1.system.setArtifacts(getArtifacts());
48
- }
49
- exports.registerArtifacts = registerArtifacts;
50
- function getArtifactsWorker(parsedConfig, configFileContext, processedConfigFiles = []) {
51
- const files = new Set();
52
- const dirs = new Set();
53
- if (parsedConfig.fileNames.length > 0) {
54
- if (parsedConfig.options.outFile) {
55
- files.add(path.resolve(configFileContext, parsedConfig.options.outFile));
56
- }
57
- const tsBuildInfoPath = (0, tsbuildinfo_1.getTsBuildInfoEmitPath)(parsedConfig.options);
58
- if (tsBuildInfoPath) {
59
- files.add(path.resolve(configFileContext, tsBuildInfoPath));
60
- }
61
- if (parsedConfig.options.outDir) {
62
- dirs.add(path.resolve(configFileContext, parsedConfig.options.outDir));
63
- }
64
- }
65
- for (const projectReference of parsedConfig.projectReferences || []) {
66
- const configFile = typescript_1.typescript.resolveProjectReferencePath(projectReference);
67
- if (processedConfigFiles.includes(configFile)) {
68
- // handle circular dependencies
69
- continue;
70
- }
71
- const parsedConfig = (0, config_1.parseConfig)(configFile, path.dirname(configFile));
72
- const childArtifacts = getArtifactsWorker(parsedConfig, configFileContext, [
73
- ...processedConfigFiles,
74
- configFile,
75
- ]);
76
- childArtifacts.files.forEach((file) => {
77
- files.add(file);
78
- });
79
- childArtifacts.dirs.forEach((dir) => {
80
- dirs.add(dir);
81
- });
82
- }
83
- const extensions = [
84
- typescript_1.typescript.Extension.Dts,
85
- typescript_1.typescript.Extension.Js,
86
- typescript_1.typescript.Extension.TsBuildInfo,
87
- ];
88
- return {
89
- files: Array.from(files).map((file) => path.normalize(file)),
90
- dirs: Array.from(dirs).map((dir) => path.normalize(dir)),
91
- excluded: [],
92
- extensions,
93
- };
94
- }
@@ -1,162 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.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 = {
37
- ...system_1.system,
38
- onUnRecoverableConfigFileDiagnostic: (diagnostic) => {
39
- parseConfigDiagnostics.push(diagnostic);
40
- },
41
- };
42
- function getUserProvidedConfigOverwrite() {
43
- return worker_config_1.config.configOverwrite || {};
44
- }
45
- function getImplicitConfigOverwrite() {
46
- const baseCompilerOptionsOverwrite = {
47
- skipLibCheck: true,
48
- sourceMap: false,
49
- inlineSourceMap: false,
50
- };
51
- switch (worker_config_1.config.mode) {
52
- case 'write-dts':
53
- return {
54
- compilerOptions: {
55
- ...baseCompilerOptionsOverwrite,
56
- declaration: true,
57
- emitDeclarationOnly: true,
58
- noEmit: false,
59
- },
60
- };
61
- case 'write-tsbuildinfo':
62
- case 'write-references':
63
- return {
64
- compilerOptions: {
65
- ...baseCompilerOptionsOverwrite,
66
- declaration: true,
67
- emitDeclarationOnly: false,
68
- noEmit: false,
69
- },
70
- };
71
- }
72
- return {
73
- compilerOptions: baseCompilerOptionsOverwrite,
74
- };
75
- }
76
- function applyConfigOverwrite(baseConfig, ...overwriteConfigs) {
77
- let config = baseConfig;
78
- for (const overwriteConfig of overwriteConfigs) {
79
- config = {
80
- ...(config || {}),
81
- ...(overwriteConfig || {}),
82
- compilerOptions: {
83
- ...(config?.compilerOptions || {}),
84
- ...(overwriteConfig?.compilerOptions || {}),
85
- },
86
- };
87
- }
88
- return config;
89
- }
90
- function parseConfig(configFileName, configFileContext) {
91
- const configFilePath = (0, forward_slash_1.forwardSlash)(configFileName);
92
- const { config: baseConfig, error: readConfigError } = typescript_1.typescript.readConfigFile(configFilePath, parseConfigFileHost.readFile);
93
- const overwrittenConfig = applyConfigOverwrite(baseConfig || {}, getImplicitConfigOverwrite(), getUserProvidedConfigOverwrite());
94
- const parsedConfigFile = typescript_1.typescript.parseJsonConfigFileContent(overwrittenConfig, parseConfigFileHost, configFileContext);
95
- return {
96
- ...parsedConfigFile,
97
- options: {
98
- ...parsedConfigFile.options,
99
- configFilePath: configFilePath,
100
- },
101
- errors: readConfigError ? [readConfigError] : parsedConfigFile.errors,
102
- };
103
- }
104
- exports.parseConfig = parseConfig;
105
- function getParseConfigIssues() {
106
- const issues = (0, diagnostics_1.createIssuesFromDiagnostics)(parseConfigDiagnostics);
107
- issues.forEach((issue) => {
108
- if (!issue.file) {
109
- issue.file = worker_config_1.config.configFile;
110
- }
111
- });
112
- return issues;
113
- }
114
- exports.getParseConfigIssues = getParseConfigIssues;
115
- function getParsedConfig(force = false) {
116
- if (!parsedConfig || force) {
117
- parsedConfig = parseConfig(worker_config_1.config.configFile, worker_config_1.config.context);
118
- parseConfigDiagnostics = parsedConfig.errors || [];
119
- }
120
- return parsedConfig;
121
- }
122
- exports.getParsedConfig = getParsedConfig;
123
- function parseNextConfig() {
124
- const prevParsedConfig = parsedConfig;
125
- const nextParsedConfig = getParsedConfig(true);
126
- return [prevParsedConfig, nextParsedConfig];
127
- }
128
- exports.parseNextConfig = parseNextConfig;
129
- function invalidateConfig() {
130
- parsedConfig = undefined;
131
- parseConfigDiagnostics = [];
132
- }
133
- exports.invalidateConfig = invalidateConfig;
134
- function getConfigFilePathFromCompilerOptions(compilerOptions) {
135
- return compilerOptions.configFilePath;
136
- }
137
- exports.getConfigFilePathFromCompilerOptions = getConfigFilePathFromCompilerOptions;
138
- function getConfigFilePathFromProgram(program) {
139
- return getConfigFilePathFromCompilerOptions(program.getCompilerOptions());
140
- }
141
- exports.getConfigFilePathFromProgram = getConfigFilePathFromProgram;
142
- function getConfigFilePathFromBuilderProgram(builderProgram) {
143
- return getConfigFilePathFromCompilerOptions(builderProgram.getProgram().getCompilerOptions());
144
- }
145
- exports.getConfigFilePathFromBuilderProgram = getConfigFilePathFromBuilderProgram;
146
- function didConfigFileChanged({ changedFiles = [], deletedFiles = [] }) {
147
- return [...changedFiles, ...deletedFiles]
148
- .map((file) => path.normalize(file))
149
- .includes(path.normalize(worker_config_1.config.configFile));
150
- }
151
- exports.didConfigFileChanged = didConfigFileChanged;
152
- function didDependenciesProbablyChanged(dependencies, { changedFiles = [], deletedFiles = [] }) {
153
- const didSomeDependencyHasBeenAdded = changedFiles.some((changeFile) => !dependencies.files.includes(changeFile));
154
- const didSomeDependencyHasBeenDeleted = deletedFiles.some((deletedFile) => dependencies.files.includes(deletedFile));
155
- return didSomeDependencyHasBeenAdded || didSomeDependencyHasBeenDeleted;
156
- }
157
- exports.didDependenciesProbablyChanged = didDependenciesProbablyChanged;
158
- function didRootFilesChanged() {
159
- const [prevConfig, nextConfig] = parseNextConfig();
160
- return (prevConfig && JSON.stringify(prevConfig.fileNames) !== JSON.stringify(nextConfig.fileNames));
161
- }
162
- exports.didRootFilesChanged = didRootFilesChanged;