Skip to content

build(docs-infra): fix version mismatch of local built packages - #55282

Closed
devversion wants to merge 3 commits into
angular:mainfrom
devversion:filter-transitive-deps
Closed

devversion wants to merge 3 commits into
angular:mainfrom
devversion:filter-transitive-deps

Conversation

@devversion

Copy link
Copy Markdown
Member

There is quite some trickery going on with the adev build related to
local packages:

  • Adev builds using npm packages from /node_modules
  • At runtime, we are adding HEAD packages for e.g. @angular/core to
    the bundles.
  • At build time, the CLI, or Angular devkit may accidentally resolve to
    @angular/core from /node_modules/— which is the core version from
    npm, transitively installed via @angular/docs.

This causes a version mismatch, leading to issues like:

This commit attempts to fix this by:

  • Linking all Angular HEAD packages into adev/node_modules. The
    current logic attempts to link into /node_modules, but this does not
    override existing @angular/core!
  • Linking all direct external NPM packages, like
    @angular_devkit/build-angular into adev/node_modules without their
    transitive deps. This allows proper resolution of e.g. compiler as
    node looks in adev/node_modules first, and falls back for the rest
    to the execroot node_modules, or symlink target destination (if
    preserveSymlinks=false).

Note: This is still not 100% ideal because a direct external NPM
dependency may have a transitive dependency that has another transitive
dependency on @angular/core. In those cases, the may be a conflict
that is not resolvable until we switch to a Bazel toolchain with better
first party resolution support.

Related to: #54858 (not closing because a real long-term sustainable fix is a better toolchain)

@angular-robot angular-robot Bot added the area: build & ci Related the build and CI infrastructure of the project label Apr 10, 2024
@ngbot ngbot Bot added this to the Backlog milestone Apr 10, 2024
@devversion
devversion force-pushed the filter-transitive-deps branch from 30754ef to 4607e73 Compare April 10, 2024 15:09
There is quite some trickery going on with the adev build related to
local packages:

- Adev builds using npm packages from `/node_modules`
- At runtime, we are adding `HEAD` packages for e.g. `@angular/core` to
  the bundles.
- At build time, the CLI, or Angular devkit may accidentally resolve to
  `@angular/core` from `/node_modules/`— which is the core version from
  npm, transitively installed via `@angular/docs`.

This causes a version mismatch, leading to issues like:

- CLI throwing because of a mismatch. angular#54858 (comment)
- Compiler changes not being picked up. angular#54858 (comment)

This commit attempts to fix this by:

- Linking all Angular `HEAD` packages into `adev/node_modules`. The
  current logic attempts to link into `/node_modules`, but this does not
  override existing `@angular/core`!
- Linking all direct external NPM packages, like
  `@angular_devkit/build-angular` into `adev/node_modules` without their
  transitive deps. This allows proper resolution of e.g. compiler as
  node looks in `adev/node_modules` first, and falls back for the rest
  to the execroot `node_modules`, or symlink target destination (if
  `preserveSymlinks=false`).

Note: This is still not 100% ideal because a direct external NPM
dependency may have a transitive dependency that has another transitive
dependency on `@angular/core`. In those cases, the may be a conflict
that is not resolvable until we switch to a Bazel toolchain with better
first party resolution support.
Similar to `aio`, disables caching inside Bazel as it would be discarded
anyway and is likely a source of slowness then.
Similar to what we did for aio, we should not clear the architect CLI
output in Bazel. This messes up with the output and makes debugging
hard.
@devversion
devversion force-pushed the filter-transitive-deps branch from 4607e73 to 72b8373 Compare April 10, 2024 15:24
@devversion devversion added action: review The PR is still awaiting reviews from at least one requested reviewer area: adev adev: preview PullApprove: disable target: patch This PR is targeted for the next patch release labels Apr 10, 2024
@devversion
devversion marked this pull request as ready for review April 10, 2024 15:24

@josephperrott josephperrott left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@devversion devversion added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Apr 10, 2024
@github-actions

Copy link
Copy Markdown

Deployed adev-preview for 72b8373 to: https://ng-dev-previews-fw--pr-angular-angular-55282-adev-prev-cre620xx.web.app

Note: As new commits are pushed to this pull request, this link is updated after the preview is rebuilt.

@atscott

atscott commented Apr 10, 2024

Copy link
Copy Markdown
Contributor

This PR was merged into the repository by commit 28b3c92.

