Potential performance overhead in ts-loader's disabled resolver

Abierto
#1,722 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
55/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
typescript, webpack

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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?

Lenguaje dominante
TypeScript
Estrellas
3.5k
Forks
439
Merge medio
8 h 6 min
PR fusionados (30 d)
12

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de TypeStrong/ts-loader

Todos los issues de TypeStrong/ts-loader

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.