+24
-4
@@ -68,3 +68,3 @@ /** | ||
| hookServices(); | ||
| const debouncedFunc = new Debounce(freshFilename => { | ||
| const debouncedHmrFunc = new Debounce(freshFilename => { | ||
| unblocks().then(() => { | ||
@@ -80,2 +80,21 @@ cleanModuleCache(freshFilename); | ||
| }, 500); | ||
| const debouncedRerunFunc = new Debounce(() => { | ||
| unblocks().then(() => { | ||
| // noinspection JSUnresolvedReference | ||
| for (const cacheName in Module._cache) { | ||
| // noinspection JSUnresolvedReference | ||
| delete Module._cache[cacheName]; | ||
| } | ||
| for (const parentFilename in relationModuleFilenames) { | ||
| delete relationModuleFilenames[parentFilename]; | ||
| } | ||
| aliveFilenames.splice(0, aliveFilenames.length); | ||
| try { | ||
| aliveFilenames.push(pathname); | ||
| require(pathname); | ||
| } catch (e) { | ||
| console.error(e); | ||
| } | ||
| }); | ||
| }); | ||
@@ -86,6 +105,6 @@ /** | ||
| const chokidar = require('chokidar'); | ||
| const chokidarWatcher = chokidar.watch(process.cwd()); | ||
| const chokidarWatcher = chokidar.watch(process.cwd(), { ignored: /node_modules/ }); | ||
| chokidarWatcher.on('change', freshFilename => { | ||
| if (aliveFilenames.includes(freshFilename) || globHmrFiles.includes(freshFilename)) { | ||
| debouncedFunc.call(freshFilename); | ||
| if (aliveFilenames.includes(freshFilename)) { | ||
| debouncedHmrFunc.call(freshFilename); | ||
| } | ||
@@ -98,3 +117,4 @@ }); | ||
| globHmrFiles.push(freshFilename); | ||
| debouncedRerunFunc.call(); | ||
| } | ||
| }); |
+1
-1
| { | ||
| "name": "tsxx", | ||
| "version": "1.0.12", | ||
| "version": "1.0.13", | ||
| "description": "tsx 增强", | ||
@@ -5,0 +5,0 @@ "scripts": { |
10065
6.1%325
6.56%5
25%