V
V
vinssten2021-10-01 15:37:36
JavaScript
vinssten, 2021-10-01 15:37:36

How to compile all typescript files into one file when writing a Node application?

Hey Habr! I can’t figure out the problem, I’m writing a simple NodeJS backend, while using TypeScript, and the fact is that every time the project is compiled, tsc compiles the ts file to the same place where the source file is located, which complicates navigation, and looks it's not very pretty. I tried to add the appropriate settings to tsconfig, but all the time I get an error 61570092a3d76647799083.png
Maybe it's possible to somehow solve this issue, otherwise js files are very eyesore.6157010c06d87618877211.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Sokolov, 2021-10-01
@vinsssten

Bundlers can bundle into one file.. bundlers! ) Gulp, Grunt, Babel, WebPack, new-fast Vite and more. They are already able to tstranspile during assembly, if screwed accordingly. lotion. For example, about WebPack in the TypeScript documentation, or about TypeScript in the Vite configuration (it can do it out of the box).

I
Ivan Kulakov, 2021-10-01
@ivankprod

You need to separate the client and server into two subfolders, each with its own webpack config and package.json.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question