Skip to content

Commit

Permalink
Switch monaco wrapper to use import instead of require.ensure
Browse files Browse the repository at this point in the history
  • Loading branch information
dpwatrous authored and gingi committed Nov 9, 2023
1 parent 46a4111 commit 61d8e67
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions packages/bonito-ui/src/components/editor/impl/MonacoWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,9 @@ import { Spinner, SpinnerSize } from "@fluentui/react/lib/Spinner";
import type * as MonacoEditorImpl from "./MonacoEditorImpl";

/**
* Import monaco dynamically.
*
* This avoids using import() to kludge around a problem with Typescript when it
* is not using module = "esnext" (which prevents code splitting).
*
* See: https://github.com/webpack/webpack/issues/5703#issuecomment-357512412
* Import monaco dynamically to allow for code splitting
*/
const MonacoEditorLazy = React.lazy(async () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const req = require as any;
return new Promise<typeof MonacoEditorImpl>((resolve) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return req.ensure([], (req: any) => resolve(req("./MonacoEditorImpl")));
});
});
const MonacoEditorLazy = React.lazy(() => import("./MonacoEditorImpl"));

const LoadingSpinner: React.FC = () => {
return (
Expand Down

0 comments on commit 61d8e67

Please sign in to comment.