Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
systemjs-hot-reloader-ex
Advanced tools
SystemJS / JSPM hot reloader with support of CSS, SCSS, SASS, LESS, Stylus, React and JavaScript
Universal hot reloader for SystemJS / JSPM.
This is more powerfull alternative to capaj/systemjs-hot-reloader
.
bs-systemjs-hot-reloader
package
which will be responsible for
SystemJS.trace
npm install browser-sync bs-systemjs-hot-reloader --save-dev
jspm install npm:systemjs-hot-reloader-ex --dev
Please refer to bs-systemjs-hot-reloader
usage to setup BrowserSync with plugin.
It is peer dependency for bs-systemjs-hot-reloader
, but tehnically could be used
as client side reloader for any 3rd party development server.
Log level could be changed on the fly with:
// Log level: 0 - none, 1 - error, 2 - info (default), 3 - debug
SystemJS.import('systemjs-hot-reloader-ex')
.then(function (exports) {
exports.default.logLevel = 3;
});
This reloader could reload any JS module and will track all dependencies.
By default this reloader will recursively all parents of modified module and will reinject all modules.
Modules with side effects should export __unload()
hook.
Modules with alternative reload logic should export __reload()
hook.
Both hooks have array of reinjected modules as first argument.
This reloader could reload any module, including CSS, LESS, SCSS, SASS, Stylus, PostCSS if css plugin supports correct reinjection.
Server side bs-systemjs-hot-reloader
could track LESS, SCSS, SASS, Stylus
dependency tree to reload root module if one of dependencies is changed.
The fastest reload is guaranteed when css filename could be 1:1 resolved to module name. It works when you have css loading workflow like below:
SystemJS.config({
meta: {
"*.css": {
"loader": "plugin-css"
},
"*.scss": {
"loader": "plugin-sass"
}
},
});
import 'app.css';
import 'component.scss';
A slightly slower loading workflow (guess loader by adding !
to filename in resolver):
import 'app.css!';
import 'component.scss!';
The slowest loading workflow (need to search in all loaded modules):
import 'app.css!plugin-css';
import 'component.scss!plugin-sass';
React, babel plugin, babel preset are required (obviously):
jspm install react react-dom
jspm install plugin-babel babel-preset-react --dev
We could use WebPack's react hot reloader.
jspm install npm:react-hot-loader@3.0.0-beta.5 --save-dev
React Hot Reloader v3.x is the best hot reloader and it uses the best things
from both react-transform-hmr
and react-hot-loader
v1.x - v2.x
How does it work:
react-hot-loader/babel
required to wrap import()
react-hot-loader/lib/patch.dev.js
will patch Reactreact-hot-loader/lib/AppContainer.dev.js
will restore state on reload__reload()
hook required to rerender application instead of module reloadFile: jspm.config.js
:
SystemJS.config({
paths: {
"app/": "src/"
},
transpiler: "plugin-babel",
babelOptions: {
"presets": [
"babel-preset-react"
]
},
browserConfig: {
"babelOptions": {
"plugins": [
"react-hot-loader/babel"
]
},
"packages": {
"app": {
"main": "index"
}
}
},
packages: {
"app": {
"main": "index.dist",
"defaultExtension": "jsx"
}
}
});
File: src/index.jsx
(development entry point):
import React from 'react';
import ReactDOM from 'react-dom';
import 'react-hot-loader/lib/patch.dev.js';
import AppContainer from 'react-hot-loader/lib/AppContainer.dev.js';
import App from './App';
const root = document.getElementById('root');
ReactDOM.render(<AppContainer><App /></AppContainer>, root);
export function __reload() {
ReactDOM.render(<AppContainer><App /></AppContainer>, root);
}
File: src/index.dist.jsx
(production entry point):
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(<App/>, document.getElementById('root'));
File: ./index.html
(development entry point):
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Application</title>
</head>
<body>
<div id="root"></div>
<script src="jspm_packages/system.js"></script>
<script src="jspm.config.js"></script>
<script>SystemJS.import('app');</script>
</body>
</html>
File: ./index.dist.html
(production entry point):
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Application</title>
</head>
<body>
<div id="app-root"></div>
<script src="app.js"></script>
</body>
</html>
FAQs
SystemJS / JSPM hot reloader with support of CSS, SCSS, SASS, LESS, Stylus, React and JavaScript
We found that systemjs-hot-reloader-ex 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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.