Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
babel-plugin-ng-hot-reload
Advanced tools
A babel plugin which enables hot module replacement in AngularJS applications.
The plugin is based on the ng-hot-reload webpack loader but is rewritten as babel plugin so that it is compatible with es-module syntax and every bundler which supports the hot-replacement API (e.g. webpack or parcel).
To see it in action you can simply checkout the examples on CodeSandbox:
- Webpack / JavaScript demo on CodeSandbox
- Webpack / TypeScript demo on CodeSandbox
- Parcel / TypeScript demo on CodeSandbox (There are some issues, see: FAQ)
npm i -D babel-plugin-ng-hot-reload # npm or
yarn add -D babel-plugin-ng-hot-reload # yarn
Add the following to your babelrc.js
file:
// without options
module.exports = {
plugins: ['babel-plugin-ng-hot-reload'],
};
// with options
module.exports = {
plugins: [
[
'babel-plugin-ng-hot-reload',
{
angularGlobal: false,
forceRefresh: true,
preserveState: true,
},
],
],
};
Option | Default | Description |
---|---|---|
angularGlobal | false (false or string) | Define whether angular is provided as global variable. Set to 'angular' when angular is your global variable. |
forceRefresh | true (boolean) | Whether to reload window automatically when a change in source files can't be hot-reloaded. Note that Webpack DevServer also has its own option hotOnly, which should also be configured correctly to get the behaviour you want when hot reloading fails. (ng-hot-reload option) |
preserveState | true (boolean) | If true, the library attempts to preserve some state in scope and controller instances when they are reloaded. Preserving state is an experimental feature and quite "hackish" so it may cause problems in some cases. Setting this to false might help if you run into weird errors.(ng-hot-reload option) |
@babel/preset-env
This plugin should work nicely together with the @babel/preset-env
plugin.
In opposite to the original ng-hot-reload webpack-loader it's not required to transpile your code to commonjs modules:
module.exports = {
presets: [
[
'@babel/preset-env',
{
modules: false, // Don't transpile the modules (default)
},
],
],
plugins: ['babel-plugin-ng-hot-reload'],
};
For an example check out the Webpack / Javascript example.
ngAnnotate
When you are using this plugin together with babel-plugin-angularjs-annotate
make sure that the ngAnnotate plugin is added before this plugin in your .babelrc.js
:
module.exports = {
plugins: ['angularjs-annotate', 'babel-plugin-ng-hot-reload'],
};
For an example check out the Webpack / TypeScript example.
Since this plugin only requires babel, you can use every build tool which supports hot-module-replacement.
You can check out the Parcel / TypeScript example to see how it works with other bundlers than webpack.
Unfortunatly there are currently some issues related to parcel:
fade.component.ts
)Felix Haus Website • Twitter |
---|
MIT - see LICENSE for details.
FAQs
Unknown package
The npm package babel-plugin-ng-hot-reload receives a total of 220 weekly downloads. As such, babel-plugin-ng-hot-reload popularity was classified as not popular.
We found that babel-plugin-ng-hot-reload demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.