mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
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.
113 lines
3.6 KiB
Python
113 lines
3.6 KiB
Python
# Re-export of Bazel rules with devtools-wide defaults
|
|
|
|
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", _copy_to_bin = "copy_to_bin")
|
|
load("@aspect_bazel_lib//lib:copy_to_directory.bzl", _copy_to_directory = "copy_to_directory")
|
|
load("@aspect_rules_esbuild//esbuild:defs.bzl", _esbuild = "esbuild")
|
|
load("@aspect_rules_js//js:defs.bzl", _js_library = "js_library")
|
|
load("@bazel_skylib//rules:common_settings.bzl", _string_flag = "string_flag")
|
|
load(
|
|
"//tools:defaults.bzl",
|
|
_http_server = "http_server",
|
|
_ng_project = "ng_project",
|
|
_ng_web_test_suite = "ng_web_test_suite",
|
|
_npm_sass_library = "npm_sass_library",
|
|
_sass_binary = "sass_binary",
|
|
_sass_library = "sass_library",
|
|
_ts_config = "ts_config",
|
|
_ts_project = "ts_project",
|
|
_zoneless_web_test_suite = "zoneless_web_test_suite",
|
|
)
|
|
|
|
sass_binary = _sass_binary
|
|
sass_library = _sass_library
|
|
npm_sass_library = _npm_sass_library
|
|
http_server = _http_server
|
|
js_library = _js_library
|
|
|
|
def esbuild(minify = None, **kwargs):
|
|
_esbuild(
|
|
minify = minify if minify != None else select({
|
|
"//devtools:debug_build": False,
|
|
"//conditions:default": True,
|
|
}),
|
|
# 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
|
|
)
|
|
|
|
copy_to_bin = _copy_to_bin
|
|
copy_to_directory = _copy_to_directory
|
|
string_flag = _string_flag
|
|
ts_config = _ts_config
|
|
|
|
def ng_web_test_suite(deps = [], **kwargs):
|
|
# Provide required modules for the imports in //tools/testing/browser_tests.init.mts
|
|
deps = deps + [
|
|
"//:node_modules/@angular/compiler",
|
|
"//:node_modules/@angular/core",
|
|
"//:node_modules/@angular/platform-browser",
|
|
]
|
|
_ng_web_test_suite(
|
|
deps = deps,
|
|
tsconfig = "//devtools:tsconfig_test",
|
|
**kwargs
|
|
)
|
|
|
|
def zoneless_web_test_suite(deps = [], **kwargs):
|
|
# Provide required modules for the imports in //tools/testing/browser_tests.init.mts
|
|
deps = deps + [
|
|
"//:node_modules/@angular/compiler",
|
|
"//:node_modules/@angular/core",
|
|
"//:node_modules/@angular/platform-browser",
|
|
]
|
|
_zoneless_web_test_suite(
|
|
deps = deps,
|
|
tsconfig = "//devtools:tsconfig_test",
|
|
**kwargs
|
|
)
|
|
|
|
def ng_project(name, srcs = [], angular_assets = [], **kwargs):
|
|
deps = kwargs.pop("deps", []) + [
|
|
"//:node_modules/tslib",
|
|
]
|
|
|
|
_ng_project(
|
|
name = name,
|
|
tsconfig = "//devtools:tsconfig_build",
|
|
srcs = srcs,
|
|
assets = angular_assets,
|
|
deps = deps,
|
|
**kwargs
|
|
)
|
|
|
|
def ts_project(name, **kwargs):
|
|
_ts_project(
|
|
name = name,
|
|
tsconfig = "//devtools:tsconfig_build",
|
|
**kwargs
|
|
)
|
|
|
|
def ts_test_library(name, deps = [], **kwargs):
|
|
_ts_project(
|
|
name = name,
|
|
tsconfig = "//devtools:tsconfig_test",
|
|
testonly = 1,
|
|
deps = deps + [
|
|
"//:node_modules/@types/jasmine",
|
|
],
|
|
**kwargs
|
|
)
|
|
|
|
def extension_package(
|
|
# Actually copy the files into the destination location so they can be copied
|
|
# out during use when publishing."
|
|
hardlink = "off",
|
|
**kwargs):
|
|
# Use the copy_to_directory rule for creating extension packages.
|
|
copy_to_directory(
|
|
hardlink = hardlink,
|
|
**kwargs
|
|
)
|