Socket
Socket
Sign inDemoInstall

mv3-hot-reload

Package Overview
Dependencies
20
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.0 to 0.2.0

30

out/bin/mv3-hot-reload.js

@@ -13,5 +13,19 @@ #!/usr/bin/env node

const utils_1 = require("../src/utils");
const PORT = 9012;
const DIST_DIRECTORY = path_1.default.resolve('dist');
const wss = new WebSocket.Server({ port: PORT });
let port = 9012;
let directory = 'dist';
let exclude = [];
try {
const CONFIG_PATH = path_1.default.resolve('mv3-hot-reload.config.js');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const config = require(CONFIG_PATH);
port = config.port || port;
directory = config.directory || directory;
exclude = config.exclude || exclude;
}
catch (err) {
// ignore
}
const directoryPath = path_1.default.resolve(directory);
const excludePaths = exclude.map((file) => path_1.default.join(directoryPath, file));
const wss = new WebSocket.Server({ port });
wss.on('listening', () => {

@@ -25,9 +39,11 @@ console.log('hot reload server is listening...');

chokidar_1.default
.watch(DIST_DIRECTORY, {
.watch(directoryPath, {
ignoreInitial: true,
})
.on('all', lodash_1.debounce(() => {
console.log('file change detected.');
ws.send(utils_1.Message.FileChange);
.on('all', lodash_1.debounce((_, path) => {
if (!excludePaths.includes(path)) {
console.log('file change detected.');
ws.send(utils_1.Message.FileChange);
}
}, 500));
});
{
"name": "mv3-hot-reload",
"version": "0.1.0",
"version": "0.2.0",
"description": "Enable hot reloading for MV3.",

@@ -5,0 +5,0 @@ "bin": "./out/bin/mv3-hot-reload.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc