Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@angularclass/hmr
Advanced tools
Angular2-HMR
npm install @angularclass/hmr @angularclass/hmr-loader
This module requires Angular 2.0.0-rc.5 or higher. Please see repository Angular 2 Seed for a working example.
also download https://github.com/AngularClass/angular2-hmr-loader
main.browser.ts
import { removeNgStyles, createNewHosts, bootloader } from '@angularclass/hmr';
@NgModule({
bootstrap: [ App ],
declarations: [ App ],
imports: [
// Angular 2
BrowserModule,
FormsModule,
HttpModule,
RouterModule.forRoot([], {
useHash: true
}),
// app
appModule
// vendors
],
providers: []
})
class MainModule {
constructor(public appRef: ApplicationRef) {}
hmrOnInit(store) {
if (!store) return;
console.log('HMR store', store);
console.log('store.OHHAI:', store.OHHAI)
// inject AppStore here and update it
// this.AppStore.update(store)
}
hmrOnDestroy(store) {
var cmpLocation = this.appRef.components.map(cmp => cmp.location.nativeElement);
// recreate elements
store.disposeOldHosts = createNewHosts(cmpLocation)
// inject your AppStore and grab state then set it on store
// var appState = this.AppStore.get()
store.OHHAI = 'yolo'
// Object.assign(store, appState)
// remove styles
removeNgStyles();
}
hmrAfterDestroy(store) {
// display new elements
store.disposeOldHosts()
delete store.disposeOldHosts;
// anything you need done the component is removed
}
}
export function main() {
return platformBrowserDynamic().bootstrapModule(MainModule);
}
// boot on document ready
bootloader(main);
bootloader
is only needed to detech that the dom is ready before bootstraping otherwise bootstrap. This is needed because that dom is already ready during reloading
In production you only need bootloader which just does this
export function bootloader(main) {
if (document.readyState === 'complete') {
main()
} else {
document.addEventListener('DOMContentLoaded', main);
}
}
you would bootstrap your app the normal way, in production, afer dom is ready. Also, in production, you should remove the loader
{
test: /\.ts$/,
loaders: [
'awesome-typescript-loader',
].concat(prod ? [] : '@angularclass/hmr-loader')
},
enjoy — AngularClass
Learn AngularJS, Angular 2, and Modern Web Development from the best. Looking for corporate Angular training, want to host us, or Angular consulting? patrick@angularclass.com
FAQs
angular-hmr: Hot Module Replacement for Webpack and Angular
The npm package @angularclass/hmr receives a total of 23,903 weekly downloads. As such, @angularclass/hmr popularity was classified as popular.
We found that @angularclass/hmr demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.