mv3-hot-reload
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -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", |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
4060
82
1