Skip to content

feat(lib-instrument): add inputSourceMap option - #33

Merged
AriPerkkio merged 1 commit into
mainfrom
feat/lib-instrument-add-inputSourceMap-option
Oct 29, 2026
Merged

AriPerkkio merged 1 commit into
mainfrom
feat/lib-instrument-add-inputSourceMap-option

Conversation

@AriPerkkio

@AriPerkkio AriPerkkio commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Adds new inputSourceMap: boolean option to control whether input source map is stored in the coverage data. As the coverage data is embedded into the instrumented code, the input source map is always part of the transformed code too. In projects like Vitest, this makes no sense as we could just store the input source map in main thread and never transfer it to the test workers. This new option allows downstream projects to remove input source map from the transformed code compeltely. In vitest-dev/benchmarks this change reduced transformed code about 25%.

API:

  • inputSourceMap: true (default): no change, the input source map is stored in the coverage data.
  • inputSourceMap: false: the input source map is not stored. It must be registered with MapStore#registerMap from @vitest/istanbul-lib-source-maps before transforming the coverage.
const instrumenter = createInstrumenter({ inputSourceMap: false });
const code = instrumenter.instrumentSync(transformedCode, filename, sourceMap);

// ...

const mapStore = createSourceMapStore();
mapStore.registerMap(filename, sourceMap);

const coverageMap = await mapStore.transformCoverage(createCoverageMap(rawCoverage));

@pkg-pr-new

pkg-pr-new Bot commented Oct 21, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/@vitest/istanbul-lib-coverage@83c12e2
npm i https://pkg.pr.new/@vitest/istanbul-lib-instrument@83c12e2
npm i https://pkg.pr.new/@vitest/istanbul-lib-report@83c12e2
npm i https://pkg.pr.new/@vitest/istanbul-lib-source-maps@83c12e2

commit: 83c12e2

@AriPerkkio
AriPerkkio marked this pull request as ready for review October 29, 2026 11:31
@AriPerkkio
AriPerkkio merged commit 8f050ff into main Oct 29, 2026
6 checks passed
@AriPerkkio
AriPerkkio deleted the feat/lib-instrument-add-inputSourceMap-option branch October 29, 2026 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant