问题:开启 sentry 配置,导致构建内存泄漏

    image.png

    默认构建配置
    使用1个Worker,内存限制为2048MB
    image.png

    处理方式:

    1. // Modifying node memory limits
    2. export NODE_OPTIONS="--max-old-space-size=8192"
    3. // 或者修改 SourceMap 生成方式(最低成本)
    4. // https://v3.umijs.org/zh-CN/guide/boost-compile-speed#调整-sourcemap-生成方式
    5. const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
    6. module.exports = {
    7. configureWebpack: config => {
    8. // get a reference to the existing ForkTsCheckerWebpackPlugin
    9. const existingForkTsChecker = config.plugins.filter(p => p instanceof ForkTsCheckerWebpackPlugin)[0];
    10. // remove the existing ForkTsCheckerWebpackPlugin
    11. // so that we can replace it with our modified version
    12. config.plugins = config.plugins.filter(p => !(p instanceof ForkTsCheckerWebpackPlugin));
    13. // copy the options from the original ForkTsCheckerWebpackPlugin
    14. // instance and add the memoryLimit property
    15. const forkTsCheckerOptions = existingForkTsChecker.options;
    16. // modification the workers
    17. forkTsCheckerOptions.workers = 2;
    18. // modification the memoryLimit
    19. forkTsCheckerOptions.memoryLimit = 12288;
    20. config.plugins.push(new ForkTsCheckerWebpackPlugin(forkTsCheckerOptions));
    21. }
    22. };

    修改后居然提升了构建速度
    Before
    image.png
    Now
    image.png