ui: add polyfill

This commit is contained in:
undefined committed 2024-06-27 15:40:21 +08:00
1 parent 2a8e3142b3
commit 67307ca48d
7 files changed
+48 -39

No files matched your search

+3 -2
View File
@@ -1,7 +1,7 @@
import esbuild from 'esbuild';
import {
Context, fs, Handler, Logger, NotFoundError, param, SettingModel, sha1,
size, Types, UiContextBase,
size, SystemModel, Types, UiContextBase,
} from 'hydrooj';
import { debounce } from 'lodash';
import { tmpdir } from 'os';
@@ -46,6 +46,7 @@ const build = async (contents: string) => {
format: 'iife' as 'iife',
bundle: true,
outdir: tmp,
sourcemap: SystemModel.get('ui-default.nosourcemap') ? false : 'external',
splitting: false,
write: false,
target: ['chrome65'],
@@ -106,7 +107,7 @@ export async function buildUI() {
...entryPoints.map((i) => `import '${relative(tmp, i).replace(/\\/g, '\\\\')}';`),
].join('\n'));
const pages = entry.outputFiles.map((i) => i.text);
const str = `window.LANGS=${JSON.stringify(SettingModel.langs)};${pages.join('\n')}`;
const str = `window.LANGS=${JSON.stringify(SettingModel.langs)};window._hydroLoad=()=>{ ${pages.join('\n')} };`;
addFile('entry.js', str);
UiContextBase.constantVersion = hashes['entry.js'];
for (const key in vfs) {