代码之家  ›  专栏  ›  技术社区  ›  Rich Duncan

Nest CLI-main.hmr.ts文件是什么?

  •  1
  • Rich Duncan  · 技术社区  · 6 年前

    使用创建新应用程序时

    nest new myApp
    

    它创建一个main.hmr.ts文件。此文件与main.ts不同,因为bootstrap函数包含以下代码:

      if (module.hot) {
        module.hot.accept();
        module.hot.dispose(() => app.close());
      }
    

    声明 模块 是:

    declare const module: any;
    

    我想知道这段代码的目的是什么。。。

    1 回复  |  直到 6 年前
        1
  •  4
  •   Rich Duncan    6 年前

    好的-WebPack热模块替换使用了它。。。

    https://webpack.js.org/api/hot-module-replacement/