hupe1980 / cdkdx

Zero-config CLI for aws cdk development
MIT License
38 stars 8 forks source link

Ability to modify default tsconfig.json which is added in /src/lambdas #15

Open vspdi opened 3 years ago

vspdi commented 3 years ago

It would be nice, if the configuration would allow some overwrites to the tsconfig.json which is applied to the lambda bundling. For example, we are trying to use inverisfy.js inside the lambdas for dependency injection. For that to work, we would need to set the following properties:

{
  "compilerOptions": {
    "emitDecoratorMetaData": true,
    "experimentalDecorators": true
  }
}

I would suggest, the following changes:

If you like lets start a small discussion over this topic, potential problems or improvements. I would be happy to contribute to this awesome project by implementing those ideas.

Greetings Viktor

ob-ivan commented 2 years ago

I have a similar problem with the default tsconfig.json.

In our project we use npm workspaces with hoisting, which means that all dependencies show up in the root node_modules directory, in addition to per-workspace node_modules directories that contain alternative versions of dependencies.

I have two workspaces, A and B, and workspace A uses cdkdx, while workspace B uses Storybook.

Among the dependencies of Storybook there is @types/overlayscrollbars, which uses NodeListOf<TNode> from the typescript's dom library. That dependency is added to the root node_modules directory.

However, when cdkdx build is executed in workspace A, the created tsconfig.json files defines the compiler libs like this:

    "lib": [
      "es2018"
    ],

So it doesn't include the dom library.

Since all typings from the root node_modules/@types are considered by the compiler, the compilation in workspace A fails:

../../../node_modules/@types/overlayscrollbars/index.d.ts:348:19 - error TS2304: Cannot find name 'NodeListOf'.

348         elements: NodeListOf<Element> | ReadonlyArray<Element> | JQuery,

I wish there was a way to redefine lib as ["es2018", "dom"] in tsconfig.json.

PS. As a temporary remedy, I can unignore tsconfig.json, modify it the way I want and commit it to the repository. This way I get the options I need, but on the other hand I don't get any updates to tsconfig.json from the future versions of cdkdx. This looks like a reasonable tradeoff to me, as I have to pin cdkdx to version 1.3.0 at the moment anyway. But that's a story for another day.

hupe1980 commented 2 years ago

@ob-ivan Have you tried this: https://github.com/hupe1980/cdkdx/tree/master/packages/cdkdx#extending-typescript-config