build: improve dependency management for local packages

Refactor .pnpmfile.cjs to use a Set for localAngularPackages for better performance.
Adjust typescript dependency handling in compiler-cli to correctly use devDependencies.
Promote rxjs and zone.js from peer dependencies to regular dependencies for local packages.
These changes streamline dependency resolution and align with pnpm's behavior for workspace dependencies.
This commit is contained in:
Alan Agius
2025-11-12 14:37:31 +00:00
committed by Andrew Kushnir
parent c51b42f1ce
commit 0835bd815f
3 changed files with 21 additions and 9 deletions
+17 -8
View File
@@ -1,5 +1,5 @@
// TODO: Define these packages in a single common location. // TODO: Define these packages in a single common location.
const localAngularPackages = [ const localAngularPackages = new Set([
'@angular/animations', '@angular/animations',
'@angular/common', '@angular/common',
'@angular/compiler', '@angular/compiler',
@@ -15,7 +15,9 @@ const localAngularPackages = [
'@angular/router', '@angular/router',
'@angular/service-worker', '@angular/service-worker',
'@angular/upgrade', '@angular/upgrade',
]; ]);
const peerDepsToChange = new Set(['zone.js', 'rxjs']);
function readPackage(pkg, context) { function readPackage(pkg, context) {
// TODO(devversion): This allows us to make compiler/TS a production dependency of compiler-cli // TODO(devversion): This allows us to make compiler/TS a production dependency of compiler-cli
@@ -25,31 +27,38 @@ function readPackage(pkg, context) {
pkg.dependencies = { pkg.dependencies = {
...pkg.dependencies, ...pkg.dependencies,
'@angular/compiler': 'workspace:*', '@angular/compiler': 'workspace:*',
'typescript': '5.9.3', 'typescript': pkg.devDependencies['typescript'],
}; };
delete pkg.devDependencies['typescript'];
} }
Object.entries(pkg.peerDependencies).forEach(([key, version]) => { for (const [key, version] of Object.entries(pkg.peerDependencies)) {
// Any package that has a peerDependency on rxjs or zone.js, should instead treat the peerDependency as a // Any package that has a peerDependency on rxjs or zone.js, should instead treat the peerDependency as a
// regular dependency. // regular dependency.
if (['rxjs', 'zone.js'].includes(key)) { if (peerDepsToChange.has(key)) {
pkg.dependencies = { pkg.dependencies = {
...pkg.dependencies, ...pkg.dependencies,
[key]: version, [key]: pkg.devDependencies[key] ?? version,
}; };
delete pkg.devDependencies[key];
continue;
} }
// Change all locally generated packages to directly depend on the other local packages, instead // Change all locally generated packages to directly depend on the other local packages, instead
// of expecting them as peerDependencies automatically as we do not auto install peer deps. The // of expecting them as peerDependencies automatically as we do not auto install peer deps. The
// package is also removed from peerDependencies as it was moved over and will just cause errors. // package is also removed from peerDependencies as it was moved over and will just cause errors.
if (localAngularPackages.includes(key) && pkg.version === '0.0.0-PLACEHOLDER') { if (pkg.version === '0.0.0-PLACEHOLDER' && localAngularPackages.has(key)) {
pkg.dependencies = { pkg.dependencies = {
...pkg.dependencies, ...pkg.dependencies,
[key]: 'workspace: *', [key]: 'workspace: *',
}; };
delete pkg.peerDependencies[key]; delete pkg.peerDependencies[key];
} }
}); }
return pkg; return pkg;
} }
+3
View File
@@ -39,6 +39,9 @@
"tslib": "^2.3.0", "tslib": "^2.3.0",
"yargs": "^18.0.0" "yargs": "^18.0.0"
}, },
"devDependencies": {
"typescript": "5.9.3"
},
"peerDependencies": { "peerDependencies": {
"@angular/compiler": "0.0.0-PLACEHOLDER", "@angular/compiler": "0.0.0-PLACEHOLDER",
"typescript": ">=5.9 <6.0" "typescript": ">=5.9 <6.0"
+1 -1
View File
@@ -10,7 +10,7 @@ overrides:
packageExtensionsChecksum: sha256-3L73Fw32UVtE6x5BJxJPBtQtH/mgsr31grNpdhHP1IY= packageExtensionsChecksum: sha256-3L73Fw32UVtE6x5BJxJPBtQtH/mgsr31grNpdhHP1IY=
pnpmfileChecksum: sha256-vPvk/mBsTHwJvR6NXsWAPUB+5p/66ODkNQwJchPTYMM= pnpmfileChecksum: sha256-TYPFsbGgXlr65uhno3A1oHE+n2qqt8R+w/szQ+Wq97s=
patchedDependencies: patchedDependencies:
dagre-d3-es: dagre-d3-es: