Skip to content
Merged
Show file tree
Hide file tree
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
16 changes: 12 additions & 4 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ module(
bazel_dep(name = "platforms", version = "1.0.0")
bazel_dep(name = "yq.bzl", version = "0.3.5")
bazel_dep(name = "rules_nodejs", version = "6.7.3")
bazel_dep(name = "aspect_rules_js", version = "2.9.2")
bazel_dep(name = "aspect_rules_js", version = "3.0.2")
bazel_dep(name = "aspect_rules_ts", version = "3.8.5")
bazel_dep(name = "rules_pkg", version = "1.2.0")
bazel_dep(name = "rules_cc", version = "0.2.17")
bazel_dep(name = "aspect_bazel_lib", version = "2.22.5")
bazel_dep(name = "jq.bzl", version = "0.4.0")
bazel_dep(name = "bazel_lib", version = "3.2.2")
bazel_dep(name = "bazel_skylib", version = "1.9.0")
bazel_dep(name = "aspect_rules_esbuild", version = "0.25.0")
bazel_dep(name = "aspect_rules_jasmine", version = "2.0.4")
Expand All @@ -25,7 +26,7 @@ git_override(
bazel_dep(name = "devinfra")
git_override(
module_name = "devinfra",
commit = "e4dcda13e469f50a6bd92667e2ded8b98173bf2c",
commit = "491fa7fc1803683748875b2b89d85700aca2b1f4",
remote = "https://github.com/angular/dev-infra.git",
)

Expand Down Expand Up @@ -160,6 +161,14 @@ npm.npm_translate_lock(
npmrc = "//:.npmrc",
pnpm_lock = "//:pnpm-lock.yaml",
)

# This is needed as by default `.md` files are excluded from the npm package.
# But @angular/core includes best-practices.md file.
# See: https://github.com/aspect-build/rules_js/blob/786a74a158dd36ed073188b0e506c423cd05501a/npm/private/exclude_package_contents_presets.bzl#L29
npm.npm_exclude_package_contents(
package = "@angular/core",
presets = [],
)
use_repo(npm, "npm")

rules_ts_ext = use_extension("@aspect_rules_ts//ts:extensions.bzl", "ext")
Expand All @@ -185,5 +194,4 @@ register_toolchains(
"@devinfra//bazel/git-toolchain:git_macos_arm64_toolchain",
"@devinfra//bazel/git-toolchain:git_windows_toolchain",
"//tools/toolchains:dummy_cc_windows_no_exec_toolchain",
"//tools/toolchains:node24_windows_no_exec_toolchain",
)
228 changes: 46 additions & 182 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion goldens/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
load("@bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")

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

Expand Down
1 change: 1 addition & 0 deletions modules/testing/builder/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ ts_project(
":node_modules/@angular/ssr",
":node_modules/browser-sync",
":node_modules/jsdom",
":node_modules/ng-packagr",
":node_modules/vitest",
":node_modules/@vitest/coverage-v8",
] + glob(["projects/**/*"]),
Expand Down
7 changes: 4 additions & 3 deletions modules/testing/builder/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"devDependencies": {
"@angular-devkit/core": "workspace:*",
"@angular-devkit/architect": "workspace:*",
"@angular/ssr": "workspace:*",
"@angular-devkit/build-angular": "workspace:*",
"browser-sync": "3.0.4",
"@angular-devkit/core": "workspace:*",
"@angular/ssr": "workspace:*",
"@vitest/coverage-v8": "4.0.18",
"browser-sync": "3.0.4",
"jsdom": "28.1.0",
"ng-packagr": "22.0.0-next.0",
"rxjs": "7.8.2",
"vitest": "4.0.18"
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"@rollup/plugin-commonjs": "^29.0.0",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "16.0.3",
"@rollup/wasm-node": "4.59.0",
"@stylistic/eslint-plugin": "^5.0.0",
"@tony.ganchev/eslint-plugin-header": "~3.2.4",
"@types/babel__core": "7.20.5",
Expand Down
4 changes: 3 additions & 1 deletion packages/angular/build/src/utils/worker-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ export class WorkerPool extends Piscina {
// Enable compile code caching if enabled for the main process (only exists on Node.js v22.8+).
// Skip if running inside Bazel via a RUNFILES environment variable check. The cache does not work
// well with Bazel's hermeticity requirements.
const compileCacheDirectory = process.env['RUNFILES'] ? undefined : getCompileCacheDir?.();
const compileCacheDirectory = process.env['JS_BINARY__RUNFILES']
? undefined
: getCompileCacheDir?.();
if (compileCacheDirectory) {
if (typeof piscinaOptions.env === 'object') {
piscinaOptions.env['NODE_COMPILE_CACHE'] = compileCacheDirectory;
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/cli/bin/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
*/

// Enable on-disk code caching if available (Node.js 22.8+)
// Skip if running inside Bazel via a RUNFILES environment variable check and no explicit cache
// Skip if running inside Bazel via a JS_BINARY__RUNFILES environment variable check and no explicit cache
// location defined. The default cache location does not work well with Bazel's hermeticity requirements.
if (!process.env['RUNFILES'] || process.env['NODE_COMPILE_CACHE']) {
if (!process.env['JS_BINARY__RUNFILES'] || process.env['NODE_COMPILE_CACHE']) {
try {
const { enableCompileCache } = require('node:module');

Expand Down
2 changes: 1 addition & 1 deletion packages/angular/ssr/test/npm_package/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_file")
load("@bazel_lib//lib:write_source_files.bzl", "write_source_file")
load("//tools:defaults.bzl", "jasmine_test", "ts_project")

ts_project(
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/ssr/third_party/beasties/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@npm//:rollup/package_json.bzl", rollup = "bin")
load("@npm//:@rollup/wasm-node/package_json.bzl", rollup = "bin")

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

Expand Down
9 changes: 2 additions & 7 deletions packages/angular_devkit/build_angular/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,6 @@ ts_project(
"src/builders/**/*_spec.ts",
],
),
data = [
"//packages/angular_devkit/build_angular/test/hello-world-lib",
],
deps = [
":build_angular",
":build_angular_test_utils",
Expand Down Expand Up @@ -268,9 +265,6 @@ ts_project(
"src/**/*_spec.ts",
],
),
data = [
"//packages/angular_devkit/build_angular/test/hello-world-lib",
],
deps = [
":build_angular",
":node_modules/@angular-devkit/architect",
Expand Down Expand Up @@ -319,7 +313,8 @@ LARGE_SPECS = {
"//:node_modules/@angular/animations",
],
},
"ng-packagr": {},
"ng-packagr": {
},
"browser": {
"shards": 10,
"size": "large",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import { purgeStaleBuildCache } from '@angular/build/private';
import { BuilderContext, BuilderOutput, createBuilder } from '@angular-devkit/architect';
import type { NgPackagrOptions } from 'ng-packagr';
import { createRequire } from 'node:module';
import { join, resolve } from 'node:path';
import { Observable, catchError, from, map, of, switchMap } from 'rxjs';
import { normalizeCacheOptions } from '../../utils/normalize-cache';
Expand All @@ -27,7 +28,9 @@ export function execute(
await purgeStaleBuildCache(context);

const root = context.workspaceRoot;
const packager = (await import('ng-packagr')).ngPackagr();
const workspaceRequire = createRequire(root + '/');
const ngPackagePath = workspaceRequire.resolve('ng-packagr');
const packager = (await import(ngPackagePath)).ngPackagr();

packager.forProject(resolve(root, options.project));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ import {
import { debounceTime, map, take, tap } from 'rxjs';

describe('NgPackagr Builder', () => {
const workspaceRoot = join(normalize(__dirname), `../../../test/hello-world-lib/`);
const workspaceRoot = join(
normalize(__dirname),
`../../../../../../modules/testing/builder/projects/hello-world-lib/`,
);
const host = new TestProjectHost(workspaceRoot);
let architect: Architect;

Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion packages/angular_devkit/schematics_cli/test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ npm_link_package(
name = "node_modules/@angular-devkit/schematics-cli",
src = "//packages/angular_devkit/schematics_cli:pkg",
package = "@angular-devkit/schematics-cli",
root_package = package_name(),
)

jasmine_test(
Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tests/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@aspect_bazel_lib//lib:directory_path.bzl", "directory_path")
load("@bazel_lib//lib:directory_path.bzl", "directory_path")
load("@npm//:@rollup/wasm-node/package_json.bzl", rollup = "bin")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@npm//:rollup/package_json.bzl", rollup = "bin")
load("//tools:defaults.bzl", "ts_project")
load(":e2e.bzl", "e2e_suites")

Expand Down
8 changes: 4 additions & 4 deletions tools/bazel/npm_package.bzl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
load("@aspect_bazel_lib//lib:expand_template.bzl", "expand_template")
load("@aspect_bazel_lib//lib:jq.bzl", "jq")
load("@aspect_bazel_lib//lib:utils.bzl", "to_label")
load("@aspect_rules_js//npm:defs.bzl", _npm_package = "npm_package")
load("@bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
load("@bazel_lib//lib:expand_template.bzl", "expand_template")
load("@bazel_lib//lib:utils.bzl", "to_label")
load("@jq.bzl//jq:jq.bzl", "jq")
load("@rules_pkg//:pkg.bzl", "pkg_tar")
load("//tools:link_package_json_to_tarballs.bzl", "link_package_json_to_tarballs")
load("//tools:snapshot_repo_filter.bzl", "SNAPSHOT_REPO_JQ_FILTER")
Expand Down
2 changes: 1 addition & 1 deletion tools/defaults.bzl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", _copy_to_bin = "copy_to_bin")
load("@aspect_rules_jasmine//jasmine:defs.bzl", _jasmine_test = "jasmine_test")
load("@aspect_rules_js//js:defs.bzl", _js_binary = "js_binary")
load("@bazel_lib//lib:copy_to_bin.bzl", _copy_to_bin = "copy_to_bin")
load("@devinfra//bazel/ts_project:index.bzl", "strict_deps_test")
load("@rules_angular//src/ng_examples_db:index.bzl", _ng_examples_db = "ng_examples_db")
load("@rules_angular//src/ng_package:index.bzl", _ng_package = "ng_package")
Expand Down
4 changes: 2 additions & 2 deletions tools/link_package_json_to_tarballs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#
# Use of this source code is governed by an MIT-style license that can be
# found in the LICENSE file at https://angular.dev/license
load("@aspect_bazel_lib//lib:jq.bzl", "jq")
load("@aspect_bazel_lib//lib:utils.bzl", "to_label")
load("@bazel_lib//lib:utils.bzl", "to_label")
load("@jq.bzl//jq:jq.bzl", "jq")

def link_package_json_to_tarballs(name, src, pkg_deps, out):
"""Substitute tar paths into a package.json file for the packages it depends on.
Expand Down
2 changes: 1 addition & 1 deletion tools/test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@aspect_bazel_lib//lib:jq.bzl", "jq")
load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
load("@jq.bzl//jq:jq.bzl", "jq")

jq(
name = "final_package_json",
Expand Down
12 changes: 0 additions & 12 deletions tools/toolchains/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
load("@rules_cc//cc:defs.bzl", "cc_toolchain")
load(":dummy_cc_toolchain.bzl", "dummy_cc_toolchain_config")

# This is needed following https://github.com/bazel-contrib/rules_nodejs/pull/3859
toolchain(
name = "node24_windows_no_exec_toolchain",
exec_compatible_with = [],
target_compatible_with = [
"@platforms//os:windows",
"@platforms//cpu:x86_64",
],
toolchain = "@node24_windows_amd64//:toolchain",
toolchain_type = "@rules_nodejs//nodejs:toolchain_type",
)

# This defines a dummy C++ toolchain for Windows.
# Without this, the build fails with "Unable to find a CC toolchain using toolchain resolution".
dummy_cc_toolchain_config(name = "dummy_cc_toolchain_config")
Expand Down