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(core): embedded export for cfn-parse #19773

Merged
merged 7 commits into from
Apr 7, 2022
Merged

chore(core): embedded export for cfn-parse #19773

merged 7 commits into from
Apr 7, 2022

Conversation

kaizencc
Copy link
Contributor

@kaizencc kaizencc commented Apr 5, 2022

This PR moves cfn-parse.ts under a folder within @aws-cdk/core/lib, where it is "secretly" exported. You can access the API of cfn-parse by importing import * as cfn_parse from '@aws-cdk/core/lib/cfn-parse';.

The motivation behind this change is to stabilize the code generated by cfn2ts. cfn2ts imports cfn_parse but until now, this was not possible in v2 since aws-cdk-lib is export-restricted. This change should allow cdk v2 users the ability to generate L1 code via cfn2ts.

Closes #18037.


All Submissions:

Adding new Unconventional Dependencies:

  • This PR adds new unconventional dependencies following the process described here

New Features

  • Have you added the new feature to an integration test?
    • Did you use cdk-integ to deploy the infrastructure and generate the snapshot (i.e. cdk-integ without --dry-run)?

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

@gitpod-io
Copy link

gitpod-io bot commented Apr 5, 2022

@github-actions github-actions bot added effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p1 labels Apr 5, 2022
@aws-cdk-automation aws-cdk-automation requested a review from a team April 5, 2022 21:55
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Apr 5, 2022
Copy link
Contributor

@rix0rrr rix0rrr left a comment

Choose a reason for hiding this comment

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

Excellent, thanks! Can you drop in a cfn-parse.ts at the old location as well which re-exports the new cfn-parse.ts ?

That's so that old imports at the old location still work.

Copy link
Contributor

@rix0rrr rix0rrr left a comment

Choose a reason for hiding this comment

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

Also, maybe not name the internal helper folder cfn-parse, but something like internal-helpers or something. Then we have an obvious point if we ever need to add more stuff like this.

And doesn't the package.json need to be updated as well?

Copy link
Contributor Author

@kaizencc kaizencc left a comment

Choose a reason for hiding this comment

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

Currently this is targeting master. But I think this is a breaking change to core since we are restricting deep imports there with the package.json changes. So should we target v2-main instead? Or am I missing something.

// explicitly import the cfn-parse.ts file from @core, which is not part of the public API of the module
this.code.line(`import * as ${CFN_PARSE} from '${coreImport}/${coreImport === '.' ? '' : 'lib/'}cfn-parse';`);
// import cfn-parse from an embedded folder inside @core, since it is not part of the public API of the module
this.code.line(`import * as ${CFN_PARSE} from '${coreImport}/${coreImport === '.' ? '' : 'lib/'}helpers-internal';`);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here's my understanding, please correct me if I'm off-base. The old import of @aws-cdk/core/lib/cfn-parse will work for internal cdk modules. They will not work for external users of cfn2ts because I am not exporting it out of package.json. So this does need to change to @aws-cdk/core/lib/helpers-internal.

"./package.json": "./package.json",
"./.jsii": "./.jsii",
"./.warnings.jsii.js": "./.warnings.jsii.js",
"./lib/helpers-internal": "./lib/helpers-internal/index.js"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

named helpers-internal because that is what it is in pipelines

@kaizencc kaizencc requested a review from rix0rrr April 6, 2022 17:00
@mergify
Copy link
Contributor

mergify bot commented Apr 7, 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: d71a02b
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@mergify mergify bot merged commit f82d96b into master Apr 7, 2022
@mergify mergify bot deleted the conroy/cfn-parse branch April 7, 2022 08:53
@mergify
Copy link
Contributor

mergify bot commented Apr 7, 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 bot pushed a commit that referenced this pull request Apr 7, 2022
This should have been a part of #19773. Ensures that old imports of `@aws-cdk/core/lib/cfn-parse` still work, so that it is not a breaking change. 

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)?
	* [ ] Did you use `cdk-integ` to deploy the infrastructure and generate the snapshot (i.e. `cdk-integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
otaviomacedo pushed a commit that referenced this pull request Apr 11, 2022
This should have been a part of #19773. Ensures that old imports of `@aws-cdk/core/lib/cfn-parse` still work, so that it is not a breaking change. 

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)?
	* [ ] Did you use `cdk-integ` to deploy the infrastructure and generate the snapshot (i.e. `cdk-integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
StevePotter pushed a commit to StevePotter/aws-cdk that referenced this pull request Apr 27, 2022
This PR moves `cfn-parse.ts` under a folder within `@aws-cdk/core/lib`, where it is "secretly" exported. You can access the API of `cfn-parse` by importing `import * as cfn_parse from '@aws-cdk/core/lib/cfn-parse';`.

The motivation behind this change is to stabilize the code generated by `cfn2ts`. `cfn2ts` imports `cfn_parse` but until now, this was not possible in v2 since `aws-cdk-lib` is export-restricted. This change should allow cdk v2 users the ability to generate L1 code via `cfn2ts`.

Closes aws#18037. 

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)?
	* [ ] Did you use `cdk-integ` to deploy the infrastructure and generate the snapshot (i.e. `cdk-integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
StevePotter pushed a commit to StevePotter/aws-cdk that referenced this pull request Apr 27, 2022
This should have been a part of aws#19773. Ensures that old imports of `@aws-cdk/core/lib/cfn-parse` still work, so that it is not a breaking change. 

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)?
	* [ ] Did you use `cdk-integ` to deploy the infrastructure and generate the snapshot (i.e. `cdk-integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
mergify bot pushed a commit that referenced this pull request May 3, 2022
Due to an oversight, embedded exports from core were not exported in cdk v2. This is necessary for #19773 to work. The export logic added in that PR would not get executed for `core`, but it is supposed to.

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
wphilipw pushed a commit to wphilipw/aws-cdk that referenced this pull request May 23, 2022
Due to an oversight, embedded exports from core were not exported in cdk v2. This is necessary for aws#19773 to work. The export logic added in that PR would not get executed for `core`, but it is supposed to.

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*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. effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(cfn2ts, aws-cdk-lib): cfn2ts not compatible with aws-cdk-lib
3 participants