Skip to content

chore: fix yarn upgrade causing dependency incompatibility#33454

Merged
mergify[bot] merged 2 commits intoaws:mainfrom
samson-keung:fix-yarn-upgrade
Feb 15, 2025
Merged

chore: fix yarn upgrade causing dependency incompatibility#33454
mergify[bot] merged 2 commits intoaws:mainfrom
samson-keung:fix-yarn-upgrade

Conversation

@samson-keung
Copy link
Copy Markdown
Contributor

@samson-keung samson-keung commented Feb 14, 2025

Issue # (if applicable)

N/A

The problem was yarn upgrade no longer worked. You can see the auto upgrade PR - #33299 - is having a failed build.

After diving deep into the reason of failure, here are the findings:

I first checked out the branch for #33299, then run the build locally. Here is the error in the build log:

> tsc --build

aws-cdk/node_modules/@types/glob/index.d.ts:29:42 - error TS2694: Namespace '"<path skipped>/aws-cdk/node_modules/minimatch/dist/commonjs/index"' has no exported member 'IOptions'.

29     interface IOptions extends minimatch.IOptions {
                                            ~~~~~~~~

aws-cdk/node_modules/@types/glob/index.d.ts:74:30 - error TS2724: '"<path skipped>/aws-cdk/node_modules/minimatch/dist/commonjs/index"' has no exported member named 'IMinimatch'. Did you mean 'Minimatch'?

74         minimatch: minimatch.IMinimatch;
                                ~~~~~~~~~~

Pay attention to the file paths above. aws-cdk/node_modules/@types/glob is trying to reference a type from aws-cdk/node_modules/minimatch because yarn upgraded to a minimatch version that natively export minimatch types. But @types/glob is not compatible with these new minimatch types, causing the error seen above.

Ideally, @types/glob should specify the @types/minimatch version it works with, but in reality, it has "@types/minimatch": "*", which started pointing to the upgraded aws-cdk/node_modules/minimatch as yarn hoist dependencies into the top level node_modules.

Some references:

Description of changes

Use nohoist for @types/glob and @types/minimatch so that the different places that use these two packages do not conflict with each other at the top level node_modules.

After doing the above, I noticed cdk-build-tools was actually relying on @types/glob but it does not declare the dependency in its package.json. It worked because it pulled the @types/glob at the top level node_modules (which is no longer available with nohoist).

Describe any new or updated permissions being added

None

Description of how you validated changes

Locally built and no error.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added the p2 label Feb 14, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team February 14, 2025 20:19
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Feb 14, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.00%. Comparing base (76848e4) to head (cbd1a7a).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #33454   +/-   ##
=======================================
  Coverage   81.00%   81.00%           
=======================================
  Files         238      238           
  Lines       14271    14271           
  Branches     2492     2492           
=======================================
  Hits        11560    11560           
  Misses       2425     2425           
  Partials      286      286           
Flag Coverage Δ
suite.unit 81.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
packages/aws-cdk 79.92% <ø> (ø)
packages/aws-cdk-lib/core 82.16% <ø> (ø)

@samson-keung samson-keung changed the title chore: <TODO> chore: fix yarn upgrade causing dependency incompatibility Feb 14, 2025
@samson-keung samson-keung marked this pull request as ready for review February 14, 2025 22:03
Copy link
Copy Markdown
Contributor

@godwingrs22 godwingrs22 left a comment

Choose a reason for hiding this comment

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

Great work @samson-keung!. Thanks for the deep dive and for the fix. LGTM

@@ -93,6 +93,8 @@
"nohoist": [
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice. I just came to know about the behaviour of this section. So this makes these listed packages to be present in the individual subpackages (nodemodules within the subpackages) instead of hosting in the root level of the whole projects.

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Feb 14, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: cbd1a7a
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Feb 15, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 0e67605 into aws:main Feb 15, 2025
20 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 15, 2025
@samson-keung samson-keung deleted the fix-yarn-upgrade branch March 11, 2025 21:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

contribution/core This is a PR that came from AWS. p2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants