node-source-map-support icon indicating copy to clipboard operation
node-source-map-support copied to clipboard

Export a removeFromCache(filepath) function

Open gabelevi opened this issue 9 years ago • 1 comments

require('source-map-support').removeFromCache('path/to/foo.js') will remove path/to/foo.js from the source map cache.

Motivation

I use am using babel-register. At some point, my program notices that a file changes. So it calls

delete require.cache[require.resolve(filename)]
return require('filename');

Expected behavior

Stack traces show lines/columns from the updated file

Actual behavior

Stack traces still use the old source maps, so the locations are out of date

How this helps

After this lands, I can update babel-register to call removeFromCache(filename) whenever it transforms a file.

gabelevi avatar Sep 08 '16 23:09 gabelevi

If #118 lands, then this will happen automatically, I believe.

kpdecker avatar Oct 10 '16 11:10 kpdecker