fix: 修复打包后模块无法加载的问题,改用静态模块加载
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import chokidar, { FSWatcher } from 'chokidar';
|
||||
import path from 'path';
|
||||
import { NOTEBOOK_ROOT } from '../config/paths.js';
|
||||
import { config } from '../config/index.js';
|
||||
import { eventBus } from '../events/eventBus.js';
|
||||
import { logger } from '../utils/logger.js';
|
||||
import { toPosixPath } from '../../shared/utils/path.js';
|
||||
@@ -10,16 +10,17 @@ let watcher: FSWatcher | null = null;
|
||||
export const startWatcher = (): void => {
|
||||
if (watcher) return;
|
||||
|
||||
logger.info(`Starting file watcher for: ${NOTEBOOK_ROOT}`);
|
||||
const notebookRoot = config.notebookRoot;
|
||||
logger.info(`Starting file watcher for: ${notebookRoot}`);
|
||||
|
||||
watcher = chokidar.watch(NOTEBOOK_ROOT, {
|
||||
watcher = chokidar.watch(notebookRoot, {
|
||||
ignored: /(^|[\/\\])\../,
|
||||
persistent: true,
|
||||
ignoreInitial: true,
|
||||
});
|
||||
|
||||
const broadcast = (event: string, changedPath: string) => {
|
||||
const rel = path.relative(NOTEBOOK_ROOT, changedPath);
|
||||
const rel = path.relative(notebookRoot, changedPath);
|
||||
if (!rel || rel.startsWith('..') || path.isAbsolute(rel)) return;
|
||||
logger.info(`File event: ${event} - ${rel}`);
|
||||
eventBus.broadcast({ event, path: toPosixPath(rel) });
|
||||
|
||||
Reference in New Issue
Block a user