mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
ui: seperate module build
This commit is contained in:
1 parent
90a9fa95f4
commit
c2c85581c4
8 files changed
+57
-36
No files matched your search
@@ -29,6 +29,7 @@ globalConfig.json
|
||||
/config.json
|
||||
yarn.lock
|
||||
tsconfig.json
|
||||
tsconfig.*.json
|
||||
|
||||
# Project Rules
|
||||
## Core
|
||||
|
||||
+36
-27
@@ -20,7 +20,9 @@ const compilerOptionsBase = {
|
||||
const baseOutDir = path.resolve(__dirname, '../.cache/ts-out');
|
||||
const config = {
|
||||
compilerOptions: compilerOptionsBase,
|
||||
references: [],
|
||||
references: [
|
||||
{ path: 'tsconfig.ui.json' },
|
||||
],
|
||||
files: [],
|
||||
};
|
||||
const configSrc = (name) => ({
|
||||
@@ -36,37 +38,14 @@ const configSrc = (name) => ({
|
||||
'dist',
|
||||
],
|
||||
});
|
||||
const configFlat = (name) => (name === 'packages/ui-default' ? {
|
||||
exclude: [
|
||||
'./public',
|
||||
],
|
||||
include: ['**/*.ts'],
|
||||
compilerOptions: {
|
||||
experimentalDecorators: true,
|
||||
resolveJsonModule: true,
|
||||
jsx: 'react',
|
||||
module: 'commonjs',
|
||||
skipLibCheck: true,
|
||||
allowSyntheticDefaultImports: true,
|
||||
target: 'es2020',
|
||||
baseUrl: '.',
|
||||
outDir: path.join(baseOutDir, name),
|
||||
moduleResolution: 'node',
|
||||
types,
|
||||
paths: {
|
||||
'vj/*': [
|
||||
'./*',
|
||||
],
|
||||
},
|
||||
},
|
||||
} : {
|
||||
const configFlat = (name) => ({
|
||||
compilerOptions: {
|
||||
...compilerOptionsBase,
|
||||
outDir: path.join(baseOutDir, name),
|
||||
rootDir: '.',
|
||||
},
|
||||
include: ['**/*.ts'],
|
||||
exclude: [],
|
||||
exclude: ['public'],
|
||||
});
|
||||
|
||||
if (!fs.existsSync(path.resolve(process.cwd(), 'plugins'))) {
|
||||
@@ -77,7 +56,36 @@ const modules = [
|
||||
'packages/hydrooj',
|
||||
...fs.readdirSync(path.resolve(process.cwd(), 'packages')).map((i) => `packages/${i}`),
|
||||
...fs.readdirSync(path.resolve(process.cwd(), 'plugins')).map((i) => `plugins/${i}`),
|
||||
].filter((i) => !i.includes('/.')).filter((i) => fs.statSync(path.resolve(process.cwd(), i)).isDirectory());
|
||||
].filter((i) => !i.includes('/.') && !i.includes('ui-default')).filter((i) => fs.statSync(path.resolve(process.cwd(), i)).isDirectory());
|
||||
|
||||
const UIConfig = {
|
||||
exclude: [
|
||||
'packages/ui-default/public',
|
||||
],
|
||||
include: [
|
||||
'packages/ui-default/**/*.ts',
|
||||
'packages/**/public/**/*.ts',
|
||||
'plugins/**/public/**/*.ts',
|
||||
],
|
||||
compilerOptions: {
|
||||
experimentalDecorators: true,
|
||||
resolveJsonModule: true,
|
||||
jsx: 'react',
|
||||
module: 'commonjs',
|
||||
skipLibCheck: true,
|
||||
allowSyntheticDefaultImports: true,
|
||||
target: 'es2020',
|
||||
baseUrl: '.',
|
||||
outDir: path.join(baseOutDir, 'ui'),
|
||||
moduleResolution: 'node',
|
||||
types,
|
||||
paths: {
|
||||
'vj/*': [
|
||||
'./packages/ui-default/*',
|
||||
],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
for (const package of modules) {
|
||||
config.references.push({ path: package });
|
||||
@@ -99,4 +107,5 @@ for (const package of modules) {
|
||||
}
|
||||
}
|
||||
}
|
||||
fs.writeFileSync(path.resolve(process.cwd(), 'tsconfig.ui.json'), JSON.stringify(UIConfig));
|
||||
fs.writeFileSync(path.resolve(process.cwd(), 'tsconfig.json'), JSON.stringify(config));
|
||||
@@ -2,6 +2,18 @@
|
||||
require('@hydrooj/utils/lib/register');
|
||||
|
||||
const { default: hook } = require('require-resolve-hook');
|
||||
const { bypass } = hook(/^(hydrooj|@hydrooj\/utils|cordis|schemastery|lodash|js-yaml)/, (id) => bypass(() => require.resolve(id)));
|
||||
const { bypass } = hook(/^(hydrooj|@hydrooj\/utils|cordis|schemastery|lodash|js-yaml)/, (id) => {
|
||||
if (id.startsWith('hydrooj/src')) {
|
||||
console.log('module require via %s is deprecated.', id);
|
||||
if (process.env.DEV) {
|
||||
console.log(
|
||||
new Error().stack.split('\n')
|
||||
.filter((i) => !i.includes('node:internal') && i.startsWith(' '))
|
||||
.join('\n'),
|
||||
);
|
||||
}
|
||||
}
|
||||
return bypass(() => require.resolve(id));
|
||||
});
|
||||
|
||||
require('./commands');
|
||||
@@ -631,7 +631,7 @@ export interface Model {
|
||||
builtin: typeof import('./model/builtin'),
|
||||
contest: typeof import('./model/contest'),
|
||||
DiscussionModel: typeof import('./model/discussion'),
|
||||
document: typeof import('./model/document'),
|
||||
document: Omit<typeof import('./model/document'), 'apply'>,
|
||||
domain: typeof import('./model/domain').default,
|
||||
message: typeof import('./model/message').default,
|
||||
opcount: typeof import('./model/opcount'),
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { OpcountExceededError } from '../error';
|
||||
import * as bus from '../service/bus';
|
||||
import db from '../service/db';
|
||||
|
||||
const coll = db.collection('opcount');
|
||||
|
||||
@@ -42,6 +42,7 @@ export { default as paginate } from './lib/paginate';
|
||||
export * from './service/decorators';
|
||||
export { Handler, ConnectionHandler } from './service/server';
|
||||
export { UiContextBase } from './service/layers/base';
|
||||
export * as StorageService from './service/storage';
|
||||
export { EventMap } from './service/bus';
|
||||
export {
|
||||
db, Schema, yaml, fs, AdmZip, superagent,
|
||||
|
||||
@@ -2,13 +2,12 @@
|
||||
/* eslint-disable no-await-in-loop */
|
||||
import mongodb, { Cursor, Db } from 'mongodb';
|
||||
import {
|
||||
DiscussionModel, DiscussionTailReplyDoc, MessageDoc,
|
||||
RecordDoc, Schema, TestCase, TrainingNode,
|
||||
db as dst,
|
||||
DiscussionModel, DiscussionTailReplyDoc, DocumentModel,
|
||||
MessageDoc, RecordDoc, Schema, TestCase, TrainingNode,
|
||||
} from 'hydrooj';
|
||||
|
||||
const dst = global.Hydro.service.db;
|
||||
const map = {};
|
||||
|
||||
const pid = (id) => {
|
||||
if (map[id.toString()]) return map[id.toString()];
|
||||
return id;
|
||||
@@ -74,7 +73,7 @@ const tasks = {
|
||||
parent_doc_id: {
|
||||
field: 'parentId',
|
||||
processer: (parentId, doc) => {
|
||||
if (doc.parent_doc_type === global.Hydro.model.document.TYPE_PROBLEM) {
|
||||
if (doc.parent_doc_type === DocumentModel.TYPE_PROBLEM) {
|
||||
return pid(parentId);
|
||||
}
|
||||
return parentId;
|
||||
|
||||
@@ -13,7 +13,7 @@ declare module 'hydrooj' {
|
||||
'sonic.auth': string;
|
||||
}
|
||||
interface Context {
|
||||
sonic: SonicService;
|
||||
sonic?: SonicService;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user