Potential performance overhead in ts-loader's disabled resolver

オープン
#1,722 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
typescript, webpack

調査の方向性

Start with src/resolver.ts and trace how servicesHost.resolveModule handles the resolver result and falls back to TypeScript. Compare the disabled resolver's behavior with the reported return false experiment, then check the existing tests for fallback and diagnostics. Done means avoiding per-call exception overhead while preserving fallback and diagnostic behavior.

索引モデルが issue の本文から書いたものです。

説明

Potential performance overhead in ts-loader's disabled resolver

Problem

In ts-loader v9.6.2, makeResolver returns a function that always throws. servicesHost.resolveModule catches the exception and continues with TypeScript's resolver. Could this disabled path avoid the exception overhead while preserving the existing fallback behavior?

This is a performance question, separate from the functional enhanced-resolve issue in #1492. PR #1701 notes that the resolver was already disabled before that change. This report does not propose restoring enhanced-resolve.

Measurements

I compared v9.6.2 with an experimental change that replaces throw new Error() in src/resolver.ts with return false. false is allowed by ResolveSync, and the caller continues to TypeScript's resolver. This is one possible implementation, not a proposed definitive fix.

In our private application, two local initial-build comparisons measured:

Run Existing configuration Avoiding the resolver throw Reduction
1 73.4 s 39.0 s 34.4 s (46.9%)
2 75.5 s 43.1 s 32.4 s (42.9%)

The generated assets matched except for webpack's compilation hash in runtime.js. The application source and CPU profile are private, so these results are specific to our project and environment.

The published resolver-overhead reproduction fixture is generated and contains no application source. It was run with Node 24.14.1, TypeScript 6.0.3, and webpack 5.112.2. With 300 view modules and a resolution fan-out of 2,100, it produced 634,051 resolver calls per build. After one warmup, the median of three paired initial builds was:

Resolver behavior Median initial build
Throw and catch 51.71 s
Return no result 42.71 s

Both modes reported zero errors and warnings and emitted byte-identical bundles. The fixture's dense import fan-out was chosen to approximate our call volume; these timings do not predict a general application-level speedup.

Correctness check

In a separate small transpileOnly: false watch fixture, both variants emitted byte-identical initial bundles and reported the same TS2322 diagnostic after a source change. These checks cover only the tested configuration.

Could the disabled resolver return no result, or use another approach, to avoid throwing on every call while preserving TypeScript fallback and diagnostics?

主要言語
TypeScript
スター
3.5k
フォーク
439
平均マージ
8時間 6分
マージ済み PR(30日)
12

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

TypeStrong/ts-loader のほかの issue

TypeStrong/ts-loader の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。