ts-checker-rspack-plugin 1.6.0 → 1.6.2

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 (56) hide show
  1. package/lib/formatter/basic-formatter.d.ts +1 -1
  2. package/lib/formatter/code-frame-formatter.d.ts +2 -2
  3. package/lib/formatter/formatter-config.d.ts +2 -2
  4. package/lib/formatter/formatter-options.d.ts +3 -3
  5. package/lib/formatter/formatter.d.ts +1 -1
  6. package/lib/formatter/index.d.ts +6 -6
  7. package/lib/formatter/rspack-formatter.d.ts +1 -1
  8. package/lib/formatter/stats-formatter.d.ts +1 -1
  9. package/lib/getDependenciesWorker.js +4 -4
  10. package/lib/getIssuesWorker.js +4 -4
  11. package/lib/hooks/intercept-done-to-get-dev-server-tap.d.ts +2 -2
  12. package/lib/hooks/tap-after-compile-to-add-dependencies.d.ts +2 -2
  13. package/lib/hooks/tap-after-compile-to-get-issues.d.ts +2 -2
  14. package/lib/hooks/tap-after-environment-to-patch-watching.d.ts +1 -1
  15. package/lib/hooks/tap-done-to-async-get-issues.d.ts +2 -2
  16. package/lib/hooks/tap-error-to-log-message.d.ts +1 -1
  17. package/lib/hooks/tap-start-to-run-type-script-go.d.ts +2 -2
  18. package/lib/hooks/tap-start-to-run-workers.d.ts +5 -5
  19. package/lib/hooks/tap-stop-to-terminate-workers.d.ts +2 -2
  20. package/lib/index.d.ts +1 -1
  21. package/lib/index.js +248 -102
  22. package/lib/issue/index.d.ts +3 -3
  23. package/lib/issue/issue-config.d.ts +3 -3
  24. package/lib/issue/issue-location.d.ts +1 -1
  25. package/lib/issue/issue-match.d.ts +2 -2
  26. package/lib/issue/issue-options.d.ts +3 -3
  27. package/lib/issue/issue-predicate.d.ts +1 -1
  28. package/lib/issue/issue-rspack-error.d.ts +2 -2
  29. package/lib/issue/issue.d.ts +2 -2
  30. package/lib/plugin-config.d.ts +5 -5
  31. package/lib/plugin-hooks.d.ts +10 -6
  32. package/lib/plugin-options.d.ts +4 -4
  33. package/lib/plugin-pools.d.ts +1 -1
  34. package/lib/plugin-state.d.ts +3 -3
  35. package/lib/plugin.d.ts +8 -6
  36. package/lib/rpc/index.d.ts +6 -6
  37. package/lib/rpc/rpc-worker.d.ts +1 -1
  38. package/lib/rpc/wrap-rpc.d.ts +1 -1
  39. package/lib/typescript/type-script-go-package.d.ts +2 -2
  40. package/lib/typescript/type-script-go-runner.d.ts +9 -10
  41. package/lib/typescript/type-script-support.d.ts +1 -1
  42. package/lib/typescript/type-script-worker-config.d.ts +5 -5
  43. package/lib/typescript/type-script-worker-options.d.ts +2 -2
  44. package/lib/typescript/worker/get-dependencies-worker.d.ts +2 -2
  45. package/lib/typescript/worker/get-issues-worker.d.ts +3 -3
  46. package/lib/typescript/worker/lib/artifacts.d.ts +1 -1
  47. package/lib/typescript/worker/lib/config.d.ts +3 -3
  48. package/lib/typescript/worker/lib/dependencies.d.ts +1 -1
  49. package/lib/typescript/worker/lib/diagnostics.d.ts +1 -1
  50. package/lib/typescript/worker/lib/file-system/mem-file-system.d.ts +1 -1
  51. package/lib/typescript/worker/lib/file-system/passive-file-system.d.ts +1 -1
  52. package/lib/typescript/worker/lib/file-system/real-file-system.d.ts +1 -1
  53. package/lib/typescript/worker/lib/system.d.ts +1 -1
  54. package/lib/typescript/worker/lib/worker-config.d.ts +1 -1
  55. package/lib/watch/inclusive-node-watch-file-system.d.ts +4 -4
  56. package/package.json +17 -19
package/lib/index.js CHANGED
@@ -279,7 +279,7 @@ var __webpack_modules__ = {
279
279
  const hasMarker = markerLines[number];
280
280
  const lastMarkerLine = !markerLines[number + 1];
281
281
  if (!hasMarker) return ` ${defs.gutter(gutter)}${line.length > 0 ? ` ${line}` : ""}`;
282
- {
282
+ else {
283
283
  let markerLine = "";
284
284
  if (Array.isArray(hasMarker)) {
285
285
  const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " ");
@@ -303,7 +303,7 @@ var __webpack_modules__ = {
303
303
  }).join("\n");
304
304
  if (opts.message && !hasColumns) frame = `${" ".repeat(numberMaxWidth + 1)}${opts.message}\n${frame}`;
305
305
  if (shouldHighlight) return defs.reset(frame);
306
- return frame;
306
+ else return frame;
307
307
  }
308
308
  exports1.gl = codeFrameColumns;
309
309
  },
