From a595fb8fd1f7d48650c2bda7406a89ce27e74c6b Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Thu, 7 Apr 2022 16:39:08 -0700 Subject: [PATCH] Inline source maps in dev build (#18970) * Inline source maps in dev build * Update readme * correct command * Use env var * Update location --- .github/workflows/ci.yml | 3 +++ build/lib/compilation.js | 7 +++---- build/lib/compilation.ts | 8 +++----- test/unit/README.md | 8 ++++++-- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d1a629c31c..8d80d86d6b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -131,8 +131,11 @@ jobs: ELECTRON_SKIP_BINARY_DOWNLOAD: 1 run: yarn --frozen-lockfile --network-timeout 180000 + # Don't inline source maps so that we generate code coverage for ts files - name: Compile and Download run: yarn npm-run-all --max_old_space_size=4095 -lp compile "electron x64" playwright-install download-builtin-extensions + env: + SQL_NO_INLINE_SOURCEMAP: 1 - name: Run Unit Tests (Electron) id: electron-unit-tests diff --git a/build/lib/compilation.js b/build/lib/compilation.js index 1148ef423d..fd21452243 100644 --- a/build/lib/compilation.js +++ b/build/lib/compilation.js @@ -37,10 +37,9 @@ 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) }); - // {{SQL CARBON EDIT}} Never inline source maps so that generating local coverage works - // if (!build) { - // // overrideOptions.inlineSourceMap = true; - // } + if (!build && !process.env['SQL_NO_INLINE_SOURCEMAP']) { + overrideOptions.inlineSourceMap = true; + } 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 2c9c70f83a..9d1b5f57c0 100644 --- a/build/lib/compilation.ts +++ b/build/lib/compilation.ts @@ -44,10 +44,9 @@ function createCompile(src: string, build: boolean, emitError?: boolean) { const projectPath = path.join(__dirname, '../../', src, 'tsconfig.json'); const overrideOptions = { ...getTypeScriptCompilerOptions(src), inlineSources: Boolean(build) }; - // {{SQL CARBON EDIT}} Never inline source maps so that generating local coverage works - // if (!build) { - // // overrideOptions.inlineSourceMap = true; - // } + if (!build && !process.env['SQL_NO_INLINE_SOURCEMAP']) { + overrideOptions.inlineSourceMap = true; + } const compilation = tsb.create(projectPath, overrideOptions, false, err => reporter(err)); @@ -88,7 +87,6 @@ function createCompile(src: string, build: boolean, emitError?: boolean) { export function compileTask(src: string, out: string, build: boolean): () => NodeJS.ReadWriteStream { return function () { - if (os.totalmem() < 4_000_000_000) { throw new Error('compilation requires 4GB of RAM'); } diff --git a/test/unit/README.md b/test/unit/README.md index 47a309adba..f7566ce2c1 100644 --- a/test/unit/README.md +++ b/test/unit/README.md @@ -30,7 +30,7 @@ Unit tests from layers `common` and `browser` are run inside `chromium`, `webkit ## Coverage -The following command will create a `coverage` folder at the root of the workspace: +The following command will create a `coverage` folder in the `.build` folder at the root of the workspace: **OS X and Linux** @@ -38,4 +38,8 @@ The following command will create a `coverage` folder at the root of the workspa **Windows** - scripts\test --coverage + .\scripts\test.bat --coverage + +NOTE: When running locally the coverage will be generated for the .js files because by default the sourcemaps +are inlined. To fix this set the environment variable `SQL_NO_INLINE_SOURCEMAP` to `1`, re-run the +compile/watch task and then re-run the test script with coverage enabled.