Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fixed source-map passed to istanbul-lib-instrument not being a plain …
…object
  • Loading branch information
marekdedic committed Dec 25, 2021
commit 860dbb36bd0f698542e7eaef5b1dcb0cc5fdc20e
8 changes: 7 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ export default function(this: loader.LoaderContext, source: string, sourceMap?:

// Instrument the code
let instrumenter = createInstrumenter(options);
instrumenter.instrument(source, this.resourcePath, done.bind(this), sourceMap);
if (sourceMap !== undefined) {
const { ...sourceMapPlainObject } = sourceMap;
instrumenter.instrument(source, this.resourcePath, done.bind(this), sourceMapPlainObject);
}
else {
instrumenter.instrument(source, this.resourcePath, done.bind(this), undefined);
}

function done(this: loader.LoaderContext, error: Error | null, instrumentedSource: string) {
// Get the source map for the instrumented code
Expand Down