@vendasta/hot-module-replacement
v2.0.0
Published
Serivce to enable Hot module Replacement On Lazy Loaded Modules
Downloads
13
Readme
Running Hot Module Replacement on Lazy Loaded Modules
How to Use?
First you will need to install. This can be achieved by running
npm install @vendasta/hot-module-replacementNext you will need to initialize the module for Hot Module Replacement.
In the constructor of the module, call HotModuleReplacementService.initializeModule with the following parameters:
nodeModuleRef: the node module reference from the Webpack module API.moduleRef: the module that Hot module replacement will be ran on.lazyRoutes: the routes to run Hot Module Replacement on. For nested lazy loaded modules this should include the routes for any lazy loaded parent modules.enable: (optional) To be set by an environment variable to toggle running (This can be used to turn on/off Hot Module replacement by using a npm script).
Example:
export class ExampleModule {
constructor(moduleRef: NgModuleRef<ExampleModule>) {
HotModuleReplacementService.initializeModule(module, moduleRef, lazyRoutes, environment.enableHotModuleReplacement);
}
}Where lazyRoutes is a defined constant with all of the lazy loaded routes.
