From e10bf9993680fb634d81704c9f324186f28e8304 Mon Sep 17 00:00:00 2001 From: Christopher Allen Date: Wed, 17 Aug 2022 17:05:38 +0100 Subject: [PATCH] fix(build): Fix sourcemaps (#6352) Get sourcemaps working again. - The change in tsconfig.json is sufficient to get functional, per-.ts-file sourcemaps in build/src/** that work in uncompiled mode (i.e. in the playground / tests). - No further changes are required for these to be ingested by gulp + Closure Compiler; the resulting files - build/*_compressed.js.map - now point at files in core/, blocks/, etc. This works correctly when packaged and also when doing local testing in compiled mode of the checked-in build products (i.e., after they are copied to the repository root.) - In order to get sourcemaps to work for local testing in compiled mode of the build products directly from build/, buildCompile now creates symlinks from build/ to core/, blocks/ and generators/. --- scripts/gulpfiles/build_tasks.js | 9 +++++++++ tsconfig.json | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/gulpfiles/build_tasks.js b/scripts/gulpfiles/build_tasks.js index 810bb425c..e6a395c40 100644 --- a/scripts/gulpfiles/build_tasks.js +++ b/scripts/gulpfiles/build_tasks.js @@ -630,6 +630,15 @@ function buildCompiled() { // option to Closure Compiler; instead feed them as input via gulp.src. }; + // Symlink source dirs from build dir so that sourcemaps work in + // compiled-mode testing. + for (const src of ['core', 'blocks', 'generators']) { + const target = `${BUILD_DIR}/${src}` + if (!fs.existsSync(target)) { + fs.symlinkSync(`../${src}`, target); + } + } + // Fire up compilation pipline. return gulp.src(chunkOptions.js, {base: './'}) .pipe(stripApacheLicense()) diff --git a/tsconfig.json b/tsconfig.json index 3b1971dc5..9dbdfcfab 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,8 +11,9 @@ // normally they are ignored as source files "allowJs": true, - // Generate d.ts files + // Generate d.ts files and sourcemaps. "declaration": true, + "sourceMap": true, "module": "ES2015", "moduleResolution": "node",