Last active
June 5, 2019 07:23
-
-
Save vakrilov/f6add06310ad1799c38ee14781a64ab1 to your computer and use it in GitHub Desktop.
Angular HMR RC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { platformNativeScriptDynamic } from "nativescript-angular/platform"; | |
import { AppOptions } from "nativescript-angular/platform-common"; | |
import { AppModule } from "./app.module"; | |
// Optional - attach to livesync hooks and perfrom navigation | |
import "./livesync-navigation"; | |
let options: AppOptions = {}; | |
if (module['hot']) { | |
const hmrUpdate = require("nativescript-dev-webpack/hmr").hmrUpdate; | |
options.hmrOptions = { | |
moduleTypeFactory: () => AppModule, | |
livesyncCallback: (platformReboot) => { | |
console.log("HMR: Sync...") | |
hmrUpdate(); | |
setTimeout(platformReboot, 0); | |
}, | |
} | |
hmrUpdate(); | |
// Path to your app module. You might have to change if your module is in deferent place | |
module['hot'].accept(["./app.module"]); | |
} | |
// Don't forget to pass the options when creating the platform | |
platformNativeScriptDynamic(options).bootstrapModule(AppModule); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@vakrilov thanks for this! One slight improvement:
Otherwise the navigate may error if not called inside NgZone 👍