Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 295b8e1

Browse files
josephperrottclydin
authored andcommitted
refactor: replace usage of ng_package with new ng_package from rules_angular
1 parent 5e8c649 commit 295b8e1

File tree

9 files changed

+80
-46
lines changed

9 files changed

+80
-46
lines changed

‎WORKSPACE‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,3 +274,24 @@ esbuild_register_toolchains(
274274
name = "esbuild",
275275
esbuild_version = LATEST_ESBUILD_VERSION,
276276
)
277+
278+
git_repository(
279+
name = "rules_angular",
280+
commit = "bc8e690770319b8780761f797773bfd47f47dfdc",
281+
remote = "https://github.com/devversion/rules_angular.git",
282+
)
283+
284+
load("@rules_angular//setup:step_1.bzl", "rules_angular_step1")
285+
286+
rules_angular_step1()
287+
288+
load("@rules_angular//setup:step_2.bzl", "rules_angular_step2")
289+
290+
rules_angular_step2()
291+
292+
load("@rules_angular//setup:step_3.bzl", "rules_angular_step3")
293+
294+
rules_angular_step3(
295+
angular_compiler_cli = "//:node_modules/@angular/compiler-cli",
296+
typescript = "//:node_modules/typescript",
297+
)

‎goldens/public-api/angular/ssr/node/index.api.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
```ts
66

77
import { ApplicationRef } from '@angular/core';
8-
import type{ Http2ServerRequest } from 'node:http2';
9-
import type{ Http2ServerResponse } from 'node:http2';
10-
import type{ IncomingMessage } from 'node:http';
11-
import type{ ServerResponse } from 'node:http';
8+
import { Http2ServerRequest } from 'node:http2';
9+
import { Http2ServerResponse } from 'node:http2';
10+
import { IncomingMessage } from 'node:http';
11+
import { ServerResponse } from 'node:http';
1212
import { StaticProvider } from '@angular/core';
1313
import { Type } from '@angular/core';
1414

‎package.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@
125125
"listr2": "8.3.2",
126126
"lodash": "^4.17.21",
127127
"npm": "^11.0.0",
128+
"magic-string": "0.30.17",
129+
"rollup-plugin-dts": "6.2.1",
130+
"rollup-plugin-sourcemaps2": "0.5.0",
128131
"prettier": "^3.0.0",
129132
"protractor": "~7.0.0",
130133
"puppeteer": "18.2.1",

‎packages/angular/ssr/BUILD.bazel‎

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
load("@aspect_rules_js//npm:defs.bzl", "npm_package")
21
load("@devinfra//bazel/api-golden:index_rjs.bzl", "api_golden_test_npm_package")
32
load("@npm2//:defs.bzl", "npm_link_all_packages")
43
load("@rules_pkg//:pkg.bzl", "pkg_tar")
@@ -40,8 +39,7 @@ ts_project(
4039
)
4140

4241
ng_package(
43-
name = "angular_package",
44-
package_name = "@angular/ssr",
42+
name = "npm_package",
4543
srcs = [
4644
":package.json",
4745
"//packages/angular/ssr/third_party/beasties:beasties_bundled",
@@ -53,10 +51,21 @@ ng_package(
5351
],
5452
nested_packages = [
5553
"//packages/angular/ssr/schematics:pkg",
54+
# Included directly as the generated types reference the types file in this location.
55+
"//packages/angular/ssr/third_party/beasties:beasties_dts",
5656
],
57+
package = "@angular/ssr",
58+
rollup_runtime_deps = [
59+
"//:node_modules/@rollup/plugin-commonjs",
60+
"//:node_modules/@rollup/plugin-node-resolve",
61+
"//:node_modules/magic-string",
62+
"//:node_modules/rollup-plugin-dts",
63+
"//:node_modules/rollup-plugin-sourcemaps2",
64+
],
65+
tags = ["release-package"],
5766
deps = [
58-
":ssr_legacy",
59-
"//packages/angular/ssr/node:node_legacy",
67+
":ssr",
68+
"//packages/angular/ssr/node",
6069
],
6170
)
6271

@@ -69,16 +78,6 @@ pkg_tar(
6978
tags = ["manual"],
7079
)
7180

72-
# TODO: Replace when `ng_package` creates a valid `rules_js`-compliant npm package.
73-
npm_package(
74-
name = "npm_package",
75-
srcs = [":angular_package"],
76-
replace_prefixes = {
77-
"angular_package/": "",
78-
},
79-
tags = ["release-package"],
80-
)
81-
8281
alias(
8382
name = "pkg",
8483
actual = ":npm_package",

‎packages/angular/ssr/schematics/BUILD.bazel‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Use of this source code is governed by an MIT-style license that can be
44
# found in the LICENSE file at https://angular.dev/license
55

6-
load("@aspect_rules_js//npm:defs.bzl", "npm_package")
6+
load("@aspect_rules_js//js:defs.bzl", "js_library")
77
load("//tools:defaults.bzl", "jasmine_test", "ts_project")
88
load("//tools:ts_json_schema.bzl", "ts_json_schema")
99

@@ -91,8 +91,8 @@ jasmine_test(
9191
],
9292
)
9393

94-
# This package is intended to be combined into the main @angular/ssr package as a dep.
95-
npm_package(
94+
# This target is used as nested_package in the main @angular/ssr package as a dep.
95+
js_library(
9696
name = "pkg",
9797
srcs = [
9898
"package.json",

‎pnpm-lock.yaml‎

Lines changed: 26 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎tools/bazel/npm_package.bzl‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ def npm_package(
6363
out = "substituted_with_snapshot_repos/package.json",
6464
)
6565

66-
nostamp_subs = dict(substitutions["rjs"]["nostamp"], **extra_substitutions)
67-
stamp_subs = dict(substitutions["rjs"]["stamp"], **extra_substitutions)
66+
nostamp_subs = dict(substitutions["nostamp"], **extra_substitutions)
67+
stamp_subs = dict(substitutions["stamp"], **extra_substitutions)
6868

6969
expand_template(
7070
name = "final_package_json",

‎tools/defaults.bzl‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", _copy_to_bin = "copy_to_bin")
22
load("@aspect_rules_jasmine//jasmine:defs.bzl", _jasmine_test = "jasmine_test")
33
load("@aspect_rules_js//js:defs.bzl", _js_binary = "js_binary")
4-
load("@npm//@angular/bazel:index.bzl", _ng_package = "ng_package")
4+
load("@rules_angular//src/ng_package:index.bzl", _ng_package = "ng_package")
55
load("//tools:interop.bzl", _ts_project = "ts_project")
66
load("//tools:substitutions.bzl", "substitutions")
77
load("//tools/bazel:npm_package.bzl", _npm_package = "npm_package")
@@ -23,8 +23,8 @@ def ng_package(deps = [], **kwargs):
2323
deps = deps,
2424
license = "//:LICENSE",
2525
substitutions = select({
26-
"//:stamp": substitutions["legacy"]["stamp"],
27-
"//conditions:default": substitutions["legacy"]["nostamp"],
26+
"//:stamp": substitutions["stamp"],
27+
"//conditions:default": substitutions["nostamp"],
2828
}),
2929
**kwargs
3030
)

‎tools/substitutions.bzl‎

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ load("//:constants.bzl", "ANGULAR_FW_PEER_DEP", "ANGULAR_FW_VERSION", "NG_PACKAG
22

33
_stamp_substitutions = {
44
# Version of the local package being built, generated via the `--workspace_status_command` flag.
5-
"0.0.0-PLACEHOLDER": "{STABLE_PROJECT_VERSION}",
6-
"0.0.0-EXPERIMENTAL-PLACEHOLDER": "{STABLE_PROJECT_EXPERIMENTAL_VERSION}",
5+
"0.0.0-PLACEHOLDER": "{{STABLE_PROJECT_VERSION}}",
6+
"0.0.0-EXPERIMENTAL-PLACEHOLDER": "{{STABLE_PROJECT_EXPERIMENTAL_VERSION}}",
77
# ---
88
"BUILD_SCM_HASH-PLACEHOLDER": "{BUILD_SCM_ABBREV_HASH}",
99
"0.0.0-ENGINES-NODE": RELEASE_ENGINES_NODE,
@@ -22,21 +22,7 @@ _no_stamp_substitutions = dict(_stamp_substitutions, **{
2222
"0.0.0-EXPERIMENTAL-PLACEHOLDER": "0.0.0",
2323
})
2424

25-
def _adjust_substitutions_for_rules_js(subs):
26-
result = {}
27-
for key, value in subs.items():
28-
# in `rules_js`, or `expand_template` from `bazel-lib`, stamp variables
29-
# can only be retrieved via `{{X}}` syntax.
30-
result[key] = value.replace("{", "{{").replace("}", "}}")
31-
return result
32-
3325
substitutions = {
34-
"legacy": {
35-
"stamp": _stamp_substitutions,
36-
"nostamp": _no_stamp_substitutions,
37-
},
38-
"rjs": {
39-
"stamp": _adjust_substitutions_for_rules_js(_stamp_substitutions),
40-
"nostamp": _adjust_substitutions_for_rules_js(_no_stamp_substitutions),
41-
},
26+
"stamp": _stamp_substitutions,
27+
"nostamp": _no_stamp_substitutions,
4228
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /