From 860dbb36bd0f698542e7eaef5b1dcb0cc5fdc20e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20D=C4=9Bdi=C4=8D?= Date: Sun, 26 Dec 2021 00:48:11 +0100 Subject: [PATCH] Fixed source-map passed to istanbul-lib-instrument not being a plain object --- src/index.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 03a2eda..f33b486 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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