-
-
Notifications
You must be signed in to change notification settings - Fork 360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: make --all work for transpiled code #1047
Conversation
8 similar comments
Does this resolves any of the issues where |
lib/source-maps.js
Outdated
@@ -4,12 +4,12 @@ const libSourceMaps = require('istanbul-lib-source-maps') | |||
const fs = require('fs') | |||
const path = require('path') | |||
|
|||
// TODO: write some unit tests for this class. | |||
let sourceMapCache = libSourceMaps.createSourceMapStore() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused about how this can have any effective change. The SourceMaps
object is only created by the NYC object as nyc.sourceMaps
. Since each process only gets one object, the singleton doesn't actually get reused by multiple SourceMaps objects. My vote is that we don't use singletons if it can be avoided.
Above aside if this is kept as a singleton variable I think it should be const
, not let
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be a const
.
The issue is that we new NYC()
during instrumentation, and then also new NYC()
in report
and check
steps. I agree that singletons are often a bad pattern, but in the case of a cache I believe it's the correct behavior (it should be a cache of source-maps that exist for the processes lifecycle).
lib/source-maps.js
Outdated
} | ||
} | ||
return sourceMap | ||
} | ||
|
||
SourceMaps.prototype.remapCoverage = function (obj) { | ||
var transformed = this.sourceMapCache.transformCoverage( | ||
var transformed = this._sourceMapCache.transformCoverage( | ||
libCoverage.createCoverageMap(obj) | ||
) | ||
return transformed.map.data | ||
} | ||
|
||
SourceMaps.prototype.reloadCachedSourceMaps = function (report) { | ||
var _this = this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you are converting to an arrow function would you mind dropping _this
and updating the whole function to use this
directly?
during normal operation nyc will instantiate SourceMaps multiple times:
Because
--all
does not save source-maps to cache (as is the case when files are loaded during normal execution) the source-maps extracted by--all
are dropped on the floor and never used.This tiny fix makes source-maps start working in conjunction with
--all
.