From 58bf8a100b21e478c44eea4aea8864fbdcfc9e13 Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Wed, 13 Jul 2022 17:05:41 -0700 Subject: [PATCH] Fix code coverage not mapping correctly (#20026) --- build/lib/compilation.js | 12 +++++++++++- build/lib/compilation.ts | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/build/lib/compilation.js b/build/lib/compilation.js index 585101a46b..7e53dc4aee 100644 --- a/build/lib/compilation.js +++ b/build/lib/compilation.js @@ -37,9 +37,19 @@ function createCompile(src, build, emitError) { const sourcemaps = require('gulp-sourcemaps'); const projectPath = path.join(__dirname, '../../', src, 'tsconfig.json'); const overrideOptions = Object.assign(Object.assign({}, getTypeScriptCompilerOptions(src)), { inlineSources: Boolean(build) }); - if (!build) { + // {{SQL CARBON EDIT}} Add override for not inlining the sourcemap during build so we can get code coverage - it + // currently expects a *.map.js file to exist next to the source file for proper source mapping + if (!build && !process.env['SQL_NO_INLINE_SOURCEMAP']) { overrideOptions.inlineSourceMap = true; } + else if (!build) { + console.warn('********************************************************************************************'); + console.warn('* Inlining of source maps is DISABLED, which will prevent debugging from working properly, *'); + console.warn('* but is required to generate code coverage reports. *'); + console.warn('* To re-enable inlining of source maps clear the SQL_NO_INLINE_SOURCEMAP environment var *'); + console.warn('* and re-run the build/watch task *'); + console.warn('********************************************************************************************'); + } const compilation = tsb.create(projectPath, overrideOptions, false, err => reporter(err)); function pipeline(token) { const bom = require('gulp-bom'); diff --git a/build/lib/compilation.ts b/build/lib/compilation.ts index 66ca3c5e4f..cb60091fce 100644 --- a/build/lib/compilation.ts +++ b/build/lib/compilation.ts @@ -44,10 +44,20 @@ function createCompile(src: string, build: boolean, emitError?: boolean) { const projectPath = path.join(__dirname, '../../', src, 'tsconfig.json'); const overrideOptions = { ...getTypeScriptCompilerOptions(src), inlineSources: Boolean(build) }; - if (!build) { + // {{SQL CARBON EDIT}} Add override for not inlining the sourcemap during build so we can get code coverage - it + // currently expects a *.map.js file to exist next to the source file for proper source mapping + if (!build && !process.env['SQL_NO_INLINE_SOURCEMAP']) { overrideOptions.inlineSourceMap = true; + } else if (!build) { + console.warn('********************************************************************************************'); + console.warn('* Inlining of source maps is DISABLED, which will prevent debugging from working properly, *'); + console.warn('* but is required to generate code coverage reports. *'); + console.warn('* To re-enable inlining of source maps clear the SQL_NO_INLINE_SOURCEMAP environment var *'); + console.warn('* and re-run the build/watch task *'); + console.warn('********************************************************************************************'); } + const compilation = tsb.create(projectPath, overrideOptions, false, err => reporter(err)); function pipeline(token?: util.ICancellationToken) {