@atscott atscott closed this in f828984 Apr 10, 2024
atscott pushed a commit that referenced this pull request Apr 10, 2024
Similar to `aio`, disables caching inside Bazel as it would be discarded
anyway and is likely a source of slowness then.

PR Close #55282
atscott pushed a commit that referenced this pull request Apr 10, 2024
Similar to what we did for aio, we should not clear the architect CLI
output in Bazel. This messes up with the output and makes debugging
hard.

PR Close #55282
atscott pushed a commit that referenced this pull request Apr 10, 2024
There is quite some trickery going on with the adev build related to
local packages:

- Adev builds using npm packages from `/node_modules`
- At runtime, we are adding `HEAD` packages for e.g. `@angular/core` to
  the bundles.
- At build time, the CLI, or Angular devkit may accidentally resolve to
  `@angular/core` from `/node_modules/`— which is the core version from
  npm, transitively installed via `@angular/docs`.

This causes a version mismatch, leading to issues like:

- CLI throwing because of a mismatch. #54858 (comment)
- Compiler changes not being picked up. #54858 (comment)

This commit attempts to fix this by:

- Linking all Angular `HEAD` packages into `adev/node_modules`. The
  current logic attempts to link into `/node_modules`, but this does not
  override existing `@angular/core`!
- Linking all direct external NPM packages, like
  `@angular_devkit/build-angular` into `adev/node_modules` without their
  transitive deps. This allows proper resolution of e.g. compiler as
  node looks in `adev/node_modules` first, and falls back for the rest
  to the execroot `node_modules`, or symlink target destination (if
  `preserveSymlinks=false`).

Note: This is still not 100% ideal because a direct external NPM
dependency may have a transitive dependency that has another transitive
dependency on `@angular/core`. In those cases, the may be a conflict
that is not resolvable until we switch to a Bazel toolchain with better
first party resolution support.

PR Close #55282
atscott pushed a commit that referenced this pull request Apr 10, 2024
Similar to `aio`, disables caching inside Bazel as it would be discarded
anyway and is likely a source of slowness then.

PR Close #55282
atscott pushed a commit that referenced this pull request Apr 10, 2024
Similar to what we did for aio, we should not clear the architect CLI
output in Bazel. This messes up with the output and makes debugging
hard.

PR Close #55282
iteriani pushed a commit to iteriani/angular that referenced this pull request Apr 11, 2024
…lar#55282)

There is quite some trickery going on with the adev build related to
local packages:

- Adev builds using npm packages from `/node_modules`
- At runtime, we are adding `HEAD` packages for e.g. `@angular/core` to
  the bundles.
- At build time, the CLI, or Angular devkit may accidentally resolve to
  `@angular/core` from `/node_modules/`— which is the core version from
  npm, transitively installed via `@angular/docs`.

This causes a version mismatch, leading to issues like:

- CLI throwing because of a mismatch. angular#54858 (comment)
- Compiler changes not being picked up. angular#54858 (comment)

This commit attempts to fix this by:

- Linking all Angular `HEAD` packages into `adev/node_modules`. The
  current logic attempts to link into `/node_modules`, but this does not
  override existing `@angular/core`!
- Linking all direct external NPM packages, like
  `@angular_devkit/build-angular` into `adev/node_modules` without their
  transitive deps. This allows proper resolution of e.g. compiler as
  node looks in `adev/node_modules` first, and falls back for the rest
  to the execroot `node_modules`, or symlink target destination (if
  `preserveSymlinks=false`).

Note: This is still not 100% ideal because a direct external NPM
dependency may have a transitive dependency that has another transitive
dependency on `@angular/core`. In those cases, the may be a conflict
that is not resolvable until we switch to a Bazel toolchain with better
first party resolution support.

PR Close angular#55282
iteriani pushed a commit to iteriani/angular that referenced this pull request Apr 11, 2024
Similar to `aio`, disables caching inside Bazel as it would be discarded
anyway and is likely a source of slowness then.

PR Close angular#55282
iteriani pushed a commit to iteriani/angular that referenced this pull request Apr 11, 2024
…ar#55282)

Similar to what we did for aio, we should not clear the architect CLI
output in Bazel. This messes up with the output and makes debugging
hard.

PR Close angular#55282
@JeanMeche

Copy link
Copy Markdown
Member

It looks like this change introduced a regression #55298

@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators May 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker adev: preview area: build & ci Related the build and CI infrastructure of the project PullApprove: disable target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants