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
- Langage dominant
- JavaScript
- Étoiles
- 2.2k
- Forks
- 223
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
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() ...
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Piste de recherche
Commencez par l’ordre d’initialisation démontré en utilisant source-map-support.install() et coffee-script.register(). Suivez comment l’enregistrement de CoffeeScript après l’installation de source-map-support affecte la réécriture de la pile d’exception. C’est terminé lorsque la trace d’exception CoffeeScript fournie utilise toujours les source maps, quel que soit celui des deux modules qui est initialisé en premier.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- javascript
- Domaine
- backend
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100