Skip to content

Commit 8729f48

Browse files
committed
feat(config): add source map support for coverage tracking
- Import envAsBoolean from @socketsecurity/lib/env/helpers - Enable source maps conditionally when COVERAGE env var is set - Update vitest coverage exclusions to prevent dist/ file tracking - Add multiple exclusion patterns for better coverage accuracy This improves coverage measurement by generating source maps during coverage runs, though architectural limitations prevent full src/ coverage remapping.
1 parent c336e33 commit 8729f48

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

.config/esbuild.config.mjs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,9 @@ import path from 'node:path'
77
import { fileURLToPath } from 'node:url'
88
import fg from 'fast-glob'
99

10+
import { envAsBoolean } from '#socketsecurity/lib/env/helpers'
1011
import { getLocalPackageAliases } from '../scripts/utils/get-local-package-aliases.mjs'
1112

12-
// Helper to check boolean env vars
13-
const envAsBoolean = name => {
14-
const value = process.env[name]
15-
return value === 'true' || value === '1'
16-
}
17-
1813
const __dirname = path.dirname(fileURLToPath(import.meta.url))
1914
const rootPath = path.join(__dirname, '..')
2015
const srcPath = path.join(rootPath, 'src')
@@ -293,7 +288,7 @@ export const buildConfig = {
293288
platform: 'node',
294289
target: 'node18',
295290
// Enable source maps for coverage (set COVERAGE=true env var)
296-
sourcemap: envAsBoolean('COVERAGE'),
291+
sourcemap: envAsBoolean(process.env.COVERAGE),
297292
// Don't minify - this is a library and minification breaks ESM/CJS interop.
298293
minify: false,
299294
// Tree-shaking optimization.

.config/vitest.config.mts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,11 @@ export default defineConfig({
132132
'test/**',
133133
'packages/**',
134134
'perf/**',
135-
'dist/**',
136-
'src/external/**',
135+
'dist',
136+
'dist/**/*',
137+
'**/dist/**',
138+
'src/external',
139+
'src/external/**/*',
137140
'src/types.ts',
138141
'scripts/**',
139142
],

0 commit comments

Comments
 (0)