@@ -1625,6 +1625,7 @@ var __webpack_exports__ = {};
1625
1625
  const commaPattern = /\\,/g;
1626
1626
  const periodPattern = /\\\./g;
1627
1627
  const EXPANSION_MAX = 100000;
1628
+ const EXPANSION_MAX_LENGTH = 4000000;
1628
1629
  function numeric(str) {
1629
1630
  return isNaN(str) ? str.charCodeAt(0) : parseInt(str, 10);
1630
1631
  }
@@ -1654,9 +1655,9 @@ var __webpack_exports__ = {};
1654
1655
  }
1655
1656
  function expand(str, options = {}) {
1656
1657
  if (!str) return [];
1657
- const { max = EXPANSION_MAX } = options;
1658
+ const { max = EXPANSION_MAX, maxLength = EXPANSION_MAX_LENGTH } = options;
1658
1659
  if ('{}' === str.slice(0, 2)) str = '\\{\\}' + str.slice(2);
1659
- return expand_(escapeBraces(str), max, true).map(unescapeBraces);
1660
+ return expand_(escapeBraces(str), max, maxLength, true).map(unescapeBraces);
1660
1661
  }
1661
1662
  function embrace(str) {
1662
1663
  return '{' + str + '}';
@@ -1670,21 +1671,78 @@ var __webpack_exports__ = {};
1670
1671
  function gte(i, y) {
1671
1672
  return i >= y;
1672
1673
  }
1673
- function expand_(str, max, isTop) {
1674
- const expansions = [];
1675
- const m = balanced('{', '}', str);
1676
- if (!m) return [
1677
- str
1678
- ];
1679
- const pre = m.pre;
1680
- const post = m.post.length ? expand_(m.post, max, false) : [
1674
+ function combine(acc, pre, values, max, maxLength, dropEmpties) {
1675
+ const out = [];
1676
+ let length = 0;
1677
+ for(let a = 0; a < acc.length; a++)for(let v = 0; v < values.length; v++){
1678
+ if (out.length >= max) return out;
1679
+ const expansion = acc[a] + pre + values[v];
1680
+ if (!dropEmpties || expansion) {
1681
+ if (length + expansion.length > maxLength) return out;
1682
+ out.push(expansion);
1683
+ length += expansion.length;
1684
+ }
1685
+ }
1686
+ return out;
1687
+ }
1688
+ function expandSequence(body, isAlphaSequence, max, maxLength) {
1689
+ const n = body.split(/\.\./);
1690
+ const N = [];
1691
+ if (void 0 === n[0] || void 0 === n[1]) return N;
1692
+ const x = numeric(n[0]);
1693
+ const y = numeric(n[1]);
1694
+ const width = Math.max(n[0].length, n[1].length);
1695
+ let incr = 3 === n.length && void 0 !== n[2] ? Math.max(Math.abs(numeric(n[2])), 1) : 1;
1696
+ let test = lte;
1697
+ const reverse = y < x;
1698
+ if (reverse) {
1699
+ incr *= -1;
1700
+ test = gte;
1701
+ }
1702
+ const pad = n.some(isPadded);
1703
+ let length = 0;
1704
+ for(let i = x; test(i, y) && N.length < max; i += incr){
1705
+ let c;
1706
+ if (isAlphaSequence) {
1707
+ c = String.fromCharCode(i);
1708
+ if ('\\' === c) c = '';
1709
+ } else {
1710
+ c = String(i);
1711
+ if (pad) {
1712
+ const need = width - c.length;
1713
+ if (need > 0) {
1714
+ const z = new Array(need + 1).join('0');
1715
+ c = i < 0 ? '-' + z + c.slice(1) : z + c;
1716
+ }
1717
+ }
1718
+ }
1719
+ if (length + c.length > maxLength) break;
1720
+ N.push(c);
1721
+ length += c.length;
1722
+ }
1723
+ return N;
1724
+ }
1725
+ function expand_(str, max, maxLength, isTop) {
1726
+ let acc = [
1681
1727
  ''
1682
1728
  ];
1683
- if (/\$$/.test(m.pre)) for(let k = 0; k < post.length && k < max; k++){
1684
- const expansion = pre + '{' + m.body + '}' + post[k];
1685
- expansions.push(expansion);
1686
- }
1687
- else {
1729
+ let dropEmpties = false;
1730
+ let firstGroup = true;
1731
+ for(;;){
1732
+ const m = balanced('{', '}', str);
1733
+ if (!m) return combine(acc, str, [
1734
+ ''
1735
+ ], max, maxLength, dropEmpties);
1736
+ const pre = m.pre;
1737
+ if (/\$$/.test(pre)) {
1738
+ acc = combine(acc, pre + '{' + m.body + '}', [
1739
+ ''
1740
+ ], max, maxLength, dropEmpties && !m.post.length);
1741
+ firstGroup = false;
1742
+ if (!m.post.length) break;
1743
+ str = m.post;
1744
+ continue;
1745
+ }
1688
1746
  const isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
1689
1747
  const isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
1690
1748
  const isSequence = isNumericSequence || isAlphaSequence;
@@ -1692,62 +1750,53 @@ var __webpack_exports__ = {};
1692
1750
  if (!isSequence && !isOptions) {
1693
1751
  if (m.post.match(/,(?!,).*\}/)) {
1694
1752
  str = m.pre + '{' + m.body + escClose + m.post;
1695
- return expand_(str, max, true);
1753
+ isTop = true;
1754
+ continue;
1696
1755
  }
1697
- return [
1698
- str
1699
- ];
1756
+ return combine(acc, pre + '{' + m.body + '}' + m.post, [
1757
+ ''
1758
+ ], max, maxLength, dropEmpties);
1700
1759
  }
1701
- let n;
1702
- if (isSequence) n = m.body.split(/\.\./);
1760
+ if (firstGroup) {
1761
+ dropEmpties = isTop && !isSequence;
1762
+ firstGroup = false;
1763
+ }
1764
+ let values;
1765
+ if (isSequence) values = expandSequence(m.body, isAlphaSequence, max, maxLength);
1703
1766
  else {
1704
- n = parseCommaParts(m.body);
1767
+ let n = parseCommaParts(m.body);
1705
1768
  if (1 === n.length && void 0 !== n[0]) {
1706
- n = expand_(n[0], max, false).map(embrace);
1707
- if (1 === n.length) return post.map((p)=>m.pre + n[0] + p);
1708
- }
1709
- }
1710
- let N;
1711
- if (isSequence && void 0 !== n[0] && void 0 !== n[1]) {
1712
- const x = numeric(n[0]);
1713
- const y = numeric(n[1]);
1714
- const width = Math.max(n[0].length, n[1].length);
1715
- let incr = 3 === n.length && void 0 !== n[2] ? Math.max(Math.abs(numeric(n[2])), 1) : 1;
1716
- let test = lte;
1717
- const reverse = y < x;
1718
- if (reverse) {
1719
- incr *= -1;
1720
- test = gte;
1769
+ n = expand_(n[0], max, maxLength, false).map(embrace);
1770
+ if (1 === n.length) {
1771
+ acc = combine(acc, pre + n[0], [
1772
+ ''
1773
+ ], max, maxLength, dropEmpties && !m.post.length);
1774
+ if (!m.post.length) break;
1775
+ str = m.post;
1776
+ continue;
1777
+ }
1721
1778
  }
1722
- const pad = n.some(isPadded);
1723
- N = [];
1724
- for(let i = x; test(i, y); i += incr){
1725
- let c;
1726
- if (isAlphaSequence) {
1727
- c = String.fromCharCode(i);
1728
- if ('\\' === c) c = '';
1729
- } else {
1730
- c = String(i);
1731
- if (pad) {
1732
- const need = width - c.length;
1733
- if (need > 0) {
1734
- const z = new Array(need + 1).join('0');
1735
- c = i < 0 ? '-' + z + c.slice(1) : z + c;
1736
- }
1779
+ let dropsEmpties = dropEmpties && !m.post.length && !pre;
1780
+ for(let d = 0; dropsEmpties && d < acc.length; d++)if (acc[d]) dropsEmpties = false;
1781
+ values = [];
1782
+ let valuesLength = 0;
1783
+ outer: for(let j = 0; j < n.length; j++){
1784
+ const expanded = expand_(n[j], max, maxLength, false);
1785
+ for(let k = 0; k < expanded.length; k++){
1786
+ const v = expanded[k];
1787
+ if (!dropsEmpties || v) {
1788
+ if (values.length >= max || valuesLength + v.length > maxLength) break outer;
1789
+ values.push(v);
1790
+ valuesLength += v.length;
1737
1791
  }
1738
1792
  }
1739
- N.push(c);
1740
1793
  }
1741
- } else {
1742
- N = [];
1743
- for(let j = 0; j < n.length; j++)N.push.apply(N, expand_(n[j], max, false));
1744
- }
1745
- for(let j = 0; j < N.length; j++)for(let k = 0; k < post.length && expansions.length < max; k++){
1746
- const expansion = pre + N[j] + post[k];
1747
- if (!isTop || isSequence || expansion) expansions.push(expansion);
1748
1794
  }
1795
+ acc = combine(acc, pre, values, max, maxLength, dropEmpties && !m.post.length);
1796
+ if (!m.post.length) break;
1797
+ str = m.post;
1749
1798
  }
1750
- return expansions;
1799
+ return acc;
1751
1800
  }
1752
1801
  const MAX_PATTERN_LENGTH = 65536;
1753
1802
  const assertValidPattern = (pattern)=>{
@@ -2240,8 +2289,7 @@ var __webpack_exports__ = {};
2240
2289
  } else if (']' === c && !(i === braceStart + 2 && braceNeg)) inBrace = false;
2241
2290
  acc += c;
2242
2291
  continue;
2243
- }
2244
- if ('[' === c) {
2292
+ } else if ('[' === c) {
2245
2293
  inBrace = true;
2246
2294
  braceStart = i;
2247
2295
  braceNeg = false;
@@ -2279,8 +2327,7 @@ var __webpack_exports__ = {};
2279
2327
  } else if (']' === c && !(i === braceStart + 2 && braceNeg)) inBrace = false;
2280
2328
  acc += c;
2281
2329
  continue;
2282
- }
2283
- if ('[' === c) {
2330
+ } else if ('[' === c) {
2284
2331
  inBrace = true;
2285
2332
  braceStart = i;
2286
2333
  braceNeg = false;
@@ -2508,8 +2555,7 @@ var __webpack_exports__ = {};
2508
2555
  re += noEmpty && /^[*]+$/.test(glob) ? starNoEmpty : star;
2509
2556
  hasMagic = true;
2510
2557
  continue;
2511
- }
2512
- inStar = false;
2558
+ } else inStar = false;
2513
2559
  if ('\\' === c) {
2514
2560
  if (i === glob.length - 1) re += '\\\\';
2515
2561
  else escaping = true;
@@ -2758,7 +2804,7 @@ var __webpack_exports__ = {};
2758
2804
  ...s.slice(0, 4),
2759
2805
  ...s.slice(4).map((ss)=>this.parse(ss))
2760
2806
  ];
2761
- if (isDrive) return [
2807
+ else if (isDrive) return [
2762
2808
  s[0],
2763
2809
  ...s.slice(1).map((ss)=>this.parse(ss))
2764
2810
  ];
@@ -3097,9 +3143,9 @@ var __webpack_exports__ = {};
3097
3143
  if (!hit) return false;
3098
3144
  }
3099
3145
  if (fi === fl && pi === pl) return true;
3100
- if (fi === fl) return partial;
3101
- if (pi === pl) return fi === fl - 1 && '' === file[fi];
3102
- throw new Error('wtf?');
3146
+ else if (fi === fl) return partial;
3147
+ else if (pi === pl) return fi === fl - 1 && '' === file[fi];
3148
+ else throw new Error('wtf?');
3103
3149
  }
3104
3150
  braceExpand() {
3105
3151
  return braceExpand(this.pattern, this.options);
@@ -3180,11 +3226,11 @@ var __webpack_exports__ = {};
3180
3226
  }
3181
3227
  slashSplit(p) {
3182
3228
  if (this.preserveMultipleSlashes) return p.split('/');
3183
- if (this.isWindows && /^\/\/[^/]+/.test(p)) return [
3229
+ else if (this.isWindows && /^\/\/[^/]+/.test(p)) return [
3184
3230
  '',
3185
3231
  ...p.split(/\/+/)
3186
3232
  ];
3187
- return p.split(/\/+/);
3233
+ else return p.split(/\/+/);
3188
3234
  }
3189
3235
  match(f, partial = this.partial) {
3190
3236
  this.debug('match', f, this.pattern);
@@ -3307,8 +3353,9 @@ var __webpack_exports__ = {};
3307
3353
  });
3308
3354
  const ignoredFunctions = ignoredPatterns.map((pattern)=>{
3309
3355
  if ('string' == typeof pattern) return (path)=>minimatch(path, pattern);
3310
- if (pattern instanceof RegExp) return (path)=>pattern.test(path);
3311
- return ()=>false;
3356
+ else if (pattern instanceof RegExp) return (path)=>pattern.test(path);
3357
+ else if ('function' == typeof pattern) return pattern;
3358
+ else return ()=>false;
3312
3359
  });
3313
3360
  ignoredFunctions.push((path)=>filteredExcluded.some((excludedPath)=>isInsideAnotherPath(excludedPath, path)));
3314
3361
  ignoredFunctions.push((path)=>BUILTIN_IGNORED_DIRS.some((ignoredDir)=>path.includes(`/${ignoredDir}/`) || path.includes(`\\${ignoredDir}\\`)));
@@ -3721,6 +3768,7 @@ var __webpack_exports__ = {};
3721
3768
  const external_node_fs_namespaceObject = require("node:fs");
3722
3769
  var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
3723
3770
  const external_node_url_namespaceObject = require("node:url");
3771
+ const external_node_util_namespaceObject = require("node:util");
3724
3772
  const TYPESCRIPT_PACKAGE = "typescript";
3725
3773
  const TYPESCRIPT_PACKAGE_JSON = `${TYPESCRIPT_PACKAGE}/package.json`;
3726
3774
  const TYPESCRIPT_PREVIEW_PACKAGE = "@typescript/native-preview";
@@ -3752,6 +3800,36 @@ var __webpack_exports__ = {};
3752
3800
  args: []
3753
3801
  };
3754
3802
  }
3803
+ async function runTypeScriptGoShowConfig(executable, configFile) {
3804
+ const { stdout } = await (0, external_node_util_namespaceObject.promisify)(external_node_child_process_namespaceObject.execFile)(executable.command, [
3805
+ ...executable.args,
3806
+ '--project',
3807
+ configFile,
3808
+ '--showConfig',
3809
+ '--pretty',
3810
+ 'false'
3811
+ ], {
3812
+ cwd: external_node_path_default().dirname(configFile),
3813
+ encoding: 'utf8',
3814
+ maxBuffer: 67108864
3815
+ });
3816
+ const parsedConfig = JSON.parse(stdout);
3817
+ if (!parsedConfig || 'object' != typeof parsedConfig || Array.isArray(parsedConfig)) throw new TypeError('Invalid tsgo --showConfig output.');
3818
+ return parsedConfig;
3819
+ }
3820
+ function toComparisonPath(file) {
3821
+ const normalizedPath = external_node_path_default().normalize(file);
3822
+ return 'win32' === process.platform ? normalizedPath.toLowerCase() : normalizedPath;
3823
+ }
3824
+ function shouldRefreshTypeScriptGoDependencies(dependencies, { changedFiles = [], deletedFiles = [] }) {
3825
+ if (!dependencies) return true;
3826
+ const dependencyKeys = dependencies.files.map((file)=>toComparisonPath(file));
3827
+ return changedFiles.some((file)=>{
3828
+ const key = toComparisonPath(file);
3829
+ const extension = external_node_path_default().extname(file).toLowerCase();
3830
+ return '.json' === extension || dependencies.extensions.includes(extension) && !dependencyKeys.includes(key);
3831
+ }) || deletedFiles.some((file)=>dependencyKeys.includes(toComparisonPath(file)));
3832
+ }
3755
3833
  function createTypeScriptGoArgs(config) {
3756
3834
  const args = config.build ? [
3757
3835
  '--build',
@@ -3917,17 +3995,41 @@ var __webpack_exports__ = {};
3917
3995
  });
