mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: loader: add perf tool
This commit is contained in:
1 parent
4f9c1a03f2
commit
5f995f97ad
6 files changed
+51
-20
No files matched your search
+6
-5
@@ -36,8 +36,8 @@
|
|||||||
"@types/node": "^18.11.18",
|
"@types/node": "^18.11.18",
|
||||||
"@types/semver": "^7.3.13",
|
"@types/semver": "^7.3.13",
|
||||||
"@types/supertest": "^2.0.12",
|
"@types/supertest": "^2.0.12",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.48.2",
|
"@typescript-eslint/eslint-plugin": "^5.49.0",
|
||||||
"@typescript-eslint/parser": "^5.48.2",
|
"@typescript-eslint/parser": "^5.49.0",
|
||||||
"autocannon": "^7.10.0",
|
"autocannon": "^7.10.0",
|
||||||
"cac": "^6.7.14",
|
"cac": "^6.7.14",
|
||||||
"chokidar": "^3.5.3",
|
"chokidar": "^3.5.3",
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
"eslint-plugin-jsx-a11y": "^6.7.1",
|
"eslint-plugin-jsx-a11y": "^6.7.1",
|
||||||
"eslint-plugin-react": "^7.32.1",
|
"eslint-plugin-react": "^7.32.1",
|
||||||
"eslint-plugin-react-hooks": "^4.6.0",
|
"eslint-plugin-react-hooks": "^4.6.0",
|
||||||
"eslint-plugin-simple-import-sort": "8.0.0",
|
"eslint-plugin-simple-import-sort": "10.0.0",
|
||||||
"friendly-errors-webpack-plugin": "^1.7.0",
|
"friendly-errors-webpack-plugin": "^1.7.0",
|
||||||
"fs-extra": "^11.1.0",
|
"fs-extra": "^11.1.0",
|
||||||
"globby": "13.1.3",
|
"globby": "13.1.3",
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
"mini-css-extract-plugin": "^2.7.2",
|
"mini-css-extract-plugin": "^2.7.2",
|
||||||
"monaco-editor-webpack-plugin": "^7.0.1",
|
"monaco-editor-webpack-plugin": "^7.0.1",
|
||||||
"mongodb": "^3.7.3",
|
"mongodb": "^3.7.3",
|
||||||
"mongodb-memory-server": "^8.11.3",
|
"mongodb-memory-server": "^8.11.4",
|
||||||
"nyc": "^15.1.0",
|
"nyc": "^15.1.0",
|
||||||
"ora": "^6.1.2",
|
"ora": "^6.1.2",
|
||||||
"postcss-loader": "^7.0.2",
|
"postcss-loader": "^7.0.2",
|
||||||
@@ -80,7 +80,8 @@
|
|||||||
"webpack-bundle-analyzer": "^4.7.0",
|
"webpack-bundle-analyzer": "^4.7.0",
|
||||||
"webpack-dev-server": "^4.11.1",
|
"webpack-dev-server": "^4.11.1",
|
||||||
"webpack-manifest-plugin": "^5.0.0",
|
"webpack-manifest-plugin": "^5.0.0",
|
||||||
"webpackbar": "^5.0.2"
|
"webpackbar": "^5.0.2",
|
||||||
|
"wtfnode": "^0.9.1"
|
||||||
},
|
},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
"@types/node": "18.11.18",
|
"@types/node": "18.11.18",
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
"p-queue": "^7.3.0",
|
"p-queue": "^7.3.0",
|
||||||
"schemastery": "^3.6.1",
|
"schemastery": "^3.6.1",
|
||||||
"shell-quote": "^1.7.4",
|
"shell-quote": "^1.7.4",
|
||||||
"superagent": "^8.0.8",
|
"superagent": "^8.0.9",
|
||||||
"ws": "^8.12.0"
|
"ws": "^8.12.0"
|
||||||
},
|
},
|
||||||
"preferUnplugged": true,
|
"preferUnplugged": true,
|
||||||
|
|||||||
@@ -12,17 +12,17 @@
|
|||||||
},
|
},
|
||||||
"preferUnplugged": true,
|
"preferUnplugged": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-s3": "^3.254.0",
|
"@aws-sdk/client-s3": "^3.259.0",
|
||||||
"@aws-sdk/lib-storage": "^3.254.0",
|
"@aws-sdk/lib-storage": "^3.259.0",
|
||||||
"@aws-sdk/middleware-endpoint": "^3.254.0",
|
"@aws-sdk/middleware-endpoint": "^3.257.0",
|
||||||
"@aws-sdk/s3-presigned-post": "^3.254.0",
|
"@aws-sdk/s3-presigned-post": "^3.259.0",
|
||||||
"@aws-sdk/s3-request-presigner": "^3.254.0",
|
"@aws-sdk/s3-request-presigner": "^3.259.0",
|
||||||
"@graphql-tools/schema": "^9.0.13",
|
"@graphql-tools/schema": "^9.0.14",
|
||||||
"@hydrooj/utils": "workspace:*",
|
"@hydrooj/utils": "workspace:*",
|
||||||
"@simplewebauthn/server": "^7.0.0",
|
"@simplewebauthn/server": "^7.0.0",
|
||||||
"adm-zip": "0.5.5",
|
"adm-zip": "0.5.5",
|
||||||
"cac": "^6.7.14",
|
"cac": "^6.7.14",
|
||||||
"cordis": "^2.7.1",
|
"cordis": "^2.7.2",
|
||||||
"detect-browser": "^5.3.0",
|
"detect-browser": "^5.3.0",
|
||||||
"emoji-regex": "^10.2.1",
|
"emoji-regex": "^10.2.1",
|
||||||
"emojis-list": "2.1.0",
|
"emojis-list": "2.1.0",
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
"moment-timezone": "^0.5.40",
|
"moment-timezone": "^0.5.40",
|
||||||
"mongodb": "^3.7.3",
|
"mongodb": "^3.7.3",
|
||||||
"nanoid": "^4.0.0",
|
"nanoid": "^4.0.0",
|
||||||
"nodemailer": "^6.9.0",
|
"nodemailer": "^6.9.1",
|
||||||
"notp": "^2.0.3",
|
"notp": "^2.0.3",
|
||||||
"p-queue": "^7.3.0",
|
"p-queue": "^7.3.0",
|
||||||
"path-to-regexp": "^6.2.1",
|
"path-to-regexp": "^6.2.1",
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
"schemastery": "^3.6.1",
|
"schemastery": "^3.6.1",
|
||||||
"semver": "^7.3.8",
|
"semver": "^7.3.8",
|
||||||
"serialize-javascript": "^6.0.1",
|
"serialize-javascript": "^6.0.1",
|
||||||
"superagent": "^8.0.8",
|
"superagent": "^8.0.9",
|
||||||
"tar": "^6.1.13",
|
"tar": "^6.1.13",
|
||||||
"thirty-two": "^1.0.2",
|
"thirty-two": "^1.0.2",
|
||||||
"ws": "^8.12.0"
|
"ws": "^8.12.0"
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ export function resolveConfig(plugin: any, config: any) {
|
|||||||
}
|
}
|
||||||
Context.service('loader');
|
Context.service('loader');
|
||||||
|
|
||||||
|
const timeout = Symbol.for('loader.timeout');
|
||||||
|
const showLoadTime = argv.options.showLoadTime;
|
||||||
|
|
||||||
export class Loader {
|
export class Loader {
|
||||||
static readonly Record = Symbol.for('loader.record');
|
static readonly Record = Symbol.for('loader.record');
|
||||||
|
|
||||||
@@ -60,11 +63,38 @@ export class Loader {
|
|||||||
fork.update(config);
|
fork.update(config);
|
||||||
} else {
|
} else {
|
||||||
logger.info('apply plugin %c', key.split('node_modules').pop());
|
logger.info('apply plugin %c', key.split('node_modules').pop());
|
||||||
const plugin = await this.resolvePlugin(key);
|
let plugin = await this.resolvePlugin(key);
|
||||||
if (!plugin) return;
|
if (!plugin) return;
|
||||||
resolveConfig(plugin, config);
|
resolveConfig(plugin, config);
|
||||||
if (asName) plugin.name = asName;
|
if (asName) plugin.name = asName;
|
||||||
// fork = parent.plugin(plugin, this.interpolate(config));
|
// fork = parent.plugin(plugin, this.interpolate(config));
|
||||||
|
if (plugin.apply) {
|
||||||
|
const original = plugin.apply;
|
||||||
|
const apply = (...args) => {
|
||||||
|
const start = Date.now();
|
||||||
|
const result = Promise.resolve(original(...args)).catch((e) => logger.error(e));
|
||||||
|
Promise.race([
|
||||||
|
result,
|
||||||
|
new Promise((resolve) => {
|
||||||
|
setTimeout(() => resolve(timeout), 10000);
|
||||||
|
}),
|
||||||
|
]).then((t) => {
|
||||||
|
if (t === timeout) {
|
||||||
|
logger.warn('Plugin %s took too long to load', key);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (showLoadTime && (typeof showLoadTime !== 'number' || Date.now() - start > showLoadTime)) {
|
||||||
|
logger.info('Plugin %s loaded in %dms', key, Date.now() - start);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
plugin = Object.create(plugin);
|
||||||
|
Object.defineProperty(plugin, 'apply', {
|
||||||
|
writable: true,
|
||||||
|
value: apply,
|
||||||
|
enumerable: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
fork = parent.plugin(plugin, config);
|
fork = parent.plugin(plugin, config);
|
||||||
if (!fork) return;
|
if (!fork) return;
|
||||||
parent.state[Loader.Record] ||= Object.create(null);
|
parent.state[Loader.Record] ||= Object.create(null);
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
"classnames": "^2.3.2",
|
"classnames": "^2.3.2",
|
||||||
"clipboard": "^2.0.11",
|
"clipboard": "^2.0.11",
|
||||||
"diff": "^5.1.0",
|
"diff": "^5.1.0",
|
||||||
"diff-dom": "^4.2.8",
|
"diff-dom": "^5.0.2",
|
||||||
"echarts": "^5.4.1",
|
"echarts": "^5.4.1",
|
||||||
"emojis-keywords": "2.0.0",
|
"emojis-keywords": "2.0.0",
|
||||||
"emojis-list": "2.1.0",
|
"emojis-list": "2.1.0",
|
||||||
@@ -67,7 +67,7 @@
|
|||||||
"monaco-editor": "0.33.0",
|
"monaco-editor": "0.33.0",
|
||||||
"monaco-editor-nls": "^2.0.0",
|
"monaco-editor-nls": "^2.0.0",
|
||||||
"monaco-themes": "^0.4.3",
|
"monaco-themes": "^0.4.3",
|
||||||
"monaco-yaml": "^4.0.2",
|
"monaco-yaml": "^4.0.3",
|
||||||
"nanoid": "^4.0.0",
|
"nanoid": "^4.0.0",
|
||||||
"normalize.css": "^8.0.1",
|
"normalize.css": "^8.0.1",
|
||||||
"nprogress": "^0.2.0",
|
"nprogress": "^0.2.0",
|
||||||
@@ -84,7 +84,7 @@
|
|||||||
"react-dnd": "^16.0.1",
|
"react-dnd": "^16.0.1",
|
||||||
"react-dnd-html5-backend": "^16.0.1",
|
"react-dnd-html5-backend": "^16.0.1",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-query": "^3.39.2",
|
"react-query": "^3.39.3",
|
||||||
"react-redux": "^8.0.5",
|
"react-redux": "^8.0.5",
|
||||||
"react-split-pane": "^0.1.92",
|
"react-split-pane": "^0.1.92",
|
||||||
"reconnecting-websocket": "^4.4.0",
|
"reconnecting-websocket": "^4.4.0",
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
"mongodb": "^3.7.3",
|
"mongodb": "^3.7.3",
|
||||||
"reggol": "^1.3.5",
|
"reggol": "^1.3.5",
|
||||||
"source-map-support": "^0.5.21",
|
"source-map-support": "^0.5.21",
|
||||||
"systeminformation": "^5.17.3"
|
"systeminformation": "^5.17.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/fs-extra": "^11.0.1",
|
"@types/fs-extra": "^11.0.1",
|
||||||
|
|||||||
Reference in new issue
Block a user