How to bundle typescript application - node -express

I want to create a full-fledged full-screen web application. My server side code is in typescript. I would like to configure my project so that it is from the following structre:

  • projectFolder / src / (server typescript files) - refers to the main index.ts file
  • projectFolder / public / (client-side code) - served from express.ts express code.

  • projectFolder / serverCodeBundle.js

While I'm working on my server-side code, I want some kind of watch command to run in backgorund and link all my ts files to some serverCodeBundle.js so that the original ts source file.

To keep things simple, suppose my server-side code looks like this (for simplicity, I have ommitted client code):

/src/index.ts:
 import {A} from './A'
 new A()

/src/A.ts:
 export class A {
   constructor() {
     throw new Error("A error")
   }
 }

Running nodemon serverCodeBundle.js should receive an error message indicating that the error came from A.ts.

I tried tsify [along with require ("source-map-support"). install () at the beginning of each ts file (and only in index.ts) and the sourcemap option in tsconfig], but can't make it work.

Is there any tsify configuration, yoman generator, or any other package that can do this?

+4
source share

Source: https://habr.com/ru/post/1673195/


All Articles