Skip to content

Commit

Permalink
build: setup rules_js and link dependencies
Browse files Browse the repository at this point in the history
This also requires us to move patches from `patch:` protocol to
`patch-package` temporarily. This is because we need to temporarily use
pnpm and yarn berry in hybrid, and both don't have any overlap in how
patching works; and pnpm would fail if it sees the `patch` protocol.
  • Loading branch information
devversion authored and clydin committed Dec 16, 2024
1 parent 183f772 commit f22d4ee
Show file tree
Hide file tree
Showing 14 changed files with 15,778 additions and 515 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# @generated
# Input hashes for repository rule npm_translate_lock(name = "npm2", pnpm_lock = "@//:pnpm-lock.yaml").
# This file should be checked into version control along with the pnpm-lock.yaml file.
.npmrc=-2023857461
package.json=1474377014
pnpm-lock.yaml=1733416088
pnpm-workspace.yaml=1711114604
yarn.lock=-607783516
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ jobs:
run: yarn install --immutable
- name: Run module and package tests
run: yarn bazel test //modules/... //packages/...
env:
ASPECT_RULES_JS_FROZEN_PNPM_LOCK: '1'

e2e:
strategy:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ jobs:
run: yarn install --immutable
- name: Run module and package tests
run: yarn bazel test //modules/... //packages/...
env:
ASPECT_RULES_JS_FROZEN_PNPM_LOCK: '1'

e2e:
strategy:
Expand Down
8 changes: 7 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
engine-strict = true
# Yarn Berry doesn't check engines at all, so pnpm shouldn't either.
engine-strict = false

