From 786ea441e9af325d09a1f201e79f7cbf2b923f9c Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Fri, 6 Mar 2026 21:13:18 +0100 Subject: [PATCH] build: force external sourcemaps for esbuild targets Update the `esbuild` macro in devtools to use `external` sourcemaps by default and remove the ability to override the `sourcemap` and `sources_content` options. This change is necessary to ensure that the build is deterministic and 100% reproducible as otherwise Firefox will not publish the build. --- devtools/README.md | 4 ++++ devtools/projects/shell-browser/src/app/BUILD.bazel | 8 -------- devtools/tools/defaults.bzl | 9 ++++++--- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/devtools/README.md b/devtools/README.md index c918ec226c1..b89ec8aae99 100644 --- a/devtools/README.md +++ b/devtools/README.md @@ -84,6 +84,10 @@ have sourcemaps loaded and be unminified. - The background service worker is found at `chrome://extensions`. - Click on the "Angular DevTools" extension and the "Inspect Views > service worker" button to open a debugger. +### Enabling sourcemaps + +To enable sourcemaps you need to add the `sourcemap = "inline"` flag to the `esbuild` macro located in `tools/defaults.bzl`. + ### Running End-to-End Tests Before running end-to-end tests, you need to start the development server using: diff --git a/devtools/projects/shell-browser/src/app/BUILD.bazel b/devtools/projects/shell-browser/src/app/BUILD.bazel index ce8da3d9bba..fc92a8d7552 100644 --- a/devtools/projects/shell-browser/src/app/BUILD.bazel +++ b/devtools/projects/shell-browser/src/app/BUILD.bazel @@ -214,8 +214,6 @@ esbuild( entry_point = "detect-angular.ts", format = "iife", platform = "browser", - # Need to inline sourcemaps for injected scripts as Chrome doesn't seem to load them correctly otherwise. - sourcemap = "inline", splitting = False, target = "esnext", deps = [ @@ -234,8 +232,6 @@ esbuild( entry_point = "backend.ts", format = "iife", platform = "browser", - # Need to inline sourcemaps for injected scripts as Chrome doesn't seem to load them correctly otherwise. - sourcemap = "inline", splitting = False, target = "esnext", deps = [ @@ -254,8 +250,6 @@ esbuild( entry_point = "ng-validate.ts", format = "iife", platform = "browser", - # Need to inline sourcemaps for injected scripts as Chrome doesn't seem to load them correctly otherwise. - sourcemap = "inline", splitting = False, target = "esnext", deps = [ @@ -292,8 +286,6 @@ esbuild( entry_point = "content-script.ts", format = "iife", platform = "browser", - # Need to inline sourcemaps for injected scripts as Chrome doesn't seem to load them correctly otherwise. - sourcemap = "inline", splitting = False, target = "esnext", deps = [ diff --git a/devtools/tools/defaults.bzl b/devtools/tools/defaults.bzl index 5f96520bb91..b178eab6725 100644 --- a/devtools/tools/defaults.bzl +++ b/devtools/tools/defaults.bzl @@ -24,14 +24,17 @@ npm_sass_library = _npm_sass_library http_server = _http_server js_library = _js_library -def esbuild(minify = None, sourcemap = "linked", sources_content = True, **kwargs): +def esbuild(minify = None, **kwargs): _esbuild( minify = minify if minify != None else select({ "//devtools:debug_build": False, "//conditions:default": True, }), - sourcemap = sourcemap, - sources_content = sources_content, + # Do not change this as otherwise the sourcemaps will cause the build not to be reproducable and firefox will not publish the extension. + # NB: Do not use `select` here either as this option is not configurable and bazel doesn't resolve to a value. + # TODO: Remove this once aspect_rules_esbuild supports sourcemap = False + # See: https://github.com/aspect-build/rules_esbuild/pull/264 + sourcemap = "external", **kwargs )