mirror of
https://github.com/go-gitea/gitea.git
synced 2026-04-23 11:09:43 +08:00
Avoid top-level await (#37272)
This commit is contained in:
@@ -2,12 +2,14 @@ import type {FrontendRenderFunc} from '../plugin.ts';
|
||||
import {initSwaggerUI} from '../swagger.ts';
|
||||
|
||||
// HINT: SWAGGER-CSS-IMPORT: this import is also necessary when swagger is used as a frontend external render
|
||||
// It must be on top-level, doesn't work in a function
|
||||
// Static import doesn't work (it needs to use manifest.json to manually add the CSS file)
|
||||
await import('../../../css/swagger.css');
|
||||
// But it can't share the same CSS file with the standalone page: it triggers our Vite manifest parser's bug
|
||||
// Although single top-level "await import(css)" can work, it requires es2022.
|
||||
// Otherwise, single function-level "await import(css)" can't work due to Vite's dependency analysis and bundling.
|
||||
import '../../../css/swagger-render.css';
|
||||
|
||||
export const frontendRender: FrontendRenderFunc = async (opts): Promise<boolean> => {
|
||||
try {
|
||||
await import('../../../css/swagger-render.css');
|
||||
await initSwaggerUI(opts.container, {specText: opts.contentString()});
|
||||
return true;
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user