-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Conversation
There was a problem hiding this 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.
There was a problem hiding this 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?
There was a problem hiding this 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';`); |
There was a problem hiding this comment.
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
.
packages/@aws-cdk/core/package.json
Outdated
"./package.json": "./package.json", | ||
"./.jsii": "./.jsii", | ||
"./.warnings.jsii.js": "./.warnings.jsii.js", | ||
"./lib/helpers-internal": "./lib/helpers-internal/index.js" |
There was a problem hiding this comment.
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
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 CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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). |
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*
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*
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*
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*
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*
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*
This PR moves
cfn-parse.ts
under a folder within@aws-cdk/core/lib
, where it is "secretly" exported. You can access the API ofcfn-parse
by importingimport * as cfn_parse from '@aws-cdk/core/lib/cfn-parse';
.The motivation behind this change is to stabilize the code generated by
cfn2ts
.cfn2ts
importscfn_parse
but until now, this was not possible in v2 sinceaws-cdk-lib
is export-restricted. This change should allow cdk v2 users the ability to generate L1 code viacfn2ts
.Closes #18037.
All Submissions:
Adding new Unconventional Dependencies:
New Features
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