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

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

Open
vspdi opened this issue Apr 14, 2021 · 2 comments
Open

Comments

@vspdi
Copy link

vspdi commented Apr 14, 2021

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:

  • Introduce two new optinal files: tsconfig.lambdas.json and tsconfig.cdk.json (or any other names to distinguish)
  • If those files exist, the project info picks them up so it can be later merged into the default default config file before beeing generated

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
Copy link

ob-ivan commented Mar 17, 2022

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
Copy link
Owner

hupe1980 commented Apr 4, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants