question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(init-templates/typescript): exclude node_modules

See original GitHub issue

❓ Should node_modules not be excluded from typescript projects in tsconfig?

The Question

I don’t know whether it is intentional or not, however when initializing a Typescript app the node_modules are included into the project and will therefore be type checked and so on. This is because you override the default settings of exclude to "exclude": ["cdk.out"].

Note: without an exclude list, node_modules is excluded by default; as soon as one is added, it’s important to explicitly add node_modules to the list. (Source: Specifying Files)

Regarding the Performance recommendation by the official Typescript team, it is considered a best practice to exclude node_modules. This could easily be achieved by adding it to exclude:

https://github.com/aws/aws-cdk/blob/60875a5d6cd93b7d6f0f9b1b94153f6d1f4766b1/packages/aws-cdk/lib/init-templates/v2/app/typescript/tsconfig.json#L22

{
  // ...
  "exclude": [
    "node_modules",
    "cdk.out"
  ]
}

If you don’t mind I would create a PR myself. 😃

Environment

  • CDK CLI Version: 1.76.0
  • Node.js Version: v12.16.2
  • OS: macOS Catalina
  • Language (Version): ^4.0.2

Other information

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
peterwoodworthcommented, Jun 7, 2021

Hey @bmacher, thank you for working on this! Whenever you are ready feel free to go ahead and create the PR. Integration tests won’t be necessary in this case, as you aren’t changing any actual functionality that should affect any cloudformation output

1reaction
bmachercommented, Dec 16, 2020

Thanks @SomayaB, I will work on that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - What is a tsconfig.json - TypeScript
The tsconfig.json file specifies the root files and the compiler options required to compile the project. JavaScript projects can use a jsconfig.json file ......
Read more >
tsconfig.json doesn't exclude folder node_modules properly
Im trying to build my project by command npm run ng build, but it prints me errors from folder node_modules like this.
Read more >
Publishing Node modules with TypeScript and ES modules
Publishing Node modules with TypeScript and ES modules ... First, create an empty directory and run npm init -y to create a new...
Read more >
How to Bundle JavaScript With Rollup — Step-by-Step Tutorial
support the use of Node modules in the browser,; work with environment variables, and; compress and minify our code for the smallest possible...
Read more >
How to optimize a serverless typescript eslint webpack setup ...
Or how I improved the Serverless AWS NodeJS Typescript template ... Include **/*.ts files only and Exclude node_modules and build directories.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found