Skip to content

Commit 8564cf4

Browse files
committed
build: replace all ng_package with new rule from rules_angular (#61862)
Replaces all `ng_package` rule with the new rule from `rules_angular`. PR Close #61862
1 parent a24fb53 commit 8564cf4

File tree

35 files changed

+268
-180
lines changed

35 files changed

+268
-180
lines changed

.aspect/rules/external_repository_action_cache/npm_translate_lock_MzA5NzUwNzMx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
.npmrc=-1406867100
55
.pnpmfile.cjs=-2033668682
66
adev/shared-docs/pipeline/api-gen/package.json=939673974
7+
integration/package.json=-239561259
78
modules/package.json=-1315257891
89
package.json=2073214251
910
packages/animations/package.json=-678724831
@@ -20,7 +21,7 @@ packages/platform-browser/package.json=-1163479450
2021
packages/router/package.json=860819913
2122
packages/upgrade/package.json=16347051
2223
packages/zone.js/package.json=-1577512523
23-
pnpm-lock.yaml=1222242295
24-
pnpm-workspace.yaml=-1489095561
24+
pnpm-lock.yaml=354037729
25+
pnpm-workspace.yaml=1973735808
2526
tools/bazel/rules_angular_store/package.json=-239561259
2627
yarn.lock=2105129652

.bazelignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ modules/ssr-benchmarks/node_modules
4242
# For rules_js
4343
adev/shared-docs/pipeline/api-gen/node_modules
4444
modules/node_modules
45+
integration/node_modules
4546
packages/animations/node_modules
4647
packages/common/node_modules
4748
packages/localize/node_modules

WORKSPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ npm_translate_lock(
110110
"//:package.json",
111111
"//:pnpm-workspace.yaml",
112112
"//adev/shared-docs/pipeline/api-gen:package.json",
113+
"//integration:package.json",
113114
"//modules:package.json",
114115
"//packages/animations:package.json",
115116
"//packages/common:package.json",

adev/tools/local_deps/index.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def link_local_packages(all_deps):
2929
pkg_name = _angular_dep_to_pkg_name(dep)
3030
npm_link(
3131
name = _npm_link_name(pkg_name),
32-
target = to_package_label(pkg_name),
32+
target = to_package_label(pkg_name) + "__adev_link",
3333
package_name = pkg_name,
3434
package_path = native.package_name(),
3535
tags = ["manual"],

integration/BUILD.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
load("@npm2//:defs.bzl", "npm_link_all_packages")
2+
3+
npm_link_all_packages()

integration/ng-modules-importability/BUILD.bazel

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@ ts_project(
88
data = [
99
"//packages:package_json",
1010
],
11-
interop_deps = [
12-
"//packages/compiler-cli",
13-
],
1411
tsconfig = "tsconfig.json",
1512
deps = [
1613
"//:node_modules/@types/node",
1714
"//:node_modules/typescript",
15+
"//integration:node_modules/@angular/compiler-cli",
1816
],
1917
)
2018

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
load("@aspect_rules_js//js:defs.bzl", "js_test")
12
load("@bazel_skylib//rules:write_file.bzl", "write_file")
2-
load("//tools:defaults.bzl", "nodejs_test")
33

44
def module_test(name, npm_packages, skipped_entry_points = [], additional_deps = [], **kwargs):
55
write_file(
@@ -11,14 +11,13 @@ def module_test(name, npm_packages, skipped_entry_points = [], additional_deps =
1111
})],
1212
)
1313

14-
nodejs_test(
14+
js_test(
1515
name = "test",
1616
data = [
1717
":%s_config" % name,
18-
"//integration/ng-modules-importability:test_lib",
18+
"//integration/ng-modules-importability:test_lib_rjs",
1919
] + additional_deps + [pkg[0] for pkg in npm_packages.items()],
2020
entry_point = "//integration/ng-modules-importability:index.mjs",
21-
enable_linker = True,
22-
templated_args = ["$(rootpath :%s_config)" % name],
21+
fixed_args = ["$(rootpath :%s_config)" % name],
2322
**kwargs
2423
)

integration/ng-modules-importability/index.mts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {performCompilation} from '../../packages/compiler-cli/index.js';
1+
import {performCompilation} from '@angular/compiler-cli';
22
import * as fs from 'fs/promises';
33
import * as path from 'path';
44
import * as os from 'os';
@@ -33,6 +33,11 @@ async function main() {
3333
const testChunkStart = testChunkSize * testShardIndex;
3434
const shardExports = allExports.slice(testChunkStart, testChunkStart + testChunkSize);
3535

36+
// Sub-test directory where the first-party linked node modules end up being available.
37+
const testDir = path.join(tmpDir, 'test');
38+
await fs.mkdir(testDir);
39+
await fs.mkdir(path.join(testDir, 'node_modules/@angular'), {recursive: true});
40+
3641
const testFiles = shardExports.map((e) => ({
3742
content: `
3843
import {NgModule, Component} from '@angular/core';
@@ -46,15 +51,16 @@ async function main() {
4651
@Component({imports: [TestModule], template: ''})
4752
export class TestComponent {}
4853
`,
49-
path: path.join(tmpDir, `${e.symbolName.toLowerCase()}.ts`),
54+
path: path.join(testDir, `${e.symbolName.toLowerCase()}.ts`),
5055
}));
5156

5257
// Prepare node modules to resolve e.g. `@angular/core`
53-
await fs.symlink(path.resolve('./node_modules'), path.join(tmpDir, 'node_modules'));
58+
await fs.symlink(path.resolve('./integration/node_modules'), path.join(tmpDir, 'node_modules'));
59+
5460
// Prepare node modules to resolve e.g. `@angular/cdk`. This is possible
5561
// as we are inside the sandbox, inside our test runfiles directory.
5662
for (const {packagePath, name} of packages) {
57-
await fs.symlink(path.resolve(packagePath), `./node_modules/${name}`);
63+
await fs.symlink(path.resolve(packagePath), path.join(testDir, 'node_modules', name));
5864
}
5965

6066
const diagnostics: ts.Diagnostic[] = [];

integration/ng-modules-importability/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"strict": true,
44
"declaration": true,
55
"sourceMap": true,
6-
"module": "node16",
7-
"moduleResolution": "node16",
6+
"module": "esnext",
7+
"moduleResolution": "bundler",
88
"types": ["node"]
99
}
1010
}

integration/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"dependencies": {
3+
"@angular/compiler-cli": "workspace:*"
4+
}
5+
}

0 commit comments

Comments
 (0)