Skip to content

Commit 1258bd5

Browse files
committed
build: dependencies duplicated when deploying snapshots
We were adding a `resolutions` field to the package.json of the docs site when deploying it from the main repo to try and control the version that is installed. This appears to be causing an issue where Yarn duplicates the dependencies which in turn causes Webpack to bundle them once for the main site and another for the lazy-loaded chunks with the examples. These changes resolve the issue by not adding the `resolutions` field. For reference, currently the docs package depends on `@angular/[email protected]+sha-7d87068-with-local-changes` whereas the docs site depends on `@angular/cdk@file://path/to/repo/dist/releases/cdk`. Fixes #24992.
1 parent 7d87068 commit 1258bd5

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

scripts/docs-deploy/install-built-packages.mts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,13 @@ import {getPackageJsonOfProject} from './utils.mjs';
77
export async function installBuiltPackagesInRepo(repoPath: string, builtPackages: BuiltPackage[]) {
88
const {parsed: packageJson, path: packageJsonPath} = await getPackageJsonOfProject(repoPath);
99

10-
// We will use Yarn resolutions to install the built packages.
11-
if (packageJson.resolutions === undefined) {
12-
packageJson.resolutions = {};
13-
}
14-
1510
for (const builtPackage of builtPackages) {
1611
const pkgName = builtPackage.name;
1712
const destinationUrl = url.pathToFileURL(builtPackage.outputPath);
1813

19-
// Add resolutions for each package in the format "**/{PACKAGE}" so that all
20-
// nested versions of that specific package will have the same version.
21-
packageJson.resolutions[`**/${pkgName}`] = destinationUrl;
22-
23-
// Since the resolutions only control the version of all nested installs, we also need
24-
// to explicitly set the version for the package listed in the project "package.json".
25-
// e.g. the resolution above ensures transitive installs of `@angular/cdk` are updated,
26-
// while the `dependencies` field overrides the workspace install of `@angular/cdk`.
14+
// Override the dependencies to point to the local files instead of the version on npm.
15+
// Note that we don't want to change the `resolutions` to point to the same files, because it
16+
// can cause duplicated dependencies (see #24992).
2717
packageJson.dependencies[pkgName] = destinationUrl;
2818

2919
// In case this dependency was previously a dev dependency, just remove it because we

0 commit comments

Comments
 (0)