microsoft / microsoft/TypeScript

Write typescript as modules, but output js without modules

Abierto
#39,446 8 comentarios 17 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Awaiting More Feedback Suggestion
Lenguaje dominante
Go
Estrellas
111k
Forks
14.3k
Merge medio
2 d 4 h
PR fusionados (30 d)
132

Descripción

Search Terms

Searched the whole internet for anything like it, only webpack and browserify related 'solutions' are proposed.

Suggestion

Split module options in tsconfig so typescript modules could be set separately from output target modules.

Use Cases

Our usecase:

  • We have a huge codebase, and we want to slowly move to typescript.
  • We have a sophisticated build system that we don't want to change - we want typescript to transpile to js and to take js and continue to use it as we were.
  • We don't need nor want to use modules in js. We never used modules - we have our system of imports, minification,
    versioning, caching, etc.
  • The only reason why we need to use modules in typescript is tsc incremental watch build. With no modules, it builds complete codebase on each change. We want to build only file changed and dependent files.

So currently we have two bad options - don't use modules (unacceptably slow build time) or use modules (get the output that we don't want). Currently we 'mitigate' the issue by removing parts of js tsc has output (removing stuff we recognize as related to exports and require), but that's just terrible.

Even worse, even if we were to use modules, require / exports are inlined even in output we want to inline to index.html as critical JS...

Examples

I guess I explained it all above.

Checklist

My suggestion meets these guidelines:

  • [ * ] This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • [ * ] This wouldn't change the runtime behavior of existing JavaScript code
  • [ * ] This could be implemented without emitting different JS based on the types of the expressions
  • [ * ] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • [ * ] This feature would agree with the rest of TypeScript's Design Goals.

Guía de contribución

Abrir la guía de contribución

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.

Línea de trabajo

Comienza revisando las opciones de módulo de tsconfig y el comportamiento de la compilación incremental en modo watch descrito en el issue. Determina cómo deberían interactuar las configuraciones independientes del módulo fuente y del módulo emitido, y verifica después que TypeScript pueda emitir JavaScript no modular manteniendo las compilaciones incrementales basadas en módulos.

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

Evaluación

Stack tecnológico
javascript, typescript
Área
build-system, compilers
Tipo de issue
Nueva funcionalidad
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
30/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.