mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: experimental hot reload support
This commit is contained in:
1 parent
632ae27b88
commit
fd7c9cbeb1
26 files changed
+429
-148
No files matched your search
@@ -8,6 +8,7 @@ import yaml from 'js-yaml';
|
||||
import i18n from '../lib/i18n';
|
||||
import { Logger } from '../logger';
|
||||
import * as bus from '../service/bus';
|
||||
import { Runtime } from '../service/module';
|
||||
|
||||
const logger = new Logger('common');
|
||||
|
||||
@@ -36,7 +37,11 @@ const getLoader = (type: string, filename: string) => async function loader(pend
|
||||
if (p && !fail.includes(i)) {
|
||||
try {
|
||||
logger.info(`${type.replace(/^(.)/, (t) => t.toUpperCase())} init: %s`, i);
|
||||
require(p);
|
||||
const res = require(p);
|
||||
if (res.apply) {
|
||||
const runtime = new Runtime(p);
|
||||
runtime.load(res);
|
||||
}
|
||||
} catch (e) {
|
||||
fail.push(i);
|
||||
logger.info(`${type.replace(/^(.)/, (t) => t.toUpperCase())} load fail: %s`, i);
|
||||
|
||||
Reference in new issue
Block a user