mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +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
|
/config.json
|
||||||
yarn.lock
|
yarn.lock
|
||||||
tsconfig.json
|
tsconfig.json
|
||||||
|
tsconfig.*.json
|
||||||
|
|
||||||
# Project Rules
|
# Project Rules
|
||||||
## Core
|
## Core
|
||||||
|
|||||||
+36
-27
@@ -20,7 +20,9 @@ const compilerOptionsBase = {
|
|||||||
const baseOutDir = path.resolve(__dirname, '../.cache/ts-out');
|
const baseOutDir = path.resolve(__dirname, '../.cache/ts-out');
|
||||||
const config = {
|
const config = {
|
||||||
compilerOptions: compilerOptionsBase,
|
compilerOptions: compilerOptionsBase,
|
||||||
references: [],
|
references: [
|
||||||
|
{ path: 'tsconfig.ui.json' },
|
||||||
|
],
|
||||||
files: [],
|
files: [],
|
||||||
};
|
};
|
||||||
const configSrc = (name) => ({
|
const configSrc = (name) => ({
|
||||||
@@ -36,37 +38,14 @@ const configSrc = (name) => ({
|
|||||||
'dist',
|
'dist',
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
const configFlat = (name) => (name === 'packages/ui-default' ? {
|
const configFlat = (name) => ({
|
||||||
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/*': [
|
|
||||||
'./*',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
} : {
|
|
||||||
compilerOptions: {
|
compilerOptions: {
|
||||||
...compilerOptionsBase,
|
...compilerOptionsBase,
|
||||||
outDir: path.join(baseOutDir, name),
|
outDir: path.join(baseOutDir, name),
|
||||||
rootDir: '.',
|
rootDir: '.',
|
||||||
},
|
},
|
||||||
include: ['**/*.ts'],
|
include: ['**/*.ts'],
|
||||||
exclude: [],
|
exclude: ['public'],
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!fs.existsSync(path.resolve(process.cwd(), 'plugins'))) {
|
if (!fs.existsSync(path.resolve(process.cwd(), 'plugins'))) {
|
||||||
@@ -77,7 +56,36 @@ const modules = [
|
|||||||
'packages/hydrooj',
|
'packages/hydrooj',
|
||||||
...fs.readdirSync(path.resolve(process.cwd(), 'packages')).map((i) => `packages/${i}`),
|
...fs.readdirSync(path.resolve(process.cwd(), 'packages')).map((i) => `packages/${i}`),
|
||||||
...fs.readdirSync(path.resolve(process.cwd(), 'plugins')).map((i) => `plugins/${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) {
|
for (const package of modules) {
|
||||||
config.references.push({ path: package });
|
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));
|
fs.writeFileSync(path.resolve(process.cwd(), 'tsconfig.json'), JSON.stringify(config));
|
||||||
@@ -2,6 +2,18 @@
|
|||||||
require('@hydrooj/utils/lib/register');
|
require('@hydrooj/utils/lib/register');
|
||||||
|
|
||||||
const { default: hook } = require('require-resolve-hook');
|
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');
|
require('./commands');
|
||||||
@@ -631,7 +631,7 @@ export interface Model {
|
|||||||
builtin: typeof import('./model/builtin'),
|
builtin: typeof import('./model/builtin'),
|
||||||
contest: typeof import('./model/contest'),
|
contest: typeof import('./model/contest'),
|
||||||
DiscussionModel: typeof import('./model/discussion'),
|
DiscussionModel: typeof import('./model/discussion'),
|
||||||
document: typeof import('./model/document'),
|
document: Omit<typeof import('./model/document'), 'apply'>,
|
||||||
domain: typeof import('./model/domain').default,
|
domain: typeof import('./model/domain').default,
|
||||||
message: typeof import('./model/message').default,
|
message: typeof import('./model/message').default,
|
||||||
opcount: typeof import('./model/opcount'),
|
opcount: typeof import('./model/opcount'),
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { OpcountExceededError } from '../error';
|
import { OpcountExceededError } from '../error';
|
||||||
import * as bus from '../service/bus';
|
|
||||||
import db from '../service/db';
|
import db from '../service/db';
|
||||||
|
|
||||||
const coll = db.collection('opcount');
|
const coll = db.collection('opcount');
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ export { default as paginate } from './lib/paginate';
|
|||||||
export * from './service/decorators';
|
export * from './service/decorators';
|
||||||
export { Handler, ConnectionHandler } from './service/server';
|
export { Handler, ConnectionHandler } from './service/server';
|
||||||
export { UiContextBase } from './service/layers/base';
|
export { UiContextBase } from './service/layers/base';
|
||||||
|
export * as StorageService from './service/storage';
|
||||||
export { EventMap } from './service/bus';
|
export { EventMap } from './service/bus';
|
||||||
export {
|
export {
|
||||||
db, Schema, yaml, fs, AdmZip, superagent,
|
db, Schema, yaml, fs, AdmZip, superagent,
|
||||||
|
|||||||
@@ -2,13 +2,12 @@
|
|||||||
/* eslint-disable no-await-in-loop */
|
/* eslint-disable no-await-in-loop */
|
||||||
import mongodb, { Cursor, Db } from 'mongodb';
|
import mongodb, { Cursor, Db } from 'mongodb';
|
||||||
import {
|
import {
|
||||||
DiscussionModel, DiscussionTailReplyDoc, MessageDoc,
|
db as dst,
|
||||||
RecordDoc, Schema, TestCase, TrainingNode,
|
DiscussionModel, DiscussionTailReplyDoc, DocumentModel,
|
||||||
|
MessageDoc, RecordDoc, Schema, TestCase, TrainingNode,
|
||||||
} from 'hydrooj';
|
} from 'hydrooj';
|
||||||
|
|
||||||
const dst = global.Hydro.service.db;
|
|
||||||
const map = {};
|
const map = {};
|
||||||
|
|
||||||
const pid = (id) => {
|
const pid = (id) => {
|
||||||
if (map[id.toString()]) return map[id.toString()];
|
if (map[id.toString()]) return map[id.toString()];
|
||||||
return id;
|
return id;
|
||||||
@@ -74,7 +73,7 @@ const tasks = {
|
|||||||
parent_doc_id: {
|
parent_doc_id: {
|
||||||
field: 'parentId',
|
field: 'parentId',
|
||||||
processer: (parentId, doc) => {
|
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 pid(parentId);
|
||||||
}
|
}
|
||||||
return parentId;
|
return parentId;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ declare module 'hydrooj' {
|
|||||||
'sonic.auth': string;
|
'sonic.auth': string;
|
||||||
}
|
}
|
||||||
interface Context {
|
interface Context {
|
||||||
sonic: SonicService;
|
sonic?: SonicService;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user