Skip to content

Commit

Permalink
Lazy load prism (#136)
Browse files Browse the repository at this point in the history
Signed-off-by: Nik Nasr <[email protected]>
  • Loading branch information
nikrooz authored Dec 31, 2024
1 parent 5211257 commit d389bee
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions libs/ui/api/src/lib/API.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck
import { lazy, useId } from 'react';
import { Prism } from 'prism-react-renderer';

if (typeof window !== 'undefined') {
(window as any).Prism = Prism;
import('prism-react-renderer');
import('@stoplight/json-schema-viewer');
}

const JsonSchemaViewerInner = lazy(() =>
import('@stoplight/json-schema-viewer').then((module) => ({
default: module.JsonSchemaViewer,
}))
);
const JsonSchemaViewerInner = lazy(() => {
return import('prism-react-renderer').then((module) => {
(window as any).Prism = module.Prism;

return import('@stoplight/json-schema-viewer').then((module) => ({
default: module.JsonSchemaViewer,
}));
});
});

export const API = ({
apiDescriptionDocument,
Expand Down

0 comments on commit d389bee

Please sign in to comment.