Expose emitted module specifiers on AMD outfile emit

Abierto
#35,052 4 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

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

Línea de trabajo

Comienza rastreando los componentes internos del emisor de TypeScript que determinan los especificadores de módulos AMD al emitir a un único archivo de salida. Revisa la API del compilador en torno a SourceFile.fileName, SourceFile[] y Host.writeFile, y después define cómo deben exponerse los especificadores emitidos. Se considera terminado cuando los consumidores pueden obtener los especificadores exactos contenidos en el bundle escrito sin tener que adivinarlos.

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

Descripción

In Discussion Suggestion

Search Terms

amd outfile module specifier

Suggestion

Currently when utilising the compiler APIs to emit as AMD to a single outfile, the emitted module specifier in the outfile is not exposed, but does not match the source file SourceFile.fileName or any other attribute.

It appears that there are internals of the TypeScript emitter which determine the module specifier that is included output. For example, if given /foo/bar/baz.ts and /foo/qat/qux.ts being part of the same program, when emitted as AMD in a single bundle the module specifier, the outfile will define() a module named bar/baz and qat/qux. It appears that the algorithm used looks for the common root and removes the extension to determine the module specifier.

Use Cases

When loading the bundle with an AMD loader, knowing what a module specifier is in the outfile is needed to be able to specify a module to load in a require() statement. So if we were automating a custom build, outputting a "bundle" and determining which module to require() to bootstrap the application, we have to "guess" and hope that the emitter doesn't change its algorithm of determining the module specifiers.

Examples

I'm not totally sure, but a public API that would take a SourceFile[] and provide back a string[] array of module specifiers. This could be used in Host.writeFile() to determine what module specifiers are contained in the written file.

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.
Lenguaje dominante
Go
Estrellas
111k
Forks
14.4k
Merge medio
1 d 19 h
PR fusionados (30 d)
117

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.

Más de microsoft/TypeScript

Todos los issues de microsoft/TypeScript

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.