Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ngcc): cope with packages following APF v14+ #45833

Closed
wants to merge 4 commits into from

Conversation

gkalpak
Copy link
Member

@gkalpak gkalpak commented Apr 30, 2022

In PR #45405, the Angular Package Format (APF) was updated so that secondary entry-points (such as @angular/common/http) do not have their own package.json file, as they used to. Instead, the paths to their various formats and types are exposed via the primary package.json file's exports property. As an example, see the v13 @angular/common/http/package.json and compare it with the v14 @angular/common/package.json > exports.

Previously, ngcc was not able to analyze such v14+ entry-points and would instead error as it considered such entry-points missing.

This commit addresses the issue by detecting this situation and synthesizing a package.json file for the secondary entry-points based on the exports property of the primary package.json file. This data is only used by ngcc in order to determine that the entry-point does not need further processing, since it is already in Ivy format.

FYI, I have tested this on ngcc-validation and it makes CI green: CI run

@gkalpak gkalpak added type: bug/fix state: WIP comp: ngcc target: minor This PR is targeted for the next minor release labels Apr 30, 2022
@ngbot ngbot bot modified the milestone: Backlog Apr 30, 2022
@mary-poppins
Copy link

You can preview cda0f67 at https://pr45833-cda0f67.ngbuilds.io/.

@gkalpak gkalpak changed the title WIP - fix(ngcc): cope with packages following APF v14+ fix(ngcc): cope with packages following APF v14+ Apr 30, 2022
@mary-poppins
Copy link

You can preview c92207d at https://pr45833-c92207d.ngbuilds.io/.

@mary-poppins
Copy link

You can preview 330569e at https://pr45833-330569e.ngbuilds.io/.

@mary-poppins
Copy link

You can preview 7c75b0b at https://pr45833-7c75b0b.ngbuilds.io/.

gkalpak added a commit to gkalpak/ngcc-validation that referenced this pull request May 3, 2022
gkalpak added a commit to gkalpak/ngcc-validation that referenced this pull request May 3, 2022
@mary-poppins
Copy link

You can preview 1ab8b94 at https://pr45833-1ab8b94.ngbuilds.io/.

@mary-poppins
Copy link

You can preview d4c3a78 at https://pr45833-d4c3a78.ngbuilds.io/.

gkalpak added a commit to gkalpak/ngcc-validation that referenced this pull request May 3, 2022
@gkalpak gkalpak marked this pull request as ready for review May 3, 2022 20:08
@gkalpak gkalpak added action: review The PR is still awaiting reviews from at least one requested reviewer and removed state: WIP labels May 3, 2022
@JoostK JoostK self-requested a review May 3, 2022 20:23
Copy link
Member

@JoostK JoostK left a comment

Choose a reason for hiding this comment

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

Nice work!

packages/compiler-cli/ngcc/src/utils.ts Outdated Show resolved Hide resolved
packages/compiler-cli/ngcc/test/utils_spec.ts Outdated Show resolved Hide resolved
Remove some unused dependencies from `ngcc` source code.
Move the `loadPackageJson()` helper (and associated generic types, such
as `JsonObject`) from `packages/entry_point.ts` to `utils.ts` and also
rename it to `loadJson()`. This way, they can be used in other places in
future commits, without introducing cyclical dependencies.
In PR angular#45405, the Angular Package Format (APF) was updated so that
secondary entry-points (such as `@angular/common/http`) do not have
their own `package.json` file, as they used to. Instead, the paths to
their various formats and types are exposed via the primary
`package.json` file's `exports` property. As an example, see the v13
[@angular/common/http/package.json][1] and compare it with the v14
[@angular/common/package.json > exports][2].

Previously, `ngcc` was not able to analyze such v14+ entry-points and
would instead error as it considered such entry-points missing.

This commit addresses the issue by detecting this situation and
synthesizing a `package.json` file for the secondary entry-points based
on the `exports` property of the primary `package.json` file. This data
is only used by `ngcc` in order to determine that the entry-point does
not need further processing, since it is already in Ivy format.

