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

chore(cx-api): break circular dependencies #18767

Merged
merged 6 commits into from
Feb 3, 2022
Merged

Conversation

rix0rrr
Copy link
Contributor

@rix0rrr rix0rrr commented Feb 1, 2022

Use the "Declaration Merging" feature from TypeScript, combined
with the "Monkey Patching" feature from JavaScript, to break the
circular dependencies between some of the classes in this library.

These dependency cycles interfere with proper bundling by esbuild.

Use madge to validate that we don't add those cycles back. Madge
validation only happens on the .js files, because those are the only
ones we care about when bundling. Cyclic imports that are only used to
import type information won't actually cause require() cycles at
runtime, since types don't exist in JS.


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

Use the "Declaration Merging" feature from TypeScript, combined
with the "Monkey Patching" feature from JavaScript, to break the
circular dependencies between some of the classes in this library.

These dependency cycles interfere with proper bundling by `esbuild`.

Use `madge` to validate that we don't add those cycles back. Madge
validation only happens on the `.js` files, because those are the only
ones we care about when bundling. Cyclic imports that are only used to
import type information won't actually cause `require()` cycles at
runtime, since types don't exist in JS.
@rix0rrr rix0rrr requested a review from a team February 1, 2022 13:07
@rix0rrr rix0rrr self-assigned this Feb 1, 2022
@gitpod-io
Copy link

gitpod-io bot commented Feb 1, 2022

@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Feb 1, 2022
Copy link
Contributor

@eladb eladb left a comment

Choose a reason for hiding this comment

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

Would be nice to chart a course to deprecate cx-api altogether.

@iliapolo
Copy link
Contributor

iliapolo commented Feb 2, 2022

@rix0rrr Looks like jsii compatibility is unhappy with this...

API elements with incompatible changes:
err  - METHOD @aws-cdk/cx-api.AssetManifestArtifact.fromManifest: has been removed [removed:@aws-cdk/cx-api.AssetManifestArtifact.fromManifest]
err  - METHOD @aws-cdk/cx-api.CloudArtifact.fromManifest: has been removed [removed:@aws-cdk/cx-api.CloudArtifact.fromManifest]
err  - METHOD @aws-cdk/cx-api.CloudFormationStackArtifact.fromManifest: has been removed [removed:@aws-cdk/cx-api.CloudFormationStackArtifact.fromManifest]
err  - METHOD @aws-cdk/cx-api.NestedCloudAssemblyArtifact.fromManifest: has been removed [removed:@aws-cdk/cx-api.NestedCloudAssemblyArtifact.fromManifest]
err  - METHOD @aws-cdk/cx-api.TreeCloudArtifact.fromManifest: has been removed [removed:@aws-cdk/cx-api.TreeCloudArtifact.fromManifest]

@rix0rrr
Copy link
Contributor Author

rix0rrr commented Feb 2, 2022

@rix0rrr Looks like jsii compatibility is unhappy with this...

Sooo... static methods are INHERITED in JavaScript/TypeScript/jsii. How could I forget...

I feel very comfortable not caring about this. How about you?

@iliapolo
Copy link
Contributor

iliapolo commented Feb 2, 2022

I feel very comfortable not caring about this. How about you?

Yeah, I see no reason why anyone would invoke it from the child classes.. (FLW)

@iliapolo
Copy link
Contributor

iliapolo commented Feb 2, 2022

Oh but wait, why does it complain on:

@aws-cdk/cx-api.CloudArtifact.fromManifest

This one should be preserved...

@rix0rrr
Copy link
Contributor Author

rix0rrr commented Feb 2, 2022

Good point, I'll check.

@mergify
Copy link
Contributor

mergify bot commented Feb 3, 2022

Thank you for contributing! Your pull request will be updated from master 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 ec8495a into master Feb 3, 2022
@mergify mergify bot deleted the huijbers/circular-deps branch February 3, 2022 14:23
@mergify
Copy link
Contributor

mergify bot commented Feb 3, 2022

Thank you for contributing! Your pull request will be updated from master 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
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: ecada51
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

kornicameister added a commit to kornicameister/aws-cdk that referenced this pull request Feb 6, 2022
* origin/master: (27 commits)
  chore(eks): deprecate older versions of EKS (aws#18842)
  fix(tooling): update vscode devcontainer image (aws#18455)
  chore: npm-check-updates && yarn upgrade (aws#18832)
  chore(docs): Fix broken md links (aws#18384)
  chore(lambda-layer-awscli): install awscli with pip and requirements.txt (aws#18800)
  fix(aws-appsync): Strip unsupported characters from Lambda DataSource (aws#18765)
  feat(cfnspec): cloudformation spec v55.0.0 (aws#18827)
  docs(cfnspec): update CloudFormation documentation (aws#18826)
  chore(cxapi): plugin context provider limited by cx schema (aws#18709)
  feat(iotevents): add grant method to Input class (aws#18617)
  chore(cx-api): break circular dependencies (aws#18767)
  docs(core): clarify that `addOverride` does not change property casing (aws#18687)
  feat(s3-deployment): deploy data with deploy-time values (aws#18659)
  docs(cfnspec): update CloudFormation documentation (aws#18808)
  feat(cli): `cdk diff` works for Nested Stacks (aws#18207)
  docs(cfnspec): update CloudFormation documentation (aws#18783)
  chore(lambda-layer-awscli): add update mechanism for AWS CLI (aws#18780)
  chore(release): 1.143.0
  feat(fsx): add support for FSx Lustre Persistent_2 deployment type (aws#18626)
  feat(amplify): support performance mode in Branch (aws#18598)
  ...
TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
Use the "Declaration Merging" feature from TypeScript, combined
with the "Monkey Patching" feature from JavaScript, to break the
circular dependencies between some of the classes in this library.

These dependency cycles interfere with proper bundling by `esbuild`.

Use `madge` to validate that we don't add those cycles back. Madge
validation only happens on the `.js` files, because those are the only
ones we care about when bundling. Cyclic imports that are only used to
import type information won't actually cause `require()` cycles at
runtime, since types don't exist in JS.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants