cdk: do not minify JS in NPM distribution
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the feature
I'd like to see un-minified JS files in the NPM distribution.
### Use Case
It's impossible to debug any traces because the entire JS file is in one line.
### Proposed Solution
Do not minify the JS distribution. I don't think saving spaces and new lines lead to that much savings, considering the tar balls are gzip'ed.
### Other Information
This is what the contents of one file look like:
```js
"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.Lazy=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),debug_1=require("./debug"),stack_trace_1=require("./stack-trace"),token_1=require("./token");class Lazy{static stringValue(producer,options={}){return token_1.Token.asString(new LazyString(producer,!1),options)}static string(producer,options={}){try{jsiiDeprecationWarnings.aws_cdk_lib_IStableStringProducer(producer),jsiiDeprecationWarnings.aws_cdk_lib_LazyStringValueOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.string),error}return token_1.Token.asString(new LazyString(producer,!0),options)}static uncachedString(producer,options={}){try{jsiiDeprecationWarnings.aws_cdk_lib_IStringProducer(producer),jsiiDeprecationWarnings.aws_cdk_lib_LazyStringValueOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.uncachedString),error}return token_1.Token.asString(new LazyString(producer,!1),options)}static numberValue(producer){return token_1.Token.asNumber(new LazyNumber(producer,!1))}static number(producer){try{jsiiDeprecationWarnings.aws_cdk_lib_IStableNumberProducer(producer)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.number),error}return token_1.Token.asNumber(new LazyNumber(producer,!0))}static uncachedNumber(producer){try{jsiiDeprecationWarnings.aws_cdk_lib_INumberProducer(producer)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.uncachedNumber),error}return token_1.Token.asNumber(new LazyNumber(producer,!1))}static listValue(producer,options={}){return token_1.Token.asList(new LazyList(producer,!1,options),options)}static uncachedList(producer,options={}){try{jsiiDeprecationWarnings.aws_cdk_lib_IListProducer(producer),jsiiDeprecationWarnings.aws_cdk_lib_LazyListValueOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.uncachedList),error}return token_1.Token.asList(new LazyList(producer,!1,options),options)}static list(producer,options={}){try{jsiiDeprecationWarnings.aws_cdk_lib_IStableListProducer(producer),jsiiDeprecationWarnings.aws_cdk_lib_LazyListValueOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.list),error}return token_1.Token.asList(new LazyList(producer,!0,options),options)}static anyValue(producer,options={}){return new LazyAny(producer,!1,options)}static any(producer,options={}){try{jsiiDeprecationWarnings.aws_cdk_lib_IStableAnyProducer(producer),jsiiDeprecationWarnings.aws_cdk_lib_LazyAnyValueOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.any),error}return new LazyAny(producer,!0,options)}static uncachedAny(producer,options={}){try{jsiiDeprecationWarnings.aws_cdk_lib_IAnyProducer(producer),jsiiDeprecationWarnings.aws_cdk_lib_LazyAnyValueOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.uncachedAny),error}return new LazyAny(producer,!1,options)}constructor(){}}exports.Lazy=Lazy,_a=JSII_RTTI_SYMBOL_1,Lazy[_a]={fqn:"aws-cdk-lib.Lazy",version:"2.91.0"};class LazyBase{constructor(producer,cache){this.producer=producer,this.cache=cache,this.creationStack=(0,debug_1.debugModeEnabled)()?(0,stack_trace_1.captureStackTrace)(this.constructor):[`Execute again with ${debug_1.CDK_DEBUG}=true to capture stack traces`]}resolve(context){return this.cache?this._cached??(this._cached=this.producer.produce(context)):this.producer.produce(context)}toString(){return token_1.Token.asString(this)}toJSON(){return""}}class LazyString extends LazyBase{}class LazyNumber extends LazyBase{}class LazyList extends LazyBase{constructor(producer,cache,options={}){super(producer,cache),this.options=options}resolve(context){const resolved=super.resolve(context);if(!(resolved?.length===0&&this.options.omitEmpty))return resolved}}class LazyAny extends LazyBase{constructor(producer,cache,options={}){super(producer,cache),this.options=options}resolve(context){const resolved=super.resolve(context);if(!(Array.isArray(resolved)&&resolved.length===0&&this.options.omitEmptyArray))return resolved}}
```
### Acknowledgements
- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
### CDK version used
2.91.0
### Environment details (OS name and version, etc.)
macOS
Contributor guide
Research direction
Start by tracing the TypeScript build and NPM packaging configuration that produces the distributed JavaScript files. Inspect a generated package tarball and confirm that its JavaScript files retain readable formatting rather than being minified; verify that the package contents and runtime behavior remain unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- build-system, developer-experience
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100