Skip to content

Commit f568493

Browse files
committed
feat: remove unnecessary dependencies from ng_application and ng_test
Remove various dependencies BREAKING CHANGE: Various related dependencies (jasmine, karma) have been removed from `ng_application` and `ng_test` . These dependencies are not always required, especially when using alternative testing setups like Vite for or when developing zoneless applications. This change reduces the default dependency footprint and provides more flexibility for users. Projects relying on these implicitly provided dependencies will now need to declare them explicitly. Closes #70
1 parent 0592424 commit f568493

17 files changed

Lines changed: 65 additions & 67 deletions

File tree

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ rules_ts_ext.deps(
1818
ts_integrity = "sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==",
1919
ts_version = "5.9.2",
2020
)
21-
use_repo(rules_ts_ext, npm_typescript="rules_angular_npm_typescript")
21+
use_repo(rules_ts_ext, npm_typescript = "rules_angular_npm_typescript")
2222

2323
node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node")
2424
node.toolchain(

setup/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# Create to create a package location for being able to load at this point in the directory structure.
1+
# Create to create a package location for being able to load at this point in the directory structure.

setup/bzl_library.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"Workaround for https://github.com/bazelbuild/bazel-skylib/pull/571"
2+
23
load("@bazel_skylib//:bzl_library.bzl", _bzl_library = "bzl_library")
34
load("@bazel_skylib//rules:build_test.bzl", "build_test")
45

src/architect/BUILD.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,27 @@ bzl_library(
1212
name = "ng_application",
1313
srcs = ["ng_application.bzl"],
1414
deps = [
15-
"@aspect_rules_js//js:defs",
1615
":utils",
16+
"@aspect_rules_js//js:defs",
1717
],
1818
)
1919

2020
bzl_library(
2121
name = "ng_library",
2222
srcs = ["ng_library.bzl"],
2323
deps = [
24+
":utils",
2425
"@aspect_rules_js//js:defs",
2526
"@jq.bzl//jq",
26-
":utils",
2727
],
2828
)
2929

3030
bzl_library(
3131
name = "ng_test",
3232
srcs = ["ng_test.bzl"],
3333
deps = [
34-
"@aspect_rules_js//js:defs",
3534
":utils",
35+
"@aspect_rules_js//js:defs",
3636
],
3737
)
3838

src/architect/ng_application.bzl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ NPM_DEPS = lambda node_modules: ["/".join([node_modules, s]) for s in [
1313
"@angular", # Take all of them, since the list varies across angular versions
1414
"rxjs",
1515
"tslib",
16-
"zone.js",
1716
]]
1817

1918
def ng_application(

src/architect/ng_library.bzl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"Macro definition to package an angular library"
22

3-
load("@jq.bzl//jq:jq.bzl", "jq")
43
load("@aspect_rules_js//js:defs.bzl", "js_library", "js_run_binary")
4+
load("@jq.bzl//jq:jq.bzl", "jq")
55
load(":utils.bzl", "TEST_PATTERNS", "ng_bin")
66

77
# Idiomatic configuration files created by `ng generate`
@@ -14,10 +14,12 @@ LIBRARY_CONFIG = [
1414
NPM_DEPS = lambda node_modules: ["/".join([node_modules, s]) for s in [
1515
"@angular/build",
1616
"@angular/common",
17+
"@angular/compiler",
18+
"@angular/compiler-cli",
1719
"@angular/core",
18-
"@angular/router",
1920
"rxjs",
2021
"tslib",
22+
"ng-packagr",
2123
]]
2224

2325
def ng_library(name, node_modules, ng_config, project_name = None, srcs = [], deps = [], **kwargs):

src/architect/ng_test.bzl

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,8 @@ TEST_CONFIG = [
1010

1111
NPM_DEPS = lambda node_modules: ["/".join([node_modules, s]) for s in [
1212
"@angular", # Take all of them, since the list varies across angular versions
13-
"@types/jasmine",
14-
"@types/node",
15-
"jasmine-core",
16-
"karma",
17-
"karma-chrome-launcher",
18-
"karma-coverage",
19-
"karma-jasmine",
20-
"karma-jasmine-html-reporter",
2113
"tslib",
2214
"rxjs",
23-
"zone.js",
2415
]]
2516

2617
def ng_test(name, node_modules, ng_config, args = [], project_name = None, srcs = [], deps = [], **kwargs):

src/ng_package/angular_package_format.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ def _angular_package_format_impl(ctx):
251251
] if _ != ""])
252252

253253
bundle_name_base = primary_bundle_name if is_primary_entry_point else entry_point
254-
bundle_name_base = bundle_name_base.replace('/', '-')
254+
bundle_name_base = bundle_name_base.replace("/", "-")
255255

256256
# Store the collected entry point in a list of all entry-points. This
257257
# can be later passed to the packager as a manifest.

src/ng_package/index.bzl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ load("//src/ng_package:angular_package_format.bzl", "angular_package_format")
33
load("//src/ng_package/text_replace:index.bzl", "text_replace")
44

55
def ng_package(
6-
name,
7-
nested_packages = [],
8-
substitutions = {},
9-
tags = [],
10-
replace_prefixes = {},
11-
**kwargs):
6+
name,
7+
nested_packages = [],
8+
substitutions = {},
9+
tags = [],
10+
replace_prefixes = {},
11+
**kwargs):
1212
angular_package_format(
1313
name = "%s_apf" % name,
1414
**kwargs
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
11
load("@aspect_rules_js//js:defs.bzl", "js_binary")
2-
load("@aspect_rules_ts//ts:defs.bzl", "ts_project", "ts_config")
2+
load("@aspect_rules_ts//ts:defs.bzl", "ts_config", "ts_project")
33

44
package(default_visibility = ["//visibility:public"])
5+
56
ts_config(
6-
name = "tsconfig",
7-
src = "tsconfig.json",
7+
name = "tsconfig",
8+
src = "tsconfig.json",
89
)
910

1011
ts_project(
1112
name = "packager_lib",
1213
srcs = [
13-
"api.ts",
14-
"cross-entry-point-imports.ts",
15-
"index.ts",
14+
"api.ts",
15+
"cross-entry-point-imports.ts",
16+
"index.ts",
1617
],
1718
tsconfig = ":tsconfig",
1819
deps = [
1920
"//:node_modules/@types/node",
20-
"//:node_modules/typescript",
2121
"//:node_modules/tinyglobby",
22+
"//:node_modules/typescript",
2223
],
2324
)
2425

2526
js_binary(
2627
name = "bin",
2728
data = [":packager_lib"],
2829
entry_point = ":index.js",
29-
)
30+
)

0 commit comments

Comments
 (0)