Skip to content

Commit 20ee96d

Browse files
committed
build: do not manage package version in Starlark file
The package/project version should be managed via the `package.json` file so that existing tooling like `yarn ng-dev` does not break with the recent Bazel migration. Tools like `ng-dev` expect a project version to be present in the top-level `package.json`. The current placeholder breaks the release and branching expectations.
1 parent 1e84801 commit 20ee96d

File tree

6 files changed

+46
-44
lines changed

6 files changed

+46
-44
lines changed

.bazelrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Release configuration
2+
build:release --workspace_status_command="yarn -s ng-dev release build-env-stamp --mode=release"
3+
build:release --stamp
4+
15
# ======================================================================================================================
26
# Support for debugging Node.js tests
37
# Use `--config=debug` to enable these settings

BUILD.bazel

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ load("@aspect_rules_js//npm:defs.bzl", "npm_package")
44
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
55
load("@npm//:defs.bzl", "npm_link_all_packages")
66
load("@npm//:vsce/package_json.bzl", vsce_bin = "bin")
7-
load(":version.bzl", "VERSION")
87

98
npm_link_all_packages(name = "node_modules")
109

@@ -17,17 +16,19 @@ js_library(
1716
ts_config(
1817
name = "tsconfig",
1918
src = "tsconfig.json",
20-
visibility = ["//visibility:public"]
19+
visibility = ["//visibility:public"],
2120
)
2221

2322
expand_template(
2423
name = "package_json_expanded",
25-
template = "package.json",
2624
out = "package_expanded.json",
25+
stamp_substitutions = {
26+
"0.0.0-PLACEHOLDER": "{{BUILD_SCM_VERSION}}",
27+
},
2728
substitutions = {
28-
"0.0.0-PLACEHOLDER": VERSION,
2929
"./dist/client/src/extension": "./index",
30-
}
30+
},
31+
template = "package.json",
3132
)
3233

3334
npm_package(
@@ -62,13 +63,13 @@ npm_package(
6263
":node_modules/vscode-uri",
6364
":node_modules/yallist",
6465
],
65-
include_srcs_packages = [
66-
"**",
67-
],
6866
exclude_srcs_patterns = [
6967
"*.map",
7068
"**/*.map",
7169
],
70+
include_srcs_packages = [
71+
"**",
72+
],
7273
replace_prefixes = {
7374
"package_expanded.json": "package.json",
7475
"server/package_expanded.json": "server/package.json",
@@ -82,13 +83,13 @@ vsce_bin.vsce(
8283
srcs = [
8384
":vsix_sandbox",
8485
],
85-
outs = ["ng-template-{}.vsix".format(VERSION)],
86-
chdir = "vsix_sandbox",
86+
outs = ["ng-template.vsix"],
8787
args = [
8888
"package",
8989
"-o",
90-
"../ng-template-{}.vsix".format(VERSION)
90+
"../ng-template.vsix",
9191
],
92+
chdir = "vsix_sandbox",
9293
# vsce requires npm on the PATH; we can get this from the Bazel rules_nodejs but it is not
9394
# included by default in rules_js binary rules so we include it here explicitly
9495
include_npm = True,
@@ -97,11 +98,11 @@ vsce_bin.vsce(
9798
npm_package(
9899
name = "npm",
99100
srcs = [
100-
":vsix_sandbox",
101101
":vsix",
102+
":vsix_sandbox",
102103
],
103104
root_paths = [
104-
"vsix_sandbox"
105+
"vsix_sandbox",
105106
],
106107
visibility = ["//integration:__subpackages__"],
107108
)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "ng-template",
33
"displayName": "Angular Language Service",
44
"description": "Editor services for Angular templates",
5-
"version": "0.0.0-PLACEHOLDER",
5+
"version": "14.2.0",
66
"publisher": "Angular",
77
"icon": "angular.png",
88
"license": "MIT",

scripts/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ rm -rf dist
3838
yarn install
3939

4040
# Build the npm package with bazel
41-
yarn bazel build //:npm
41+
yarn bazel build //:npm --config=release
4242

4343
# Copy the bazel built package to dist/npm
4444
mkdir -p dist/npm

server/BUILD.bazel

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,50 @@
11
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
22
load("@aspect_rules_esbuild//esbuild:defs.bzl", "esbuild")
33
load("@aspect_rules_js//js/private:expand_template.bzl", "expand_template")
4-
load("//:version.bzl", "VERSION")
54

65
ts_config(
76
name = "tsconfig",
87
src = "tsconfig.json",
8+
visibility = [
9+
"//integration:__subpackages__",
10+
"//server:__subpackages__",
11+
],
912
deps = [
1013
"//:tsconfig",
1114
"//common:tsconfig",
1215
],
13-
visibility = [
14-
"//server:__subpackages__",
15-
"//integration:__subpackages__",
16-
]
1716
)
1817

1918
esbuild(
2019
name = "banner",
21-
entry_point = "//server/src:banner.js",
22-
data = ["//server/src"],
23-
platform = "node",
24-
format = "cjs",
25-
sourcemap = "external",
26-
external = [
27-
"path",
28-
],
2920
config = {
3021
# This is described in more detail in the `server/banner.ts` but this line actually overrides
3122
# the built-in `require` function by adding a line at the bottom of the generated banner code
3223
# to assign the override function to the `require` name.
33-
"footer": { "js": "require = requireOverride;" },
24+
"footer": {"js": "require = requireOverride;"},
3425
# Workaround for https://github.com/aspect-build/rules_esbuild/issues/58
3526
"resolveExtensions": [".js"],
3627
},
28+
data = ["//server/src"],
29+
entry_point = "//server/src:banner.js",
30+
external = [
31+
"path",
32+
],
33+
format = "cjs",
3734
# Do not enable minification. It seems to break the extension on Windows (with WSL). See #1198.
3835
minify = False,
36+
platform = "node",
37+
sourcemap = "external",
3938
)
4039

4140
esbuild(
4241
name = "index",
43-
entry_point = "//server/src:server.js",
4442
srcs = [
45-
"//server/src",
4643
":banner.js",
44+
"//server/src",
4745
],
48-
platform = "node",
49-
format = "cjs",
50-
sourcemap = "external",
46+
config = "esbuild.mjs",
47+
entry_point = "//server/src:server.js",
5148
external = [
5249
"fs",
5350
"path",
@@ -58,30 +55,32 @@ esbuild(
5855
"vscode-languageserver-textdocument",
5956
"vscode-html-languageservice",
6057
],
61-
config = "esbuild.mjs",
58+
format = "cjs",
6259
# Do not enable minification. It seems to break the extension on Windows (with WSL). See #1198.
6360
minify = False,
61+
platform = "node",
62+
sourcemap = "external",
6463
visibility = [
6564
"//integration:__subpackages__",
66-
]
65+
],
6766
)
6867

6968
expand_template(
7069
name = "package_json_expanded",
71-
template = "package.json",
7270
out = "package_expanded.json",
73-
substitutions = {
74-
"0.0.0-PLACEHOLDER": VERSION,
75-
}
71+
stamp_substitutions = {
72+
"0.0.0-PLACEHOLDER": "{{BUILD_SCM_VERSION}}",
73+
},
74+
template = "package.json",
7675
)
7776

7877
filegroup(
7978
name = "npm_files",
8079
srcs = [
81-
"package_expanded.json",
8280
"README.md",
83-
"index.js",
8481
"bin/ngserver",
82+
"index.js",
83+
"package_expanded.json",
8584
],
8685
visibility = ["//:__pkg__"],
8786
)

version.bzl

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)