Files
gitea-MIRROR/web_src/js/render/plugins/frontend-openapi-swagger.ts
silverwind 290aaf7363 fix(render): remove redundant swagger CSS dynamic import
The top-level static import already bundles swagger-render.css into this
chunk, so the function-level dynamic import was ineffective and produced an
INEFFECTIVE_DYNAMIC_IMPORT warning. The CSS still loads in both the standalone
page and the iframe render (verified via e2e).

Assisted-by: Claude:Opus-4.8
2026-06-29 11:28:14 +02:00

19 lines
813 B
TypeScript

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
// 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 initSwaggerUI(opts.container, {specText: opts.contentString()});
return true;
} catch (error) {
console.error(error);
return false;
}
};