3918
3996
  });
3919
3997
  }
3920
- function getTypeScriptGoDependencies(config) {
3998
+ async function getTypeScriptGoDependencies(config) {
3999
+ const executable = await resolveTypeScriptGoExecutable(config);
4000
+ const files = new Set();
4001
+ const dirs = new Set();
4002
+ const excluded = new Set();
4003
+ const visitedConfigs = new Set();
4004
+ const collectConfigDependencies = async (configFile, fallbackRoot, collectExcluded)=>{
4005
+ const normalizedConfigFile = external_node_path_default().normalize(configFile);
4006
+ const configKey = toComparisonPath(normalizedConfigFile);
4007
+ if (visitedConfigs.has(configKey)) return;
4008
+ visitedConfigs.add(configKey);
4009
+ const configDir = external_node_path_default().dirname(normalizedConfigFile);
4010
+ const normalizedRoot = external_node_path_default().normalize(fallbackRoot);
4011
+ files.add(normalizedConfigFile);
4012
+ if (!Array.from(dirs).some((dir)=>'' === external_node_path_default().relative(dir, normalizedRoot) || isInsideAnotherPath(dir, normalizedRoot))) dirs.add(normalizedRoot);
4013
+ excluded.add(external_node_path_default().join(normalizedRoot, 'node_modules'));
4014
+ let parsedConfig;
4015
+ try {
4016
+ parsedConfig = await runTypeScriptGoShowConfig(executable, normalizedConfigFile);
4017
+ } catch {
4018
+ return;
4019
+ }
4020
+ for (const file of parsedConfig.files || [])files.add(external_node_path_default().normalize(external_node_path_default().resolve(configDir, file)));
4021
+ if (collectExcluded && !parsedConfig.references?.length) for (const exclude of parsedConfig.exclude || [])excluded.add(external_node_path_default().normalize(external_node_path_default().resolve(configDir, exclude)));
4022
+ for (const reference of parsedConfig.references || [])if (reference.path) {
4023
+ const resolvedReference = external_node_path_default().resolve(configDir, reference.path);
4024
+ const referenceConfig = '.json' === external_node_path_default().extname(resolvedReference).toLowerCase() ? resolvedReference : external_node_path_default().join(resolvedReference, 'tsconfig.json');
4025
+ await collectConfigDependencies(referenceConfig, external_node_path_default().dirname(referenceConfig), false);
4026
+ }
4027
+ };
4028
+ await collectConfigDependencies(config.configFile, config.context, true);
3921
4029
  return {
3922
- files: [
3923
- config.configFile
3924
- ],
3925
- dirs: [
3926
- config.context
3927
- ],
3928
- excluded: [
3929
- external_node_path_default().join(config.context, 'node_modules')
3930
- ],
4030
+ files: Array.from(files),
4031
+ dirs: Array.from(dirs),
4032
+ excluded: Array.from(excluded),
3931
4033
  extensions: [
3932
4034
  '.ts',
3933
4035
  '.tsx',
@@ -3946,7 +4048,7 @@ var __webpack_exports__ = {};
3946
4048
  const { debug } = getInfrastructureLogger(compiler);
3947
4049
  compiler.hooks.afterCompile.tapPromise('TsCheckerRspackPlugin', async (compilation)=>{
3948
4050
  if (compilation.compiler !== compiler) return;
3949
- let issues = [];
4051
+ let issues;
3950
4052
  try {
3951
4053
  issues = await state.issuesPromise;
3952
4054
  } catch (error) {
@@ -3995,7 +4097,7 @@ var __webpack_exports__ = {};
3995
4097
  `${external_picocolors_default().bold(color(severity))} in ` + formatter(issue),
3996
4098
  ''
3997
4099
  ].join(external_node_os_default().EOL);
3998
- {
4100
+ else {
3999
4101
  let location = external_picocolors_default().bold('absolute' === pathType ? forwardSlash(external_node_path_default().resolve(issue.file)) : relativeToContext(issue.file, process.cwd()));
4000
4102
  if (issue.location) location += `:${external_picocolors_default().bold(external_picocolors_default().green(formatIssueLocation(issue.location)))}`;
4001
4103
  return [
@@ -4233,6 +4335,7 @@ var __webpack_exports__ = {};
4233
4335
  ].join(external_node_os_default().EOL));
4234
4336
  }
4235
4337
  const hiddenTypeScriptGoErrors = Symbol('hiddenTypeScriptGoErrors');
4338
+ const STYLE_FILE = /\.(css|scss|sass|less|styl)$/i;
4236
4339
  function getStatsFilterHook(hook) {
4237
4340
  return hook;
4238
4341
  }
@@ -4243,6 +4346,9 @@ var __webpack_exports__ = {};
4243
4346
  const hooks = getPluginHooks(compiler);
4244
4347
  const { log, debug } = getInfrastructureLogger(compiler);
4245
4348
  let assertTypeScriptGoExecutablePromise;
4349
+ let dependenciesPromise;
4350
+ let dependenciesCacheGeneration = 0;
4351
+ let canReuseIssues = false;
4246
4352
  const assertTypeScriptGoExecutableOnce = async ()=>{
4247
4353
  try {
4248
4354
  if (!assertTypeScriptGoExecutablePromise) assertTypeScriptGoExecutablePromise = assertTypeScriptGoExecutable(config.typescript);
@@ -4301,6 +4407,18 @@ var __webpack_exports__ = {};
4301
4407
  return red(childErrorsMessage);
4302
4408
  });
4303
4409
  });
4410
+ let filesChange = state.watching ? consumeFilesChange(compiler) : {};
4411
+ const changedFiles = [
4412
+ ...filesChange.changedFiles || [],
4413
+ ...compiler.modifiedFiles || []
4414
+ ];
4415
+ const dependencyPaths = new Set(state.lastDependencies?.files.map((file)=>toComparisonPath(file)));
4416
+ if (state.watching && canReuseIssues && state.lastDependencies && 0 === hooks.start.taps.length && !filesChange.deletedFiles?.length && !compiler.removedFiles?.size && changedFiles.length > 0 && changedFiles.every((file)=>STYLE_FILE.test(file) && !dependencyPaths.has(toComparisonPath(file)))) {
4417
+ debug('Reusing tsgo issues for style-only changes.');
4418
+ state.issuesPromise = state.issuesPromise.then((issues)=>issues);
4419
+ return;
4420
+ }
4421
+ canReuseIssues = false;
4304
4422
  const iteration = ++state.iteration;
4305
4423
  if (state.abortController) {
4306
4424
  debug(`Aborting tsgo iteration ${iteration - 1}.`);
@@ -4308,17 +4426,32 @@ var __webpack_exports__ = {};
4308
4426
  }
4309
4427
  const abortController = new AbortController();
4310
4428
  state.abortController = abortController;
4311
- let filesChange = {};
4312
- if (state.watching) {
4313
- filesChange = consumeFilesChange(compiler);
4314
- log([
4315
- 'Calling tsgo for incremental check.',
4316
- ` Changed files: ${JSON.stringify(filesChange.changedFiles)}`,
4317
- ` Deleted files: ${JSON.stringify(filesChange.deletedFiles)}`
4318
- ].join('\n'));
4319
- } else log('Calling tsgo for single check.');
4320
- state.dependenciesPromise = Promise.resolve(getTypeScriptGoDependencies(config.typescript));
4321
- filesChange = await hooks.start.promise(filesChange, compilation);
4429
+ state.watching ? log([
4430
+ 'Calling tsgo for incremental check.',
4431
+ ` Changed files: ${JSON.stringify(filesChange.changedFiles)}`,
4432
+ ` Deleted files: ${JSON.stringify(filesChange.deletedFiles)}`
4433
+ ].join('\n')) : log('Calling tsgo for single check.');
4434
+ const cacheGeneration = ++dependenciesCacheGeneration;
4435
+ const startPromise = hooks.start.promise(filesChange, compilation);
4436
+ state.dependenciesPromise = startPromise.then((nextFilesChange)=>{
4437
+ if (cacheGeneration !== dependenciesCacheGeneration) return;
4438
+ if (state.watching && dependenciesPromise && !shouldRefreshTypeScriptGoDependencies(state.lastDependencies, nextFilesChange)) {
4439
+ debug(`Reusing cached tsgo dependencies, iteration ${iteration}.`);
4440
+ return dependenciesPromise;
4441
+ }
4442
+ const nextDependenciesPromise = getTypeScriptGoDependencies(config.typescript);
4443
+ if (state.watching) {
4444
+ dependenciesPromise = nextDependenciesPromise;
4445
+ nextDependenciesPromise.catch(()=>{
4446
+ if (dependenciesPromise === nextDependenciesPromise) {
4447
+ dependenciesPromise = void 0;
4448
+ canReuseIssues = false;
4449
+ }
4450
+ });
4451
+ }
4452
+ return nextDependenciesPromise;
4453
+ });
4454
+ filesChange = await startPromise;
4322
4455
  let aggregatedFilesChange = filesChange;
4323
4456
  if (state.aggregatedFilesChange) {
4324
4457
  aggregatedFilesChange = aggregateFilesChanges([
@@ -4332,6 +4465,7 @@ var __webpack_exports__ = {};
4332
4465
  ].join('\n'));
4333
4466
  }
4334
4467
  state.aggregatedFilesChange = aggregatedFilesChange;
4468
+ canReuseIssues = true;
4335
4469
  state.issuesPromise = (state.issuesPromise || Promise.resolve()).catch(()=>void 0).then(()=>{
4336
4470
  if (abortController.signal.aborted) return;
4337
4471
  debug(`Submitting tsgo to the pool, iteration ${iteration}.`);
@@ -4340,9 +4474,13 @@ var __webpack_exports__ = {};
4340
4474
  debug(`Running tsgo, iteration ${iteration}.`);
4341
4475
  const issues = await runTypeScriptGo(config.typescript, config.logger, config.issue.defaultSeverity, signal);
4342
4476
  if (state.aggregatedFilesChange === aggregatedFilesChange) state.aggregatedFilesChange = void 0;
4343
- if (state.abortController === abortController) state.abortController = void 0;
4477
+ if (state.abortController === abortController) {
4478
+ if (issues.some(isTypeScriptGoIssue)) canReuseIssues = false;
4479
+ state.abortController = void 0;
4480
+ }
4344
4481
  return issues;
4345
4482
  } catch (error) {
4483
+ if (state.abortController === abortController) canReuseIssues = false;
4346
4484
  hooks.error.call(error, compilation);
4347
4485
  return;
4348
4486
  } finally{
@@ -4358,8 +4496,16 @@ var __webpack_exports__ = {};
4358
4496
  state.abortController = void 0;
4359
4497
  }
4360
4498
  };
4361
- compiler.hooks.watchClose.tap('TsCheckerRspackPlugin', abortTypeScriptGo);
4499
+ compiler.hooks.watchClose.tap('TsCheckerRspackPlugin', ()=>{
4500
+ canReuseIssues = false;
4501
+ dependenciesCacheGeneration++;
4502
+ dependenciesPromise = void 0;
4503
+ abortTypeScriptGo();
4504
+ });
4362
4505
  compiler.hooks.failed.tap('TsCheckerRspackPlugin', ()=>{
4506
+ canReuseIssues = false;
4507
+ dependenciesCacheGeneration++;
4508
+ dependenciesPromise = void 0;
4363
4509
  if (!state.watching) abortTypeScriptGo();
4364
4510
  });
4365
4511
  }
@@ -1,3 +1,3 @@
1
- export * from './issue';
2
- export * from './issue-severity';
3
- export * from './issue-location';
1
+ export * from './issue.js';
2
+ export * from './issue-severity.js';
3
+ export * from './issue-location.js';
@@ -1,7 +1,7 @@
1
1
  import type * as rspack from '@rspack/core';
2
- import type { IssueOptions } from './issue-options';
3
- import type { IssuePredicate } from './issue-predicate';
4
- import type { IssueDefaultSeverity } from './issue-severity';
2
+ import type { IssueOptions } from './issue-options.js';
3
+ import type { IssuePredicate } from './issue-predicate.js';
4
+ import type { IssueDefaultSeverity } from './issue-severity.js';
5
5
  interface IssueConfig {
6
6
  predicate: IssuePredicate;
7
7
  defaultSeverity: IssueDefaultSeverity;
@@ -1,4 +1,4 @@
1
- import type { IssuePosition } from './issue-position';
1
+ import type { IssuePosition } from './issue-position.js';
2
2
  interface IssueLocation {
3
3
  start: IssuePosition;
4
4
  end: IssuePosition;
@@ -1,5 +1,5 @@
1
- import type { IssuePredicate } from './issue-predicate';
2
- import type { Issue } from './index';
1
+ import type { IssuePredicate } from './issue-predicate.js';
2
+ import type { Issue } from './index.js';
3
3
  type IssueMatch = Partial<Pick<Issue, 'severity' | 'code' | 'file'>>;
4
4
  declare function createIssuePredicateFromIssueMatch(context: string, match: IssueMatch): IssuePredicate;
5
5
  export { createIssuePredicateFromIssueMatch };
@@ -1,6 +1,6 @@
1
- import type { IssueMatch } from './issue-match';
2
- import type { IssuePredicate } from './issue-predicate';
3
- import type { IssueDefaultSeverity } from './issue-severity';
1
+ import type { IssueMatch } from './issue-match.js';
2
+ import type { IssuePredicate } from './issue-predicate.js';
3
+ import type { IssueDefaultSeverity } from './issue-severity.js';
4
4
  type IssuePredicateOption = IssuePredicate | IssueMatch | (IssuePredicate | IssueMatch)[];
5
5
  interface IssueOptions {
6
6
  include?: IssuePredicateOption;
@@ -1,4 +1,4 @@
1
- import type { Issue } from './index';
1
+ import type { Issue } from './index.js';
2
2
  type IssuePredicate = (issue: Issue) => boolean;
3
3
  declare function createTrivialIssuePredicate(result: boolean): IssuePredicate;
4
4
  declare function composeIssuePredicates(predicates: IssuePredicate[]): IssuePredicate;
@@ -1,5 +1,5 @@
1
- import type { FormatterPathType } from '../formatter';
2
- import type { Issue } from './issue';
1
+ import type { FormatterPathType } from '../formatter/index.js';
2
+ import type { Issue } from './issue.js';
3
3
  declare class IssueRspackError extends Error {
4
4
  readonly issue: Issue;
5
5
  readonly hideStack = true;
@@ -1,5 +1,5 @@
1
- import type { IssueLocation } from './issue-location';
2
- import type { IssueSeverity } from './issue-severity';
1
+ import type { IssueLocation } from './issue-location.js';
2
+ import type { IssueSeverity } from './issue-severity.js';
3
3
  interface Issue {
4
4
  severity: IssueSeverity;
5
5
  code: string;
@@ -1,9 +1,9 @@
1
1
  import type * as rspack from '@rspack/core';
2
- import type { FormatterConfig } from './formatter';
3
- import type { IssueConfig } from './issue/issue-config';
4
- import type { Logger } from './logger';
5
- import type { TsCheckerRspackPluginOptions } from './plugin-options';
6
- import type { TypeScriptWorkerConfig } from './typescript/type-script-worker-config';
2
+ import type { FormatterConfig } from './formatter/index.js';
3
+ import type { IssueConfig } from './issue/issue-config.js';
4
+ import type { Logger } from './logger.js';
5
+ import type { TsCheckerRspackPluginOptions } from './plugin-options.js';
6
+ import type { TypeScriptWorkerConfig } from './typescript/type-script-worker-config.js';
7
7
  interface TsCheckerRspackPluginConfig {
8
8
  async: boolean;
9
9
  typescript: TypeScriptWorkerConfig;