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

Aperta
#34 9 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
JavaScript
Stelle
2.2k
Fork
223
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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() ...

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.