如何捆绑 typescript-node-express 应用程序

P p*_*lik 6 node.js bundling-and-minification typescript typescript2.2

我想构建一个完整的全栈网络应用程序。我的服务器端代码是打字稿。我想配置我的项目,使其来自以下结构:

  • projectFolder/src/(服务器端打字稿文件) -包含一个index.ts主文件
  • projectFolder/public/(客户端代码) - 由index.ts 快速代码提供。

  • 项目文件夹/ serverCodeBundle.js

当我处理服务器端代码时,我希望在后台运行一些 watch 命令,并将所有 ts 文件捆绑到一些serverCodeBundle.js中,以便将其源映射到原始 ts 文件。

为了简单起见,我们假设我的服务器端代码如下所示(为简单起见,我省略了客户端代码服务):

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

/src/A.ts:
 export class A {
   constructor() {
     throw new Error("A error")
   }
 }
Run Code Online (Sandbox Code Playgroud)

运行 nodemon serverCodeBundle.js 时,应该会出现一条错误消息,指出错误来自 A.ts。

我已经在每个 ts 文件的开头尝试了 tsify[与 require("source-map-support").install() 一起使用(也仅在 index.ts 中)以及 tsconfig 中的 sourcemap 选项],但无法得到它上班。

是否有任何 tsify 配置、yeoman 生成器或任何其他捆绑器可以做到这一点?