Skip to content

Migrate all remaining ts_library targets #30710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 26, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -114,7 +114,6 @@ yarn_install(
"//:tools/postinstall/apply-patches.js",
"//:tools/postinstall/patches/@angular+bazel+20.0.0-next.1.patch",
"//:tools/postinstall/patches/@angular+build-tooling+0.0.0-1ebf18a3a60b182a3dbad12e9a149fd93af5c29b.patch",
"//:tools/postinstall/patches/@bazel+concatjs+5.8.1.patch",
"//:tools/postinstall/patches/tsec+0.2.2.patch",
"//src/cdk:package.json",
],
@@ -240,7 +239,7 @@ setup_dependencies_2()

git_repository(
name = "rules_angular",
commit = "e10bf488aca18c159399f4c1163324a40f45a5dc",
commit = "bbf9493c73f4a2d715259e8febaa99c363ceaec3",
remote = "https://github.com/devversion/rules_angular.git",
)

9 changes: 7 additions & 2 deletions src/cdk-experimental/scrolling/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("//src/e2e-app:test_suite.bzl", "e2e_test_suite")
load("//tools:defaults.bzl", "ng_e2e_test_library", "ng_module", "ng_web_test_suite")
load("//tools:defaults.bzl", "ng_module", "ng_web_test_suite")
load("//tools:defaults2.bzl", "ts_project")

package(default_visibility = ["//visibility:public"])
@@ -41,9 +41,14 @@ ng_web_test_suite(
deps = [":unit_test_sources"],
)

