Skip to content

Commit

Permalink
chore: add a note about magic number
Browse files Browse the repository at this point in the history
  • Loading branch information
Demivan committed Jan 29, 2022
1 parent f9a4c09 commit 698b67e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/vite-node/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ export class ViteNodeRunner {
},
}

// Be carefull when changing this
// changing context will change amount of code added on line :114 (vm.runInThisContext)
// this messes up sourcemaps for coverage
// adjust `offset` variable in packages/vitest/src/integrations/coverage.ts#L100 if you do change this
const context = this.prepareContext({
// esm transformed by Vite
__vite_ssr_import__: request,
Expand Down
4 changes: 2 additions & 2 deletions packages/vitest/src/integrations/coverage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ export async function reportCoverage(ctx: Vitest) {
}
}))

// This is a magic number it corresponds to the amount of code
// that we add in packages/vite-node/src/client.ts:110 (vm.runInThisContext)
// This is a magic number. It corresponds to the amount of code
// that we add in packages/vite-node/src/client.ts:114 (vm.runInThisContext)
// TODO: Include our transformations in soucemaps
const offset = 190

Expand Down

0 comments on commit 698b67e

Please sign in to comment.