首页 > 解决方案 > 如何编译具有严格内存限制的打字稿

问题描述

我正在尝试在业余爱好者 Heroku 实例上部署一个小型 Typescript 项目,但我的构建步骤失败了FATAL ERROR: Ineffective mark-compacts near heap

我可以使用哪些有用的内存优化(在代码和我的 tsconfig 中)来构建具有 512mb 内存的东西?

我的构建命令和tsconfig如下:

tsc && node --optimize_for_size --max_old_space_size=460 dist/main.js

{
  "compilerOptions": {
    "target": "ES2019",
    "module": "CommonJS",
    "strict": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "strictPropertyInitialization": false,
    "removeComments": true,
    "incremental": true,
    "sourceMap": false,
    "declaration": false,
    "outDir": "./dist"
  }
}

标签: javascripttypescriptherokumemory

解决方案


推荐阅读