@teamscale/javascript-instrumenter 0.0.1-beta.40 → 0.0.1-beta.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamscale/javascript-instrumenter",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.41",
|
|
4
4
|
"description": "Istanbul-based coverage instrumenter with coverage forwarding via WebSockets",
|
|
5
5
|
"main": "dist/src/main.js",
|
|
6
6
|
"bin": "dist/src/main.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"build": "tsc --project tsconfig.json && yarn buildVaccine",
|
|
18
18
|
"buildVaccine": "node esbuild.mjs",
|
|
19
19
|
"instrumenter": "node dist/src/main.js",
|
|
20
|
-
"test": "yarn build && NODE_OPTIONS='--experimental-vm-modules' jest --forceExit --coverage --silent=true --detectOpenHandles"
|
|
20
|
+
"test": "yarn build && NODE_OPTIONS='--experimental-vm-modules --max-old-space-size=8192' jest --forceExit --coverage --silent=true --detectOpenHandles"
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
23
23
|
"dist/**/*"
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"convert-source-map": "^1.7.0",
|
|
60
60
|
"foreground-child": "^2.0.0",
|
|
61
61
|
"glob": "^7.1.7",
|
|
62
|
-
"istanbul-lib-instrument": "^
|
|
62
|
+
"istanbul-lib-instrument": "^5.2.0",
|
|
63
63
|
"micromatch": "4.0.4",
|
|
64
64
|
"mkdirp": "^1.0.4",
|
|
65
65
|
"nyc": "^15.1.0",
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { CollectorSpecifier, InstrumentationTask, OriginSourcePattern, TaskElement, TaskResult } from './Task';
|
|
1
|
+
import { CollectorSpecifier, InstrumentationTask, OriginSourcePattern, SourceMapReference, TaskElement, TaskResult } from './Task';
|
|
2
|
+
import { RawSourceMap, SourceMapConsumer } from 'source-map';
|
|
3
|
+
import { Optional } from 'typescript-optional';
|
|
2
4
|
import Logger from 'bunyan';
|
|
3
5
|
export declare const IS_INSTRUMENTED_TOKEN = "/** $IS_JS_PROFILER_INSTRUMENTED=true **/";
|
|
4
6
|
/**
|
|
@@ -41,22 +43,12 @@ export declare class IstanbulInstrumenter implements IInstrumenter {
|
|
|
41
43
|
*/
|
|
42
44
|
instrumentOne(collector: CollectorSpecifier, taskElement: TaskElement, sourcePattern: OriginSourcePattern, dumpOriginsFile: string | undefined): Promise<TaskResult>;
|
|
43
45
|
private removeUnwantedInstrumentation;
|
|
44
|
-
private loadSourceMap;
|
|
45
46
|
/**
|
|
46
47
|
* Loads the vaccine from the vaccine file and adjusts some template parameters.
|
|
47
48
|
*
|
|
48
49
|
* @param collector - The collector to send coverage information to.
|
|
49
50
|
*/
|
|
50
51
|
private loadVaccine;
|
|
51
|
-
/**
|
|
52
|
-
* Should the given file be excluded from the instrumentation,
|
|
53
|
-
* based on the source files that have been transpiled into it?
|
|
54
|
-
*
|
|
55
|
-
* @param pattern - The pattern to match the origin source files.
|
|
56
|
-
* @param sourceFile - The bundle file name.
|
|
57
|
-
* @param originSourceFiles - The list of files that were transpiled into the bundle.
|
|
58
|
-
*/
|
|
59
|
-
private shouldExcludeFromInstrumentation;
|
|
60
52
|
/**
|
|
61
53
|
* @returns whether the given file is supported for instrumentation.
|
|
62
54
|
*/
|
|
@@ -66,17 +58,37 @@ export declare class IstanbulInstrumenter implements IInstrumenter {
|
|
|
66
58
|
* given task element.
|
|
67
59
|
*/
|
|
68
60
|
private configurationAlternativesFor;
|
|
69
|
-
/**
|
|
70
|
-
* Given a source code file, load the corresponding sourcemap.
|
|
71
|
-
*
|
|
72
|
-
* @param inputSource - The source code that might contain sourcemap comments.
|
|
73
|
-
* @param taskFile - The name of the file the `inputSource` is from.
|
|
74
|
-
* @param externalSourceMapFile - An external source map file to consider.
|
|
75
|
-
*/
|
|
76
|
-
private loadInputSourceMap;
|
|
77
61
|
/** Appends all origins from the source map to a given file. Creates the file if it does not exist yet. */
|
|
78
62
|
private dumpOrigins;
|
|
79
63
|
/** Clears the dump origins file if it exists, such that it is now ready to be appended for every instrumented file. */
|
|
80
64
|
private clearDumpOriginsFileIfNeeded;
|
|
81
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Extract the sourcemap from the given source code.
|
|
68
|
+
*
|
|
69
|
+
* @param instrumentedSource - The source code.
|
|
70
|
+
* @param instrumentedSourceFileName - The file name to assume for the file name.
|
|
71
|
+
*/
|
|
72
|
+
export declare function loadSourceMap(instrumentedSource: string, instrumentedSourceFileName: string): Promise<SourceMapConsumer | undefined>;
|
|
73
|
+
/**
|
|
74
|
+
* Given a source code file, load the corresponding sourcemap.
|
|
75
|
+
*
|
|
76
|
+
* @param inputSource - The source code that might contain sourcemap comments.
|
|
77
|
+
* @param taskFile - The name of the file the `inputSource` is from.
|
|
78
|
+
* @param externalSourceMapFile - An external source map file to consider.
|
|
79
|
+
*/
|
|
80
|
+
export declare function loadInputSourceMap(inputSource: string, taskFile: string, externalSourceMapFile: Optional<SourceMapReference>): RawSourceMap | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* Extract a sourcemap for a given code comment.
|
|
83
|
+
*
|
|
84
|
+
* @param sourcecode - The source code that is scanned for source map comments.
|
|
85
|
+
* @param sourceFilePath - The file name the code was loaded from.
|
|
86
|
+
*/
|
|
87
|
+
export declare function sourceMapFromCodeComment(sourcecode: string, sourceFilePath: string): RawSourceMap | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* Read a source map from a source map file.
|
|
90
|
+
*
|
|
91
|
+
* @param mapFilePath
|
|
92
|
+
*/
|
|
93
|
+
export declare function sourceMapFromMapFile(mapFilePath: string): RawSourceMap | undefined;
|
|
82
94
|
//# sourceMappingURL=Instrumenter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Instrumenter.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/Instrumenter.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"Instrumenter.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/Instrumenter.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EAEnB,kBAAkB,EAClB,WAAW,EACX,UAAU,EACV,MAAM,QAAQ,CAAC;AAEhB,OAAO,EAAY,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAOvE,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,MAAM,MAAM,QAAQ,CAAC;AAG5B,eAAO,MAAM,qBAAqB,8CAA8C,CAAC;AAEjF;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B;;;;OAIG;IACH,UAAU,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CAC3D;AAED;;GAEG;AACH,qBAAa,oBAAqB,YAAW,aAAa;IACzD;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IAEzC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAS;gBAEX,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IASnD;;OAEG;IACG,UAAU,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC;IAqBhE;;;;;;;OAOG;IACG,aAAa,CAClB,SAAS,EAAE,kBAAkB,EAC7B,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,mBAAmB,EAClC,eAAe,EAAE,MAAM,GAAG,SAAS,GACjC,OAAO,CAAC,UAAU,CAAC;YAuGR,6BAA6B;IA8C3C;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAMnB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAK3B;;;OAGG;IACH,OAAO,CAAC,4BAA4B;IAcpC,0GAA0G;IAC1G,OAAO,CAAC,WAAW;IASnB,uHAAuH;IACvH,OAAO,CAAC,4BAA4B;CASpC;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CAClC,kBAAkB,EAAE,MAAM,EAC1B,0BAA0B,EAAE,MAAM,GAChC,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAUxC;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CACjC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,qBAAqB,EAAE,QAAQ,CAAC,kBAAkB,CAAC,GACjD,YAAY,GAAG,SAAS,CAU1B;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAsC7G;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAGlF"}
|
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.IstanbulInstrumenter = exports.IS_INSTRUMENTED_TOKEN = void 0;
|
|
29
|
+
exports.sourceMapFromMapFile = exports.sourceMapFromCodeComment = exports.loadInputSourceMap = exports.loadSourceMap = exports.IstanbulInstrumenter = exports.IS_INSTRUMENTED_TOKEN = void 0;
|
|
30
30
|
const Task_1 = require("./Task");
|
|
31
31
|
const commons_1 = require("@cqse/commons");
|
|
32
32
|
const source_map_1 = require("source-map");
|
|
@@ -99,7 +99,7 @@ class IstanbulInstrumenter {
|
|
|
99
99
|
let inputSourceMap;
|
|
100
100
|
try {
|
|
101
101
|
const instrumenter = istanbul.createInstrumenter(configurationAlternative);
|
|
102
|
-
inputSourceMap =
|
|
102
|
+
inputSourceMap = loadInputSourceMap(inputFileSource, taskElement.fromFile, taskElement.externalSourceMapFile);
|
|
103
103
|
// Based on the source maps of the file to instrument, we can now
|
|
104
104
|
// decide if we should NOT write an instrumented version of it
|
|
105
105
|
// and use the original code instead and write it to the target path.
|
|
@@ -108,26 +108,23 @@ class IstanbulInstrumenter {
|
|
|
108
108
|
if (dumpOriginsFile) {
|
|
109
109
|
this.dumpOrigins(dumpOriginsFile, originSourceFiles);
|
|
110
110
|
}
|
|
111
|
-
if (this.shouldExcludeFromInstrumentation(sourcePattern, taskElement.fromFile, originSourceFiles)) {
|
|
112
|
-
writeToFile(taskElement.toFile, inputFileSource);
|
|
113
|
-
return new Task_1.TaskResult(0, 1, 0, 0, 0, 0, 0);
|
|
114
|
-
}
|
|
115
111
|
// The main instrumentation (adding coverage statements) is performed now:
|
|
116
|
-
instrumentedSource = instrumenter
|
|
117
|
-
.instrumentSync(inputFileSource, taskElement.fromFile, inputSourceMap)
|
|
118
|
-
.replace(/actualCoverage\s*=\s*coverage\[path\]/g, 'actualCoverage=makeCoverageInterceptor(coverage[path])')
|
|
119
|
-
.replace(/new Function\("return this"\)\(\)/g, "typeof window === 'object' ? window : this");
|
|
112
|
+
instrumentedSource = instrumenter.instrumentSync(inputFileSource, taskElement.fromFile, inputSourceMap);
|
|
120
113
|
this.logger.debug('Instrumentation source maps to:', (_b = instrumenter.lastSourceMap()) === null || _b === void 0 ? void 0 : _b.sources);
|
|
121
114
|
// In case of a bundle, the initial instrumentation step might have added
|
|
122
115
|
// too much and undesired instrumentations. Remove them now.
|
|
123
|
-
|
|
116
|
+
const instrumentedSourcemap = instrumenter.lastSourceMap();
|
|
117
|
+
let instrumentedAndCleanedSource = await this.removeUnwantedInstrumentation(taskElement, instrumentedSource, configurationAlternative, sourcePattern, instrumentedSourcemap);
|
|
118
|
+
instrumentedAndCleanedSource = instrumentedAndCleanedSource
|
|
119
|
+
.replace(/actualCoverage\s*=\s*coverage\[path\]/g, 'actualCoverage=makeCoverageInterceptor(coverage[path])')
|
|
120
|
+
.replace(/new Function\("return this"\)\(\)/g, "typeof window === 'object' ? window : this");
|
|
124
121
|
// The process also can result in a new source map that we will append in the result.
|
|
125
122
|
//
|
|
126
123
|
// `lastSourceMap` === Sourcemap for the last file that was instrumented.
|
|
127
124
|
finalSourceMap = convertSourceMap.fromObject(instrumenter.lastSourceMap()).toComment();
|
|
128
125
|
// We now can glue together the final version of the instrumented file.
|
|
129
126
|
const vaccineSource = this.loadVaccine(collector);
|
|
130
|
-
writeToFile(taskElement.toFile, `${exports.IS_INSTRUMENTED_TOKEN} ${vaccineSource} ${
|
|
127
|
+
writeToFile(taskElement.toFile, `${exports.IS_INSTRUMENTED_TOKEN} ${vaccineSource} ${instrumentedAndCleanedSource} \n${finalSourceMap}`);
|
|
131
128
|
return new Task_1.TaskResult(1, 0, 0, 0, 0, 0, 0);
|
|
132
129
|
}
|
|
133
130
|
catch (e) {
|
|
@@ -144,13 +141,13 @@ class IstanbulInstrumenter {
|
|
|
144
141
|
}
|
|
145
142
|
return new Task_1.TaskResult(0, 0, 0, 0, 0, 1, 0);
|
|
146
143
|
}
|
|
147
|
-
async removeUnwantedInstrumentation(taskElement, instrumentedSource, configurationAlternative, sourcePattern) {
|
|
148
|
-
|
|
149
|
-
const instrumentedSourceMapConsumer = await this.loadSourceMap(instrumentedSource, taskElement.fromFile);
|
|
144
|
+
async removeUnwantedInstrumentation(taskElement, instrumentedSource, configurationAlternative, sourcePattern, instrumentedSourcemap) {
|
|
145
|
+
const instrumentedSourceMapConsumer = await new source_map_1.SourceMapConsumer(instrumentedSourcemap);
|
|
150
146
|
// Without a source map, excludes/includes do not work.
|
|
151
147
|
if (!instrumentedSourceMapConsumer) {
|
|
152
148
|
return instrumentedSource;
|
|
153
149
|
}
|
|
150
|
+
const removedInstrumentationFor = new Set();
|
|
154
151
|
// Remove the unwanted instrumentation
|
|
155
152
|
const cleaned = (0, Cleaner_1.cleanSourceCode)(instrumentedSource, configurationAlternative.esModules, location => {
|
|
156
153
|
const originalPosition = instrumentedSourceMapConsumer.originalPositionFor({
|
|
@@ -158,21 +155,22 @@ class IstanbulInstrumenter {
|
|
|
158
155
|
column: location.start.column
|
|
159
156
|
});
|
|
160
157
|
if (!originalPosition.source) {
|
|
161
|
-
return
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
const isToCover = sourcePattern.isAnyIncluded([originalPosition.source]);
|
|
161
|
+
if (!isToCover) {
|
|
162
|
+
removedInstrumentationFor.add(originalPosition.source);
|
|
162
163
|
}
|
|
163
|
-
return
|
|
164
|
+
return isToCover;
|
|
164
165
|
});
|
|
166
|
+
if (removedInstrumentationFor.size) {
|
|
167
|
+
this.logger.info(`Removed from ${taskElement.toFile} instrumentation for:`);
|
|
168
|
+
removedInstrumentationFor.forEach(entry => this.logger.info(entry));
|
|
169
|
+
}
|
|
165
170
|
// Explicitly free the source map to avoid memory leaks
|
|
166
171
|
instrumentedSourceMapConsumer.destroy();
|
|
167
172
|
return cleaned;
|
|
168
173
|
}
|
|
169
|
-
async loadSourceMap(instrumentedSource, instrumentedSourceFileName) {
|
|
170
|
-
const instrumentedSourceMap = this.loadInputSourceMap(instrumentedSource, instrumentedSourceFileName, typescript_optional_1.Optional.empty());
|
|
171
|
-
if (instrumentedSourceMap) {
|
|
172
|
-
return await new source_map_1.SourceMapConsumer(instrumentedSourceMap);
|
|
173
|
-
}
|
|
174
|
-
return undefined;
|
|
175
|
-
}
|
|
176
174
|
/**
|
|
177
175
|
* Loads the vaccine from the vaccine file and adjusts some template parameters.
|
|
178
176
|
*
|
|
@@ -183,17 +181,6 @@ class IstanbulInstrumenter {
|
|
|
183
181
|
// actual values, for example, the collector to send the coverage information to.
|
|
184
182
|
return fs.readFileSync(this.vaccineFilePath, 'utf8').replace(/\$REPORT_TO_URL/g, collector.url);
|
|
185
183
|
}
|
|
186
|
-
/**
|
|
187
|
-
* Should the given file be excluded from the instrumentation,
|
|
188
|
-
* based on the source files that have been transpiled into it?
|
|
189
|
-
*
|
|
190
|
-
* @param pattern - The pattern to match the origin source files.
|
|
191
|
-
* @param sourceFile - The bundle file name.
|
|
192
|
-
* @param originSourceFiles - The list of files that were transpiled into the bundle.
|
|
193
|
-
*/
|
|
194
|
-
shouldExcludeFromInstrumentation(pattern, sourceFile, originSourceFiles) {
|
|
195
|
-
return !pattern.isAnyIncluded(originSourceFiles);
|
|
196
|
-
}
|
|
197
184
|
/**
|
|
198
185
|
* @returns whether the given file is supported for instrumentation.
|
|
199
186
|
*/
|
|
@@ -209,32 +196,13 @@ class IstanbulInstrumenter {
|
|
|
209
196
|
this.logger.debug(`Determining configuration alternatives for ${taskElement.fromFile}`);
|
|
210
197
|
const baseConfig = {
|
|
211
198
|
coverageVariable: '__coverage__',
|
|
212
|
-
produceSourceMap:
|
|
199
|
+
produceSourceMap: 'both'
|
|
213
200
|
};
|
|
214
201
|
return [
|
|
215
202
|
{ ...baseConfig, ...{ esModules: true } },
|
|
216
203
|
{ ...baseConfig, ...{ esModules: false } }
|
|
217
204
|
];
|
|
218
205
|
}
|
|
219
|
-
/**
|
|
220
|
-
* Given a source code file, load the corresponding sourcemap.
|
|
221
|
-
*
|
|
222
|
-
* @param inputSource - The source code that might contain sourcemap comments.
|
|
223
|
-
* @param taskFile - The name of the file the `inputSource` is from.
|
|
224
|
-
* @param externalSourceMapFile - An external source map file to consider.
|
|
225
|
-
*/
|
|
226
|
-
loadInputSourceMap(inputSourceCode, taskFile, externalSourceMapFile) {
|
|
227
|
-
if (externalSourceMapFile.isPresent()) {
|
|
228
|
-
const sourceMapOrigin = externalSourceMapFile.get();
|
|
229
|
-
if (!(sourceMapOrigin instanceof Task_1.SourceMapFileReference)) {
|
|
230
|
-
throw new commons_1.IllegalArgumentException('Type of source map not yet supported!');
|
|
231
|
-
}
|
|
232
|
-
return sourceMapFromMapFile(sourceMapOrigin.sourceMapFilePath);
|
|
233
|
-
}
|
|
234
|
-
else {
|
|
235
|
-
return sourceMapFromCodeComment(inputSourceCode, taskFile);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
206
|
/** Appends all origins from the source map to a given file. Creates the file if it does not exist yet. */
|
|
239
207
|
dumpOrigins(dumpOriginsFile, originSourceFiles) {
|
|
240
208
|
const jsonContent = JSON.stringify(originSourceFiles, null, 2);
|
|
@@ -257,6 +225,40 @@ class IstanbulInstrumenter {
|
|
|
257
225
|
}
|
|
258
226
|
}
|
|
259
227
|
exports.IstanbulInstrumenter = IstanbulInstrumenter;
|
|
228
|
+
/**
|
|
229
|
+
* Extract the sourcemap from the given source code.
|
|
230
|
+
*
|
|
231
|
+
* @param instrumentedSource - The source code.
|
|
232
|
+
* @param instrumentedSourceFileName - The file name to assume for the file name.
|
|
233
|
+
*/
|
|
234
|
+
async function loadSourceMap(instrumentedSource, instrumentedSourceFileName) {
|
|
235
|
+
const instrumentedSourceMap = loadInputSourceMap(instrumentedSource, instrumentedSourceFileName, typescript_optional_1.Optional.empty());
|
|
236
|
+
if (instrumentedSourceMap) {
|
|
237
|
+
return await new source_map_1.SourceMapConsumer(instrumentedSourceMap);
|
|
238
|
+
}
|
|
239
|
+
return undefined;
|
|
240
|
+
}
|
|
241
|
+
exports.loadSourceMap = loadSourceMap;
|
|
242
|
+
/**
|
|
243
|
+
* Given a source code file, load the corresponding sourcemap.
|
|
244
|
+
*
|
|
245
|
+
* @param inputSource - The source code that might contain sourcemap comments.
|
|
246
|
+
* @param taskFile - The name of the file the `inputSource` is from.
|
|
247
|
+
* @param externalSourceMapFile - An external source map file to consider.
|
|
248
|
+
*/
|
|
249
|
+
function loadInputSourceMap(inputSource, taskFile, externalSourceMapFile) {
|
|
250
|
+
if (externalSourceMapFile.isPresent()) {
|
|
251
|
+
const sourceMapOrigin = externalSourceMapFile.get();
|
|
252
|
+
if (!(sourceMapOrigin instanceof Task_1.SourceMapFileReference)) {
|
|
253
|
+
throw new commons_1.IllegalArgumentException('Type of source map not yet supported!');
|
|
254
|
+
}
|
|
255
|
+
return sourceMapFromMapFile(sourceMapOrigin.sourceMapFilePath);
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
return sourceMapFromCodeComment(inputSource, taskFile);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
exports.loadInputSourceMap = loadInputSourceMap;
|
|
260
262
|
/**
|
|
261
263
|
* Extract a sourcemap for a given code comment.
|
|
262
264
|
*
|
|
@@ -290,11 +292,11 @@ function sourceMapFromCodeComment(sourcecode, sourceFilePath) {
|
|
|
290
292
|
// One JS file can refer to several source map files in its comments.
|
|
291
293
|
failedLoading++;
|
|
292
294
|
}
|
|
293
|
-
if (result) {
|
|
294
|
-
return result;
|
|
295
|
-
}
|
|
296
295
|
}
|
|
297
296
|
} while (matched);
|
|
297
|
+
if (result) {
|
|
298
|
+
return result;
|
|
299
|
+
}
|
|
298
300
|
if (failedLoading > 0) {
|
|
299
301
|
throw new commons_1.IllegalArgumentException('None of the referenced source map files loaded!');
|
|
300
302
|
}
|
|
@@ -302,6 +304,7 @@ function sourceMapFromCodeComment(sourcecode, sourceFilePath) {
|
|
|
302
304
|
return undefined;
|
|
303
305
|
}
|
|
304
306
|
}
|
|
307
|
+
exports.sourceMapFromCodeComment = sourceMapFromCodeComment;
|
|
305
308
|
/**
|
|
306
309
|
* Read a source map from a source map file.
|
|
307
310
|
*
|
|
@@ -311,6 +314,7 @@ function sourceMapFromMapFile(mapFilePath) {
|
|
|
311
314
|
const content = fs.readFileSync(mapFilePath, 'utf8');
|
|
312
315
|
return JSON.parse(content);
|
|
313
316
|
}
|
|
317
|
+
exports.sourceMapFromMapFile = sourceMapFromMapFile;
|
|
314
318
|
function writeToFile(filePath, fileContent) {
|
|
315
319
|
mkdirp.sync(path.dirname(filePath));
|
|
316
320
|
fs.writeFileSync(filePath, fileContent);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamscale/javascript-instrumenter",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.41",
|
|
4
4
|
"description": "Istanbul-based coverage instrumenter with coverage forwarding via WebSockets",
|
|
5
5
|
"main": "dist/src/main.js",
|
|
6
6
|
"bin": "dist/src/main.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"build": "tsc --project tsconfig.json && yarn buildVaccine",
|
|
18
18
|
"buildVaccine": "node esbuild.mjs",
|
|
19
19
|
"instrumenter": "node dist/src/main.js",
|
|
20
|
-
"test": "yarn build && NODE_OPTIONS='--experimental-vm-modules' jest --forceExit --coverage --silent=true --detectOpenHandles"
|
|
20
|
+
"test": "yarn build && NODE_OPTIONS='--experimental-vm-modules --max-old-space-size=8192' jest --forceExit --coverage --silent=true --detectOpenHandles"
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
23
23
|
"dist/**/*"
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"convert-source-map": "^1.7.0",
|
|
60
60
|
"foreground-child": "^2.0.0",
|
|
61
61
|
"glob": "^7.1.7",
|
|
62
|
-
"istanbul-lib-instrument": "^
|
|
62
|
+
"istanbul-lib-instrument": "^5.2.0",
|
|
63
63
|
"micromatch": "4.0.4",
|
|
64
64
|
"mkdirp": "^1.0.4",
|
|
65
65
|
"nyc": "^15.1.0",
|