[1]: https://unpkg.com/browse/@angular/common@13.3.5/http/package.json
[2]: https://unpkg.com/browse/@angular/common@14.0.0-next.15/package.json
@gkalpak gkalpak requested a review from JoostK May 5, 2022 20:01
Copy link
Member

@JoostK JoostK left a comment

Choose a reason for hiding this comment

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

LGTM

@JoostK JoostK added target: rc This PR is targeted for the next release-candidate and removed target: minor This PR is targeted for the next minor release labels May 5, 2022
@mary-poppins
Copy link

You can preview 3686a06 at https://pr45833-3686a06.ngbuilds.io/.

@gkalpak gkalpak 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 May 6, 2022
@AndrewKushnir
Copy link
Contributor

This PR was merged into the repository by commit d4e949f.

AndrewKushnir pushed a commit that referenced this pull request May 6, 2022
…ts` (#45833)

Move the `loadPackageJson()` helper (and associated generic types, such
as `JsonObject`) from `packages/entry_point.ts` to `utils.ts` and also
rename it to `loadJson()`. This way, they can be used in other places in
future commits, without introducing cyclical dependencies.

PR Close #45833
AndrewKushnir pushed a commit that referenced this pull request May 6, 2022
In PR #45405, the Angular Package Format (APF) was updated so that
secondary entry-points (such as `@angular/common/http`) do not have
their own `package.json` file, as they used to. Instead, the paths to
their various formats and types are exposed via the primary
`package.json` file's `exports` property. As an example, see the v13
[@angular/common/http/package.json][1] and compare it with the v14
[@angular/common/package.json > exports][2].

Previously, `ngcc` was not able to analyze such v14+ entry-points and
would instead error as it considered such entry-points missing.

This commit addresses the issue by detecting this situation and
synthesizing a `package.json` file for the secondary entry-points based
on the `exports` property of the primary `package.json` file. This data
is only used by `ngcc` in order to determine that the entry-point does
not need further processing, since it is already in Ivy format.

[1]: https://unpkg.com/browse/@angular/common@13.3.5/http/package.json
[2]: https://unpkg.com/browse/@angular/common@14.0.0-next.15/package.json

PR Close #45833
AndrewKushnir pushed a commit that referenced this pull request May 6, 2022
Remove some unused dependencies from `ngcc` source code.

PR Close #45833
AndrewKushnir pushed a commit that referenced this pull request May 6, 2022
…ts` (#45833)

Move the `loadPackageJson()` helper (and associated generic types, such
as `JsonObject`) from `packages/entry_point.ts` to `utils.ts` and also
rename it to `loadJson()`. This way, they can be used in other places in
future commits, without introducing cyclical dependencies.

PR Close #45833
AndrewKushnir pushed a commit that referenced this pull request May 6, 2022
In PR #45405, the Angular Package Format (APF) was updated so that
secondary entry-points (such as `@angular/common/http`) do not have
their own `package.json` file, as they used to. Instead, the paths to
their various formats and types are exposed via the primary
`package.json` file's `exports` property. As an example, see the v13
[@angular/common/http/package.json][1] and compare it with the v14
[@angular/common/package.json > exports][2].

Previously, `ngcc` was not able to analyze such v14+ entry-points and
would instead error as it considered such entry-points missing.

This commit addresses the issue by detecting this situation and
synthesizing a `package.json` file for the secondary entry-points based
on the `exports` property of the primary `package.json` file. This data
is only used by `ngcc` in order to determine that the entry-point does
not need further processing, since it is already in Ivy format.

[1]: https://unpkg.com/browse/@angular/common@13.3.5/http/package.json
[2]: https://unpkg.com/browse/@angular/common@14.0.0-next.15/package.json

PR Close #45833
@gkalpak gkalpak deleted the fix-ngcc-apf-v14 branch May 6, 2022 17:31
@angular-automatic-lock-bot
Copy link

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 Jun 6, 2022
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 target: rc This PR is targeted for the next release-candidate type: bug/fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants