aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.36k stars 3.77k forks source link

(aws-cdk-lib): release source maps and files #20561

Open kaizencc opened 2 years ago

kaizencc commented 2 years ago

Describe the feature

See reduce module size RFC and https://github.com/aws/aws-cdk/issues/20320#issuecomment-1140181014.

Submitting a tracking issue for the following feature:

Releasing an additional 2.X.Y-debug package with every release, that will
contain the source maps and source files. In addition to reducing the size of
the aws-cdk-lib package, we want to reduce the volume of artifacts we publish
to npm and other package managers in total. This would be in direct conflict
with that goal by doubling the amount of content that is published on each
release. And, there is currently no demonstrated customer need for a debug
package like this.

Use Case

Today, there's no way to access the typescript source files from the package downloaded from npm. We haven't heard from the community that this is a feature that users want to see, but we haven't been asking either. Please add your +1s and/or comment additional thoughts on this issue.

Proposed Solution

No response

Other Information

No response

Acknowledgements

CDK version used

2.X

Environment details (OS name and version, etc.)

MacOs

kornicameister commented 2 years ago

Does, by any means, this affects cdk in non TS language?

kaizencc commented 2 years ago

Related #20717

Sevi7 commented 2 years ago

This is a really good idea to have this new package and I really like it. However, having the code minified in the original package (aws-cdk-lib) is in my opinion a bad idea because whenever a developer wants to see an error thrown by aws-cdk-lib and follow the stack trace, the code is unreadable. And consumers using aws-cdk-lib produce many errors (most of the time the code does not deploy at the first time) and the need of being switching packages to use aws-cdk-lib-debug could be quite painful.

Also, consumers who need the package minified will be minifying all their dependencies anyway. I think (and there is a lot of information about this on the internet) it is a best practice to not minify the code of a npm package. The code should be minified by the consumers in a prior step to production.

chris-smith-zocdoc commented 1 year ago

Agree with Sevi7 that we preferred the previous distribution of aws-cdk-lib (transpiled non-minified source). The module size was not a problem for us. In its current state, debugging is painful which makes finding and fixing bugs in the cdk more difficult.

sam-goodwin commented 1 year ago

The minified js is a pain as it obfuscates the code making it impossible to debug problems when I run into bugs or when I don't understand why I'm seeing some behavior. Unminified js would be better and I also remember there was a time when the source was also in the package, that was useful too.

The NpM package size doesn't bother me nearly as much as how poorly the code tree shakes. Importing anything from the cdk takes nearly 10s or so. I think the focus should be there instead. Or perhaps even esm support. Iteration speed much more important than set up time.

github-actions[bot] commented 10 months ago

This issue has received a significant amount of attention so we are automatically upgrading its priority. A member of the community will see the re-prioritization and provide an update on the issue.

pinelibg commented 7 months ago

I also want transpiled code to be unminified as the minified package is very difficult to pnpm patch or patch-package for the changes that cannot be covered by Cfn*** escape hatches.

moltar commented 7 months ago

I've been working with CDK since 2020 and I find it truly frustrating with the source maps not being there.

I think this sort of error message and line noise is hostile to the developer experience.

$> tsx test/foo.itest.ts

foo/node_modules/.pnpm/aws-cdk-lib@2.100.0_constructs@10.3.0/node_modules/aws-cdk-lib/aws-ec2/lib/connections.js:1 "use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.Connections=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var peer_1=()=>{var tmp=require("./peer");return peer_1=()=>tmp,tmp};class Connections{constructor(props={}){this._securityGroups=new ReactiveList,this._securityGroupRules=new ReactiveList,this.skip=!1,this.remoteRule=!1;try{jsiiDeprecationWarnings().aws_cdk_lib_aws_ec2_ConnectionsProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,Connections),error}this.connections=this,this._securityGroups.push(...props.securityGroups||[]),this._securityGroupRules.push(...this._securityGroups.asArray()),props.peer&&this._securityGroupRules.push(props.peer),this.defaultPort=props.defaultPort}get securityGroups(){return this._securityGroups.asArray()}addSecurityGroup(...securityGroups){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_ec2_ISecurityGroup(securityGroups)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addSecurityGroup),error}for(const securityGroup of securityGroups)this._securityGroups.push(securityGroup),this._securityGroupRules.push(securityGroup)}allowTo(other,portRange,description){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_ec2_IConnectable(other),jsiiDeprecationWarnings().aws_cdk_lib_aws_ec2_Port(portRange)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.allowTo),error}if(this.skip)return;const remoteRule=this.remoteRule;this._securityGroups.forEachAndForever(securityGroup=>{other.connections._securityGroupRules.forEachAndForever(rule=>{securityGroup.addEgressRule(rule,portRange,description,remoteRule)})}),this.skip=!0,other.connections.remoteRule=!0;try{other.connections.allowFrom(this,portRange,description)}finally{this.skip=!1,other.connections.remoteRule=!1}}allowFrom(other,portRange,description){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_ec2_IConnectable(other),jsiiDeprecationWarnings().aws_cdk_lib_aws_ec2_Port(portRange)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.allowFrom),error}if(this.skip)return;const remoteRule=this.remoteRule;this._securityGroups.forEachAndForever(securityGroup=>{other.connections._securityGroupRules.forEachAndForever(rule=>{securityGroup.addIngressRule(rule,portRange,description,remoteRule)})}),this.skip=!0,other.connections.remoteRule=!0;try{other.connections.allowTo(this,portRange,description)}finally{this.skip=!1,other.connections.remoteRule=!1}}allowInternally(portRange,description){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_ec2_Port(portRange)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.allowInternally),error}this._securityGroups.forEachAndForever(securityGroup=>{this._securityGroupRules.forEachAndForever(rule=>{securityGroup.addIngressRule(rule,portRange,description),securityGroup.addEgressRule(rule,portRange,description)})})}allowToAnyIpv4(portRange,description){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_ec2_Port(portRange)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.allowToAnyIpv4),error}this.allowTo(peer_1().Peer.anyIpv4(),portRange,description)}allowFromAnyIpv4(portRange,description){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_ec2_Port(portRange)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.allowFromAnyIpv4),error}this.allowFrom(peer_1().Peer.anyIpv4(),portRange,description)}allowDefaultPortFrom(other,description){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_ec2_IConnectable(other)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.allowDefaultPortFrom),error}if(!this.defaultPort)throw new Error("Cannot call allowDefaultPortFrom(): this resource has no default port");this.allowFrom(other,this.defaultPort,description)}allowDefaultPortInternally(description){if(!this.defaultPort)throw new Error("Cannot call allowDefaultPortInternally(): this resource has no default port");this.allowInternally(this.defaultPort,description)}allowDefaultPortFromAnyIpv4(description){if(!this.defaultPort)throw new Error("Cannot call allowDefaultPortFromAnyIpv4(): this resource has no default port");this.allowFromAnyIpv4(this.defaultPort,description)}allowToDefaultPort(other,description){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_ec2_IConnectable(other)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.allowToDefaultPort),error}if(other.connections.defaultPort===void 0)throw new Error("Cannot call allowToDefaultPort(): other resource has no default port");this.allowTo(other,other.connections.defaultPort,description)}allowDefaultPortTo(other,description){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_ec2_IConnectable(other)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.allowDefaultPortTo),error}if(!this.defaultPort)throw new Error("Cannot call allowDefaultPortTo(): this resource has no default port");this.allowTo(other,this.defaultPort,description)}}exports.Connections=Connections,_a=JSII_RTTI_SYMBOL_1,Connections[_a]={fqn:"aws-cdk-lib.aws_ec2.Connections",version:"2.100.0"};class ReactiveList{constructor(){this.elements=new Array,this.listeners=new Array}push(...xs){this.elements.push(...xs);for(const listener of this.listeners)for(const x of xs)listener(x)}forEachAndForever(listener){for(const element of this.elements)listener(element);this.listeners.push(listener)}asArray(){return this.elements.slice()}get length(){return this.elements.length}} ^

Error: Cannot call allowDefaultPortTo(): this resource has no default port at Connections.allowDefaultPortTo (foo/node_modules/.pnpm/aws-cdk-lib@2.100.0_constructs@10.3.0/node_modules/aws-cdk-lib/aws-ec2/lib/connections.js:1:5414) at EfsTestCase (foo/packages/bar/test/espocrm.itest.ts:164:25) at assert (foo/packages/bar/test/espocrm.itest.ts:190:5) at Object. (foo/packages/bar/test/espocrm.itest.ts:200:2) at Module._compile (node:internal/modules/cjs/loader:1159:14) at Object.j (foo/node_modules/.pnpm/tsx@3.14.0/node_modules/tsx/dist/cjs/index.cjs:1:1197) at Module.load (node:internal/modules/cjs/loader:1037:32) at Module._load (node:internal/modules/cjs/loader:878:12) at ModuleWrap. (node:internal/modules/esm/translators:169:29) at ModuleJob.run (node:internal/modules/esm/module_job:193:25)

Node.js v18.12.1

Makeshift commented 5 months ago

As someone who is currently 40 tabs deep into trying to work out why CDK isn't rendering how I expect it to, I would really appreciate un-minified code or sourcemaps. Debugging what's going on under my code is very unpleasant at the moment.

ThePlenkov commented 2 months ago

I would be very helpful is cdk is backed by sourcemaps. Debugging would be much easier.