ng_e2e_test_library(
ts_project(
name = "e2e_test_sources",
testonly = True,
srcs = glob(["**/*.e2e.spec.ts"]),
deps = [
"//:node_modules/@types/selenium-webdriver",
"//:node_modules/protractor",
],
)

e2e_test_suite(
5 changes: 3 additions & 2 deletions src/cdk/overlay/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@ load("//src/e2e-app:test_suite.bzl", "e2e_test_suite")
load(
"//tools:defaults.bzl",
"markdown_to_html",
"ng_e2e_test_library",
"ng_module",
"ng_web_test_suite",
"sass_binary",
@@ -88,9 +87,11 @@ ng_web_test_suite(
deps = [":unit_test_sources"],
)

ng_e2e_test_library(
ts_project(
name = "e2e_test_sources",
testonly = True,
srcs = glob(["**/*.e2e.spec.ts"]),
deps = ["//:node_modules/protractor"],
)

e2e_test_suite(
14 changes: 9 additions & 5 deletions src/cdk/testing/tests/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//tools:defaults.bzl", "ng_e2e_test_library", "ng_module")
load("//tools:defaults.bzl", "ng_module")
load("//tools:defaults2.bzl", "ts_project")

package(default_visibility = ["//visibility:public"])
@@ -70,21 +70,25 @@ ts_project(
],
)

ng_e2e_test_library(
ts_project(
name = "e2e_test_sources",
testonly = True,
srcs = glob(
[
"**/*.e2e.spec.ts",
],
exclude = ["webdriver.e2e.spec.ts"],
),
deps = [
":cross_environment_specs",
":test_harnesses",
interop_deps = [
"//src/cdk/testing",
"//src/cdk/testing/private",
"//src/cdk/testing/protractor",
],
deps = [
":cross_environment_specs_rjs",
":test_harnesses_rjs",
"//:node_modules/protractor",
],
)

ts_project(
2 changes: 1 addition & 1 deletion src/material/schematics/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -100,7 +100,7 @@ npm_package(
":ng_generate_assets",
":schema_assets",
":schematics_rjs",
"//src/material/schematics/ng-generate/theme-color:npm_package",
"//src/material/schematics/ng-generate/theme-color:npm_package_assets",
"//src/material/schematics/ng-update:ng_update_index",
],
)
9 changes: 4 additions & 5 deletions src/material/schematics/ng-generate/theme-color/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@build_bazel_rules_nodejs//:index.bzl", "copy_to_bin")
load("//tools:defaults.bzl", "esbuild", "pkg_npm")
load("//tools:defaults.bzl", "esbuild")
load("//tools:defaults2.bzl", "jasmine_test", "ts_project")

package(default_visibility = ["//visibility:public"])
@@ -48,10 +48,9 @@ esbuild(
],
)

pkg_npm(
name = "npm_package",
srcs = STATIC_ASSETS,
deps = [":index_bundled"],
filegroup(
name = "npm_package_assets",
srcs = STATIC_ASSETS + [":index_bundled"],
)

########################################
8 changes: 3 additions & 5 deletions src/material/slider/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@ load(
"//tools:defaults.bzl",
"extract_tokens",
"markdown_to_html",
"ng_e2e_test_library",
"ng_module",
"ng_web_test_suite",
"sass_binary",
@@ -102,12 +101,11 @@ ng_web_test_suite(
],
)

ng_e2e_test_library(
ts_project(
name = "e2e_test_sources",
testonly = True,
srcs = glob(["**/*.e2e.spec.ts"]),
deps = [
":slider",
],
deps = ["//:node_modules/protractor"],
)

e2e_test_suite(
3 changes: 1 addition & 2 deletions src/material/slider/slider.e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -6,8 +6,7 @@
* found in the LICENSE file at https://angular.dev/license
*/

import {$, browser, by, element, ElementFinder} from 'protractor';
import {logging} from 'selenium-webdriver';
import {$, browser, by, element, ElementFinder, logging} from 'protractor';

describe('MatSlider', () => {
const getStandardSlider = () => element(by.id('standard-slider'));
6 changes: 4 additions & 2 deletions src/universal-app/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ load("//src/cdk-experimental:config.bzl", "CDK_EXPERIMENTAL_TARGETS")
load("//src/components-examples:config.bzl", "ALL_EXAMPLES")
load("//src/material:config.bzl", "MATERIAL_TARGETS")
load("//src/material-experimental:config.bzl", "MATERIAL_EXPERIMENTAL_TARGETS")
load("//tools:defaults.bzl", "devmode_esbuild", "http_server", "ng_e2e_test_library", "ng_module", "protractor_web_test_suite", "sass_binary")
load("//tools:defaults.bzl", "devmode_esbuild", "http_server", "ng_module", "protractor_web_test_suite", "sass_binary")
load("//tools/angular:index.bzl", "LINKER_PROCESSED_FW_PACKAGES")
load("//tools:defaults2.bzl", "ts_project")
load("@aspect_rules_ts//ts:defs.bzl", rules_js_tsconfig = "ts_config")
@@ -159,9 +159,11 @@ http_server(
],
)

ng_e2e_test_library(
ts_project(
name = "hydration_e2e_tests_sources",
testonly = True,
srcs = ["hydration.e2e.spec.ts"],
deps = ["//:node_modules/protractor"],
)

protractor_web_test_suite(
57 changes: 0 additions & 57 deletions tools/defaults.bzl
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@ load("@npm//@angular/build-tooling/bazel/http-server:index.bzl", _http_server =
load("@npm//@angular/build-tooling/bazel:extract_js_module_output.bzl", "extract_js_module_output")
load("@npm//@bazel/jasmine:index.bzl", _jasmine_node_test = "jasmine_node_test")
load("@npm//@bazel/protractor:index.bzl", _protractor_web_test_suite = "protractor_web_test_suite")
load("@npm//@bazel/concatjs:index.bzl", _ts_library = "ts_library")
load("@npm//tsec:index.bzl", _tsec_test = "tsec_test")
load("//:packages.bzl", "NO_STAMP_NPM_PACKAGE_SUBSTITUTIONS", "NPM_PACKAGE_SUBSTITUTIONS")
load("//:pkg-externals.bzl", "PKG_EXTERNALS")
@@ -68,49 +67,6 @@ def sass_library(**kwargs):
def npm_sass_library(**kwargs):
_npm_sass_library(**kwargs)

def ts_library(
tsconfig = None,
deps = [],
testonly = False,
# TODO(devversion): disallow configuration of the target when schematics use ESM.
devmode_target = None,
prodmode_target = None,
devmode_module = None,
**kwargs):
# Add tslib because we use import helpers for all public packages.
local_deps = ["@npm//tslib"] + deps

if not tsconfig:
tsconfig = _getDefaultTsConfig(testonly)

# Compute an AMD module name for the target.
module_name = compute_module_name(testonly)

_ts_library(
# `module_name` is used for AMD module names within emitted JavaScript files.
module_name = module_name,
# We use the module name as package name, so that the target can be resolved within
# NodeJS executions, by activating the Bazel NodeJS linker.
# See: https://github.com/bazelbuild/rules_nodejs/pull/2799.
package_name = module_name,
# For prodmode, the target is set to `ES2022`. `@bazel/typecript` sets `ES2015` by default. Note
# that this should be in sync with the `ng_module` tsconfig generation to emit proper APF v13.
# https://github.com/bazelbuild/rules_nodejs/blob/901df3868e3ceda177d3ed181205e8456a5592ea/third_party/github.com/bazelbuild/rules_typescript/internal/common/tsconfig.bzl#L195
prodmode_target = prodmode_target if prodmode_target != None else "es2022",
# We also set devmode output to the same settings as prodmode as a first step in combining
# devmode and prodmode output. We will not rely on AMD output anyway due to the linker processing.
devmode_target = devmode_target if devmode_target != None else "es2022",
devmode_module = devmode_module if devmode_module != None else "esnext",
tsconfig = tsconfig,
testonly = testonly,
deps = local_deps,
**kwargs
)

# TODO(devversion): Partner with ISE team to support `rules_js` here.
if False and module_name and not testonly:
_make_tsec_test(kwargs["name"])

def ng_module(
deps = [],
srcs = [],
@@ -236,19 +192,6 @@ def jasmine_node_test(**kwargs):
kwargs["templated_args"] = ["--bazel_patch_module_resolver"] + kwargs.get("templated_args", [])
_jasmine_node_test(**kwargs)

def ng_e2e_test_library(deps = [], **kwargs):
local_deps = [
"@npm//@types/jasmine",
"@npm//@types/selenium-webdriver",
"@npm//protractor",
] + deps

ts_library(
testonly = True,
deps = local_deps,
**kwargs
)

def karma_web_test_suite(name, **kwargs):
test_deps = kwargs.get("deps", [])

4 changes: 4 additions & 0 deletions tools/defaults2.bzl
Original file line number Diff line number Diff line change
@@ -19,6 +19,10 @@ def ts_project(
**kwargs
)

# TODO(devversion): Partner with ISE team to support `rules_js` here.
# if False and not testonly:
# _make_tsec_test(kwargs["name"])

def jasmine_test(data = [], args = [], **kwargs):
# Create relative path to root, from current package dir. Necessary as
# we change the `chdir` below to the package directory.
13 changes: 0 additions & 13 deletions tools/postinstall/patches/@bazel+concatjs+5.8.1.patch

This file was deleted.

Loading