Skip to content

Commit 820180a

Browse files
committed
feat: add sourcemaps for coverage support
1 parent 09747fc commit 820180a

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,18 @@ export const unpluginFactory: UnpluginFactory<Options | undefined> = (options =
151151
compilerFilePath,
152152
)
153153

154+
const sourcemapFilePath = path.resolve(distCustomElementsOptions.dir, `${componentTag}.js.map`)
155+
const rawSourcemap = await buildQueue.getLatestBuild(id, sourcemapFilePath)
156+
const sourcemapExists = await compiler.sys.access(sourcemapFilePath)
157+
158+
const sourcemap = sourcemapExists
159+
? { sourceRoot: getRootDir(options), ...JSON.parse(rawSourcemap) }
160+
: undefined;
161+
154162
return {
155163
code: transformedCode,
156164
inputFilePath: id,
165+
map: sourcemap
157166
}
158167
},
159168
}

0 commit comments

Comments
 (0)