evanw / evanw/node-source-map-support
if require('coffee-script').register() is called after require('source-map-support').install() then source maps no longer function for exception traces
- Lenguaje dominante
- JavaScript
- Estrellas
- 2.2k
- Forks
- 223
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
Here is the demo modified to demonstrate the issue:
``` coffee
require('source-map-support').install()
require("coffee-script").register()
foo = ->
bar = -> throw new Error 'this is a demo'
bar()
foo()
```
I encounter this problem because I have a module which is intended to 'require' some 'user' editable coffee-script configuration code -- if at any time after initializing source-map-support I later initialize the coffee-script support so that the node module loader can require .coffee files without pre-compiling, then the source-map-support exception rewriting behavior fails to function globally in my app ...
If I change the order the source-map-support and coffee-script modules are initialized in, then things work as expected:
``` coffee
require("coffee-script").register()
require('source-map-support').install()
foo = ->
bar = -> throw new Error 'this is a demo'
bar()
foo()
```
However this means I need to _ensure_ that my process initializes the coffee-script module prior to initializing the source-map-support module -- even if enter my code through paths for which coffee-script support is not required at that time ... Particularly I encountered this issue when unit testing -- units tests give arbitrary entry points into my application's code where I wouldn't have thought I would need to initialize the coffee-script module unless/until its needed ... its a bit ugly that I _must_ initialize coffee-script within the context of my unit tests so that I can enforce correct initialization order of the two modules ...
Is there a good workaround for this? The safest thing I can come up with is to add a new module which initializes both source-map-support and coffee-script in the correct order in my code -- and use that throughout my project's code anywhere I would've used require('source-map-support').install() ...
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
Comienza con el orden de inicialización demostrado usando source-map-support.install() y coffee-script.register(). Rastrea cómo registrar CoffeeScript después de instalar source-map-support afecta a la reescritura de la pila de excepciones. Se considera terminado cuando la traza de excepción de CoffeeScript proporcionada sigue usando source maps independientemente de cuál de los dos módulos se inicialice primero.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript
- Área
- backend
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100