# Disabling pnpm [hoisting](https://pnpm.io/npmrc#hoist) by setting `hoist=false` is recommended on
# projects using rules_js so that pnpm outside of Bazel lays out a node_modules tree similar to what
# rules_js lays out under Bazel (without a hidden node_modules/.pnpm/node_modules)
hoist=false
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
dist/
/tests/legacy-cli/e2e/assets/
/tools/test/*.json
pnpm-lock.yaml
5 changes: 5 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
load("@build_bazel_rules_nodejs//:index.bzl", "copy_to_bin")
load("@npm//@bazel/concatjs:index.bzl", "ts_config")
load("@npm2//:defs.bzl", "npm_link_all_packages")

package(default_visibility = ["//visibility:public"])

Expand All @@ -19,6 +20,10 @@ exports_files([
"package.json",
])

npm_link_all_packages(
name = "node_modules",
)

# Files required by e2e tests
copy_to_bin(
name = "config-files",
Expand Down
51 changes: 47 additions & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
workspace(name = "angular_cli")

DEFAULT_NODE_VERSION = "18.19.1"

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
Expand Down Expand Up @@ -27,6 +29,17 @@ load("@build_bazel_rules_nodejs//:repositories.bzl", "build_bazel_rules_nodejs_d

build_bazel_rules_nodejs_dependencies()

http_archive(
name = "aspect_rules_js",
sha256 = "75c25a0f15a9e4592bbda45b57aa089e4bf17f9176fd735351e8c6444df87b52",
strip_prefix = "rules_js-2.1.0",
url = "https://github.com/aspect-build/rules_js/releases/download/v2.1.0/rules_js-v2.1.0.tar.gz",
)

load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")

rules_js_dependencies()

http_archive(
name = "rules_pkg",
sha256 = "8c20f74bca25d2d442b327ae26768c02cf3c99e93fad0381f32be9aab1967675",
Expand Down Expand Up @@ -70,7 +83,7 @@ nodejs_register_toolchains(
name = "nodejs",
# The below can be removed once @rules_nodejs/nodejs is updated to latest which contains https://github.com/bazelbuild/rules_nodejs/pull/3701
node_repositories = NODE_18_REPO,
node_version = "18.19.1",
node_version = DEFAULT_NODE_VERSION,
)

nodejs_register_toolchains(
Expand Down Expand Up @@ -103,16 +116,23 @@ nodejs_register_toolchains(
node_version = "22.0.0",
)

load("@aspect_rules_js//js:toolchains.bzl", "rules_js_register_toolchains")

rules_js_register_toolchains(
node_repositories = NODE_18_REPO,
node_version = DEFAULT_NODE_VERSION,
)

load("@build_bazel_rules_nodejs//:index.bzl", "yarn_install")

yarn_install(
name = "npm",
data = [
"//:.yarn/patches/@angular-bazel-https-9848736cf4.patch",
"//:.yarn/patches/@bazel-concatjs-npm-5.8.1-1bf81df846.patch",
"//:.yarn/patches/@bazel-jasmine-npm-5.8.1-3370fee155.patch",
"//:.yarn/releases/yarn-4.5.0.cjs",
"//:.yarnrc.yml",
"//:patches/@angular+bazel+19.0.0-next.7.patch",
"//:patches/@bazel+concatjs+5.8.1.patch",
"//:patches/@bazel+jasmine+5.8.1.patch",
],
# Currently disabled due to:
# 1. Missing Windows support currently.
Expand Down Expand Up @@ -152,3 +172,26 @@ load("@build_bazel_rules_nodejs//toolchains/esbuild:esbuild_repositories.bzl", "
esbuild_repositories(
npm_repository = "npm",
)

load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock")

npm_translate_lock(
name = "npm2",
data = [
"//:package.json",
"//:pnpm-workspace.yaml",
],
npmrc = "//:.npmrc",
patches = {
# Note: Patches not needed as the existing patches are only
# for `rules_nodejs` dependencies :)
},
pnpm_lock = "//:pnpm-lock.yaml",
update_pnpm_lock = True,
verify_node_modules_ignored = "//:.bazelignore",
yarn_lock = "//:yarn.lock",
)

load("@npm2//:repositories.bzl", "npm_repositories")

npm_repositories()
24 changes: 9 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
"sdk",
"Angular DevKit"
],
"packageManager": "[email protected]",
"scripts": {
"admin": "node --no-warnings=ExperimentalWarning --loader ts-node/esm/transpile-only ./scripts/devkit-admin.mjs",
"test": "bazel test //packages/...",
"build": "yarn admin build",
"lint": "eslint --cache --max-warnings=0 \"**/*.@(ts|mts|cts)\"",
"templates": "yarn admin templates",
"validate": "yarn admin validate",
"postinstall": "yarn webdriver-update && yarn husky",
"postinstall": "patch-package && yarn webdriver-update && yarn husky",
"//webdriver-update-README": "ChromeDriver version must match Puppeteer Chromium version, see https://github.com/GoogleChrome/puppeteer/releases http://chromedriver.chromium.org/downloads",
"webdriver-update": "webdriver-manager update --standalone false --gecko false --versions.chrome 106.0.5249.21",
"public-api:check": "node goldens/public-api/manage.js test",
Expand All @@ -42,18 +41,10 @@
"url": "https://github.com/angular/angular-cli/issues"
},
"homepage": "https://github.com/angular/angular-cli",
"workspaces": {
"packages": [
"packages/angular/*",
"packages/angular_devkit/*",
"packages/ngtools/*",
"packages/schematics/*"
]
},
"devDependencies": {
"@ampproject/remapping": "2.3.0",
"@angular/animations": "19.1.0-next.3",
"@angular/bazel": "patch:@angular/bazel@https%3A//github.com/angular/bazel-builds.git%23commit=07617f0f8540d27f8895b1820a6f994e1e5b7277#~/.yarn/patches/@angular-bazel-https-9848736cf4.patch",
"@angular/bazel": "https://github.com/angular/bazel-builds.git#07617f0f8540d27f8895b1820a6f994e1e5b7277",
"@angular/build-tooling": "https://github.com/angular/dev-infra-private-build-tooling-builds.git#d17f802de0af0ac409259f97678ce59ddd0671a0",
"@angular/cdk": "19.1.0-next.2",
"@angular/common": "19.1.0-next.3",
Expand Down Expand Up @@ -81,8 +72,8 @@
"@babel/runtime": "7.26.0",
"@bazel/bazelisk": "1.25.0",
"@bazel/buildifier": "7.3.1",
"@bazel/concatjs": "patch:@bazel/concatjs@npm%3A5.8.1#~/.yarn/patches/@bazel-concatjs-npm-5.8.1-1bf81df846.patch",
"@bazel/jasmine": "patch:@bazel/jasmine@npm%3A5.8.1#~/.yarn/patches/@bazel-jasmine-npm-5.8.1-3370fee155.patch",
"@bazel/concatjs": "5.8.1",
"@bazel/jasmine": "5.8.1",
"@bazel/rollup": "^5.8.1",
"@bazel/runfiles": "^5.8.1",
"@discoveryjs/json-ext": "0.6.3",
Expand Down Expand Up @@ -175,6 +166,7 @@
"ora": "5.4.1",
"pacote": "20.0.0",
"parse5-html-rewriting-stream": "7.0.0",
"patch-package": "^8.0.0",
"picomatch": "4.0.2",
"piscina": "4.8.0",
"postcss": "8.4.49",
Expand Down Expand Up @@ -225,8 +217,10 @@
"built": true
}
},
"pnpm": {
"onlyBuiltDependencies": []
},
"resolutions": {
"@bazel/concatjs@npm:5.8.1": "patch:@bazel/concatjs@npm%3A5.8.1#~/.yarn/patches/@bazel-concatjs-npm-5.8.1-1bf81df846.patch",
"@microsoft/api-extractor/typescript": "5.6.3"
"typescript": "5.7.2"
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
diff --git a/src/ng_package/packager.mjs b/src/ng_package/packager.mjs
diff --git a/node_modules/@angular/bazel/src/ng_package/packager.mjs b/node_modules/@angular/bazel/src/ng_package/packager.mjs
index 5c1f3a2c72e28a90b666c96b2fe9755cdafd5259..47034ceeb0b9ab9c1e9bee50239723a51d2e2e19 100755
--- a/src/ng_package/packager.mjs
+++ b/src/ng_package/packager.mjs
--- a/node_modules/@angular/bazel/src/ng_package/packager.mjs
+++ b/node_modules/@angular/bazel/src/ng_package/packager.mjs
@@ -7,7 +7,7 @@
*/
import * as fs from 'fs';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
diff --git a/internal/build_defs.bzl b/internal/build_defs.bzl
diff --git a/node_modules/@bazel/concatjs/internal/build_defs.bzl b/node_modules/@bazel/concatjs/internal/build_defs.bzl
index 9e5cda684f0456b61d1b6c0f9c56ae021594713f..6c45196bda5880531d32618dfca0dee44c035cb9 100755
--- a/internal/build_defs.bzl
+++ b/internal/build_defs.bzl
--- a/node_modules/@bazel/concatjs/internal/build_defs.bzl
+++ b/node_modules/@bazel/concatjs/internal/build_defs.bzl
@@ -76,7 +76,7 @@ _TYPESCRIPT_TYPINGS = Label(
"//typescript:typescript__typings",
)

-_TYPESCRIPT_SCRIPT_TARGETS = ["es3", "es5", "es2015", "es2016", "es2017", "es2018", "es2019", "es2020", "esnext"]
+_TYPESCRIPT_SCRIPT_TARGETS = ["es3", "es5", "es2015", "es2016", "es2017", "es2018", "es2019", "es2020", "es2022", "esnext"]
_TYPESCRIPT_MODULE_KINDS = ["none", "commonjs", "amd", "umd", "system", "es2015", "esnext"]

_DEVMODE_TARGET_DEFAULT = "es2015"
diff --git a/internal/common/tsconfig.bzl b/internal/common/tsconfig.bzl
diff --git a/node_modules/@bazel/concatjs/internal/common/tsconfig.bzl b/node_modules/@bazel/concatjs/internal/common/tsconfig.bzl
index b01c999f5e02b388f51a508b0b608cf69db9b664..847c23fe4829d0c847e9b4bd1ad698e1ccea720e 100755
--- a/internal/common/tsconfig.bzl
+++ b/internal/common/tsconfig.bzl
--- a/node_modules/@bazel/concatjs/internal/common/tsconfig.bzl
+++ b/node_modules/@bazel/concatjs/internal/common/tsconfig.bzl
@@ -211,9 +211,6 @@ def create_tsconfig(
# will convert that to goog.module syntax.
"module": "umd" if devmode_manifest or has_node_runtime else "esnext",

- # Has no effect in closure/ES2015 mode. Always true just for simplicity.
- "downlevelIteration": True,
-
Expand All @@ -28,7 +28,7 @@ index b01c999f5e02b388f51a508b0b608cf69db9b664..847c23fe4829d0c847e9b4bd1ad698e1
@@ -248,13 +245,6 @@ def create_tsconfig(
# "short name" mappings for npm packages, such as "@angular/core"
"paths": mapped_module_roots,

- # Inline const enums.
- "preserveConstEnums": False,
-
Expand All @@ -38,7 +38,7 @@ index b01c999f5e02b388f51a508b0b608cf69db9b664..847c23fe4829d0c847e9b4bd1ad698e1
-
# Interpret JSX as React calls (until someone asks for something different)
"jsx": "react",

@@ -277,12 +267,6 @@ def create_tsconfig(
# always emit declaration files in the same location as outDir.
"declarationDir": "/".join([workspace_path, outdir_path]),
Expand All @@ -50,12 +50,12 @@ index b01c999f5e02b388f51a508b0b608cf69db9b664..847c23fe4829d0c847e9b4bd1ad698e1
- # Implied by inlineSourceMap: True
- "sourceMap": False,
}

# "node_modules" still checked for backward compat for ng_module
diff --git a/internal/tsetse/rules/must_use_promises_rule.js b/internal/tsetse/rules/must_use_promises_rule.js
diff --git a/node_modules/@bazel/concatjs/internal/tsetse/rules/must_use_promises_rule.js b/node_modules/@bazel/concatjs/internal/tsetse/rules/must_use_promises_rule.js
index e404d01cf80ab4da4b9cca89005b14a60b7d8c79..85488d9a339982af4495d2b5f4c30effb98a538b 100755
--- a/internal/tsetse/rules/must_use_promises_rule.js
+++ b/internal/tsetse/rules/must_use_promises_rule.js
--- a/node_modules/@bazel/concatjs/internal/tsetse/rules/must_use_promises_rule.js
+++ b/node_modules/@bazel/concatjs/internal/tsetse/rules/must_use_promises_rule.js
@@ -30,6 +30,10 @@ function checkCallExpression(checker, node) {
if (tsutils.isExpressionValueUsed(node) || !inAsyncFunction(node)) {
return;
Expand Down
8 changes: 4 additions & 4 deletions [email protected] → patches/@bazel+jasmine+5.8.1.patch
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
diff --git a/jasmine_runner.js b/jasmine_runner.js
diff --git a/node_modules/@bazel/jasmine/jasmine_runner.js b/node_modules/@bazel/jasmine/jasmine_runner.js
index 097eb920357f5f02e5b6592e0e4be27c0b4bf25d..bd55c2dad833b32a9e644fed8c7d6b626cd01128 100755
--- a/jasmine_runner.js
+++ b/jasmine_runner.js
--- a/node_modules/@bazel/jasmine/jasmine_runner.js
+++ b/node_modules/@bazel/jasmine/jasmine_runner.js
@@ -147,7 +147,7 @@ async function main(args) {
// TODO(6.0): remove support for deprecated versions of Jasmine that use the old API &
// remember to update the `peerDependencies` as well.
// Jasmine versions prior to 4.0.0 should use the old API.
- if (jrunner.coreVersion().charAt(0) !== '4') {
+ if (+jrunner.coreVersion().charAt(0) < 4) {
console.warn(`DEPRECATED: Support for Jasmine versions prior to '4.0.x' is deprecated in '@bazel/jasmine'.`);

// Old Jasmine API.
Loading

0 comments on commit f22d4ee

Please sign in to comment.