Skip to content

Commit f4bf900

Browse files
committed
build: move npm workspace into tools/bazel/legacy-rnjs
This allows us to drop the yarn lock file etc. We only need to temporarily keep this for the older `ng_package` rule.
1 parent 2c7f257 commit f4bf900

File tree

5 files changed

+155
-43
lines changed

5 files changed

+155
-43
lines changed

WORKSPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ load("@build_bazel_rules_nodejs//:index.bzl", "yarn_install")
107107
yarn_install(
108108
name = "npm",
109109
data = [
110-
"//tools/bazel/legacy-rnjs:.yarn/patches/@angular-bazel-https-67c38b3c32.patch",
110+
"//tools/bazel/legacy-rnjs:.yarn/patches/@angular-bazel-https-c46f484fb8.patch",
111111
"//tools/bazel/legacy-rnjs:.yarn/releases/yarn-4.5.0.cjs",
112112
"//tools/bazel/legacy-rnjs:.yarnrc.yml",
113113
],

tools/bazel/legacy-rnjs/.yarn/patches/@angular-bazel-https-67c38b3c32.patch

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
diff --git a/src/ng_module/partial_compilation.bzl b/src/ng_module/partial_compilation.bzl
2+
index 5fd9a73d0118485c93cf39be7a2330ebe6c24243..c155cea264f524b2289917c48af3043870163c13 100644
3+
--- a/src/ng_module/partial_compilation.bzl
4+
+++ b/src/ng_module/partial_compilation.bzl
5+
@@ -16,10 +16,10 @@ ng_partial_compilation_flag = rule(
6+
)
7+
8+
def _partial_compilation_transition_impl(_settings, _attr):
9+
- return {"@npm//@angular/bazel/src:partial_compilation": True}
10+
+ return {"@rules_angular//src/ng_project/config:partial_compilation": True}
11+
12+
partial_compilation_transition = transition(
13+
implementation = _partial_compilation_transition_impl,
14+
inputs = [],
15+
- outputs = ["@npm//@angular/bazel/src:partial_compilation"],
16+
+ outputs = ["@rules_angular//src/ng_project/config:partial_compilation"],
17+
)
18+
diff --git a/src/ng_package/packager.mjs b/src/ng_package/packager.mjs
19+
index 20604c595be4b5bb0fea0bae0aeb2c2a1f4b83eb..265c2cf00aacf29844bdd1154ba2400f40810bc0 100755
20+
--- a/src/ng_package/packager.mjs
21+
+++ b/src/ng_package/packager.mjs
22+
@@ -8,7 +8,7 @@
23+
import * as fs from 'fs';
24+
import * as path from 'path';
25+
import { globSync } from 'tinyglobby';
26+
-import { analyzeFileAndEnsureNoCrossImports } from './cross_entry_points_imports';
27+
+import { analyzeFileAndEnsureNoCrossImports } from './cross_entry_points_imports.mjs';
28+
/**
29+
* List of known `package.json` fields which provide information about
30+
* supported package formats and their associated entry paths.
31+
@@ -28,19 +28,19 @@ function main(args) {
32+
const params = fs.readFileSync(paramFilePath, 'utf-8').split('\n').map(unquoteParameter);
33+
const [
34+
// Output directory for the npm package.
35+
- outputDirExecPath,
36+
+ outputDirExecPath,
37+
// The package segment of the ng_package rule's label (e.g. 'package/common').
38+
- owningPackageName,
39+
+ owningPackageName,
40+
// JSON data capturing metadata of the package being built. See `PackageMetadata`.
41+
- metadataArg,
42+
+ metadataArg,
43+
// Path to the package's README.md.
44+
- readmeMd,
45+
+ readmeMd,
46+
// Path to the package's LICENSE file.
47+
- licenseFile,
48+
+ licenseFile,
49+
// List of individual ES2022 modules
50+
- esm2022Arg,
51+
+ esm2022Arg,
52+
// List of static files that should be copied into the package.
53+
- staticFilesArg,
54+
+ staticFilesArg,
55+
// List of side-effectful entry-points
56+
sideEffectEntryPointsArg,] = params;
57+
const esm2022 = JSON.parse(esm2022Arg);
58+
@@ -111,7 +111,7 @@ function main(args) {
59+
fesmFiles.forEach((f) => copyFile(path.join(metadata.fesmBundlesOut.path, f), path.join('fesm2022', f)));
60+
// Copy all dts files (and their potential shared chunks) into the package output.
61+
const dtsFiles = globSync('**/*', { cwd: metadata.dtsBundlesOut.path });
62+
- dtsFiles.forEach((f) =>
63+
+ dtsFiles.forEach((f) =>
64+
// TODO(devversion): Put all types under `/types/` folder. Breaking change in v20.
65+
copyFile(path.join(metadata.dtsBundlesOut.path, f), f));
66+
for (const file of staticFiles) {
67+
@@ -236,7 +236,7 @@ function main(args) {
68+
}
69+
const sideEffects = packageJson.sideEffects;
70+
const neededSideEffects = sideEffectEntryPoints.map((entryPointModule) => `./${metadata.entryPoints[entryPointModule].fesm2022RelativePath}`);
71+
- const missingSideEffects = neededSideEffects.filter((p) =>
72+
+ const missingSideEffects = neededSideEffects.filter((p) =>
73+
// It's missing, if the whole package is marked as having no side effects.
74+
sideEffects === false ||
75+
// Alternatively, it's missing if the explicit list doesn't contain the pattern.
76+
diff --git a/src/ng_package/rollup.config.js b/src/ng_package/rollup.config.js
77+
index 22a4d89fb9b1f43b2092ed5ee18e1865f6d7e7cc..cdf42e39e8d7e96c91ec3765237de816958f1da7 100644
78+
--- a/src/ng_package/rollup.config.js
79+
+++ b/src/ng_package/rollup.config.js
80+
@@ -188,7 +188,6 @@ if (dtsMode) {
81+
nodeResolve({
82+
mainFields: ['es2020', 'es2015', 'module', 'browser'],
83+
jail: process.cwd(),
84+
- customResolveOptions: {moduleDirectory: nodeModulesRoot},
85+
}),
86+
commonjs({ignoreGlobal: true}),
87+
sourcemaps(),

tools/bazel/legacy-rnjs/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{
22
"name": "angular-cli-legacy-rnjs",
33
"dependencies": {
4-
"@angular/bazel": "patch:@angular/bazel@https%3A//github.com/angular/bazel-builds.git%23commit=8269ca110da4ead292163e7f2614b6407efe40ca#~/.yarn/patches/@angular-bazel-https-67c38b3c32.patch",
4+
"@angular/bazel": "patch:@angular/bazel@https%3A//github.com/angular/bazel-builds.git%23commit=3a433f1e2ae86611d1eff4012ad6940112480b5b#~/.yarn/patches/@angular-bazel-https-c46f484fb8.patch",
55
"@bazel/concatjs": "^5.8.1",
66
"@bazel/rollup": "^5.8.1",
77
"@bazel/typescript": "^5.8.1",
88
"@rollup/plugin-commonjs": "^28.0.2",
99
"@rollup/plugin-node-resolve": "^16.0.0",
1010
"rollup": "^4.34.9",
11+
"rollup-plugin-dts": "6.2.1",
1112
"rollup-plugin-sourcemaps": "^0.6.3"
1213
}
1314
}

tools/bazel/legacy-rnjs/yarn.lock

Lines changed: 65 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,22 @@ __metadata:
55
version: 8
66
cacheKey: 10c0
77

8-
"@angular/bazel@https://github.com/angular/bazel-builds.git#commit=8269ca110da4ead292163e7f2614b6407efe40ca":
9-
version: 20.0.0-next.1+sha-a02e270
10-
resolution: "@angular/bazel@https://github.com/angular/bazel-builds.git#commit=8269ca110da4ead292163e7f2614b6407efe40ca"
8+
"@angular/bazel@https://github.com/angular/bazel-builds.git#commit=3a433f1e2ae86611d1eff4012ad6940112480b5b":
9+
version: 20.0.0-next.6+sha-c0ef923
10+
resolution: "@angular/bazel@https://github.com/angular/bazel-builds.git#commit=3a433f1e2ae86611d1eff4012ad6940112480b5b"
1111
dependencies:
1212
"@microsoft/api-extractor": "npm:^7.24.2"
1313
magic-string: "npm:^0.30.0"
1414
tinyglobby: "npm:^0.2.12"
1515
tslib: "npm:^2.3.0"
1616
peerDependencies:
17-
"@angular/compiler-cli": 20.0.0-next.1+sha-a02e270
17+
"@angular/compiler-cli": 20.0.0-next.6+sha-c0ef923
1818
"@bazel/concatjs": ^5.3.0
1919
"@bazel/worker": ^5.3.0
2020
"@rollup/plugin-commonjs": ^28.0.0
2121
"@rollup/plugin-node-resolve": ^13.0.4
22-
rollup: ^2.56.3
22+
rollup: 4.35.0
23+
rollup-plugin-dts: ^6.1.1
2324
rollup-plugin-sourcemaps: ^0.6.3
2425
terser: ^5.9.0
2526
typescript: ">=5.8 <5.9"
@@ -29,27 +30,27 @@ __metadata:
2930
bin:
3031
ngc-wrapped: ./src/ngc-wrapped/index.mjs
3132
packager: ./src/ng_package/packager.mjs
32-
types_bundler: ./src/types_bundle/index.mjs
3333
xi18n: ./src/ngc-wrapped/extract_i18n.mjs
34-
checksum: 10c0/1871822cd08f233ff3776ef4c7865984924d75781c31d2fe849e6353763daf4800b629d3c0a1b56ef09c857a8a8ce231aa49a1f3d6776f85307c9684f6a6126a
34+
checksum: 10c0/c3d8b4807ef36a0ebd391a7782582466509db5dda90e6e32bfa04a31432b69fa5f5d6c8a171720211cce7c709e188c6189b8c6ca83cc041d20b1b1d88c893c9e
3535
languageName: node
3636
linkType: hard
3737

38-
"@angular/bazel@patch:@angular/bazel@https%3A//github.com/angular/bazel-builds.git%23commit=8269ca110da4ead292163e7f2614b6407efe40ca#~/.yarn/patches/@angular-bazel-https-67c38b3c32.patch":
39-
version: 20.0.0-next.1+sha-a02e270
40-
resolution: "@angular/bazel@patch:@angular/bazel@https%3A//github.com/angular/bazel-builds.git%23commit=8269ca110da4ead292163e7f2614b6407efe40ca#~/.yarn/patches/@angular-bazel-https-67c38b3c32.patch::version=20.0.0-next.1%2Bsha-a02e270&hash=e9cb6d"
38+
"@angular/bazel@patch:@angular/bazel@https%3A//github.com/angular/bazel-builds.git%23commit=3a433f1e2ae86611d1eff4012ad6940112480b5b#~/.yarn/patches/@angular-bazel-https-c46f484fb8.patch":
39+
version: 20.0.0-next.6+sha-c0ef923
40+
resolution: "@angular/bazel@patch:@angular/bazel@https%3A//github.com/angular/bazel-builds.git%23commit=3a433f1e2ae86611d1eff4012ad6940112480b5b#~/.yarn/patches/@angular-bazel-https-c46f484fb8.patch::version=20.0.0-next.6%2Bsha-c0ef923&hash=3d21c9"
4141
dependencies:
4242
"@microsoft/api-extractor": "npm:^7.24.2"
4343
magic-string: "npm:^0.30.0"
4444
tinyglobby: "npm:^0.2.12"
4545
tslib: "npm:^2.3.0"
4646
peerDependencies:
47-
"@angular/compiler-cli": 20.0.0-next.1+sha-a02e270
47+
"@angular/compiler-cli": 20.0.0-next.6+sha-c0ef923
4848
"@bazel/concatjs": ^5.3.0
4949
"@bazel/worker": ^5.3.0
5050
"@rollup/plugin-commonjs": ^28.0.0
5151
"@rollup/plugin-node-resolve": ^13.0.4
52-
rollup: ^2.56.3
52+
rollup: 4.35.0
53+
rollup-plugin-dts: ^6.1.1
5354
rollup-plugin-sourcemaps: ^0.6.3
5455
terser: ^5.9.0
5556
typescript: ">=5.8 <5.9"
@@ -59,9 +60,26 @@ __metadata:
5960
bin:
6061
ngc-wrapped: ./src/ngc-wrapped/index.mjs
6162
packager: ./src/ng_package/packager.mjs
62-
types_bundler: ./src/types_bundle/index.mjs
6363
xi18n: ./src/ngc-wrapped/extract_i18n.mjs
64-
checksum: 10c0/da86c278c486f4e270257142b549a08c38dd55ada0662352e61c2ea166989a638734d8ea99e8c2c5daccaff90978105748cd7bb5a330d07d9ad1039fe4f31d3e
64+
checksum: 10c0/65d26aa2ebb65544a7c15c93be221cf17161c46f91b8f23b12643c659124905841ff5deeb99ec66c4b5877fee4860cef7a9efe6dbb3c19d631cdc269eb066723
65+
languageName: node
66+
linkType: hard
67+
68+
"@babel/code-frame@npm:^7.26.2":
69+
version: 7.26.2
70+
resolution: "@babel/code-frame@npm:7.26.2"
71+
dependencies:
72+
"@babel/helper-validator-identifier": "npm:^7.25.9"
73+
js-tokens: "npm:^4.0.0"
74+
picocolors: "npm:^1.0.0"
75+
checksum: 10c0/7d79621a6849183c415486af99b1a20b84737e8c11cd55b6544f688c51ce1fd710e6d869c3dd21232023da272a79b91efb3e83b5bc2dc65c1187c5fcd1b72ea8
76+
languageName: node
77+
linkType: hard
78+
79+
"@babel/helper-validator-identifier@npm:^7.25.9":
80+
version: 7.25.9
81+
resolution: "@babel/helper-validator-identifier@npm:7.25.9"
82+
checksum: 10c0/4fc6f830177b7b7e887ad3277ddb3b91d81e6c4a24151540d9d1023e8dc6b1c0505f0f0628ae653601eb4388a8db45c1c14b2c07a9173837aef7e4116456259d
6583
languageName: node
6684
linkType: hard
6785

@@ -689,13 +707,14 @@ __metadata:
689707
version: 0.0.0-use.local
690708
resolution: "angular-cli-legacy-rnjs@workspace:."
691709
dependencies:
692-
"@angular/bazel": "patch:@angular/bazel@https%3A//github.com/angular/bazel-builds.git%23commit=8269ca110da4ead292163e7f2614b6407efe40ca#~/.yarn/patches/@angular-bazel-https-67c38b3c32.patch"
710+
"@angular/bazel": "patch:@angular/bazel@https%3A//github.com/angular/bazel-builds.git%23commit=3a433f1e2ae86611d1eff4012ad6940112480b5b#~/.yarn/patches/@angular-bazel-https-c46f484fb8.patch"
693711
"@bazel/concatjs": "npm:^5.8.1"
694712
"@bazel/rollup": "npm:^5.8.1"
695713
"@bazel/typescript": "npm:^5.8.1"
696714
"@rollup/plugin-commonjs": "npm:^28.0.2"
697715
"@rollup/plugin-node-resolve": "npm:^16.0.0"
698716
rollup: "npm:^4.34.9"
717+
rollup-plugin-dts: "npm:6.2.1"
699718
rollup-plugin-sourcemaps: "npm:^0.6.3"
700719
languageName: unknown
701720
linkType: soft
@@ -1194,6 +1213,13 @@ __metadata:
11941213
languageName: node
11951214
linkType: hard
11961215

1216+
"js-tokens@npm:^4.0.0":
1217+
version: 4.0.0
1218+
resolution: "js-tokens@npm:4.0.0"
1219+
checksum: 10c0/e248708d377aa058eacf2037b07ded847790e6de892bbad3dac0abba2e759cb9f121b00099a65195616badcb6eca8d14d975cb3e89eb1cfda644756402c8aeed
1220+
languageName: node
1221+
linkType: hard
1222+
11971223
"jsbn@npm:1.1.0":
11981224
version: 1.1.0
11991225
resolution: "jsbn@npm:1.1.0"
@@ -1251,7 +1277,7 @@ __metadata:
12511277
languageName: node
12521278
linkType: hard
12531279

1254-
"magic-string@npm:^0.30.0, magic-string@npm:^0.30.3":
1280+
"magic-string@npm:^0.30.0, magic-string@npm:^0.30.17, magic-string@npm:^0.30.3":
12551281
version: 0.30.17
12561282
resolution: "magic-string@npm:0.30.17"
12571283
dependencies:
@@ -1466,6 +1492,13 @@ __metadata:
14661492
languageName: node
14671493
linkType: hard
14681494

1495+
"picocolors@npm:^1.0.0":
1496+
version: 1.1.1
1497+
resolution: "picocolors@npm:1.1.1"
1498+
checksum: 10c0/e2e3e8170ab9d7c7421969adaa7e1b31434f789afb9b3f115f6b96d91945041ac3ceb02e9ec6fe6510ff036bcc0bf91e69a1772edc0b707e12b19c0f2d6bcf58
1499+
languageName: node
1500+
linkType: hard
1501+
14691502
"picomatch@npm:^2.2.2":
14701503
version: 2.3.1
14711504
resolution: "picomatch@npm:2.3.1"
@@ -1579,6 +1612,22 @@ __metadata:
15791612
languageName: node
15801613
linkType: hard
15811614

1615+
"rollup-plugin-dts@npm:6.2.1":
1616+
version: 6.2.1
1617+
resolution: "rollup-plugin-dts@npm:6.2.1"
1618+
dependencies:
1619+
"@babel/code-frame": "npm:^7.26.2"
1620+
magic-string: "npm:^0.30.17"
1621+
peerDependencies:
1622+
rollup: ^3.29.4 || ^4
1623+
typescript: ^4.5 || ^5.0
1624+
dependenciesMeta:
1625+
"@babel/code-frame":
1626+
optional: true
1627+
checksum: 10c0/f21c8726470851a40e6ca68ae580261cee8bc6275775291b9c0fdf93b868ed54f12b11c8c0dddce2c14f5691d6032b6647d094835ab9b6789226efa60e1aa71e
1628+
languageName: node
1629+
linkType: hard
1630+
15821631
"rollup-plugin-sourcemaps@npm:^0.6.3":
15831632
version: 0.6.3
15841633
resolution: "rollup-plugin-sourcemaps@npm:0.6.3"

0 commit comments

Comments
 (0)