angular/devtools/tools/defaults.bzl
Alan Agius 55b2e95fef build: disable sourcemaps in esbuild_config by setting sourcemap = False
This is now possible due to a fix in esbuild rules.
2026-03-12 14:54:43 -06:00

111 lines
3.4 KiB
Python

# Re-export of Bazel rules with devtools-wide defaults
load("@aspect_rules_esbuild//esbuild:defs.bzl", _esbuild = "esbuild")
load("@aspect_rules_js//js:defs.bzl", _js_library = "js_library")
load("@bazel_lib//lib:copy_to_bin.bzl", _copy_to_bin = "copy_to_bin")
load("@bazel_lib//lib:copy_to_directory.bzl", _copy_to_directory = "copy_to_directory")
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.
sourcemap = False,
**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
)