mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-26 10:53:56 +00:00
perf(bundle): code-split re2js, css-tree/remote-dom, and Monaco out of startup index chunk (#4391)
This commit is contained in:
17 files changed
+240
-29
No files matched your search
@@ -0,0 +1,31 @@
|
||||
import { Loader2 } from 'lucide-react';
|
||||
import React, { Suspense } from 'react';
|
||||
import type { ScriptCodeEditorHandle, ScriptCodeEditorProps } from './ScriptCodeEditor';
|
||||
|
||||
const ScriptCodeEditorImpl = React.lazy(() =>
|
||||
import('./ScriptCodeEditor').then((module) => ({ default: module.ScriptCodeEditor })),
|
||||
);
|
||||
|
||||
/**
|
||||
* Lazy boundary for Monaco-backed ScriptCodeEditor so @monaco-editor/react
|
||||
* stays out of the startup bundle while QuickAddSnippetDialog and
|
||||
* QuickScriptEditorDialog remain mounted for global window events.
|
||||
*/
|
||||
export const LazyScriptCodeEditor = React.forwardRef<ScriptCodeEditorHandle, ScriptCodeEditorProps>(
|
||||
(props, ref) => (
|
||||
<Suspense
|
||||
fallback={
|
||||
<div
|
||||
className="flex h-full w-full items-center justify-center bg-background"
|
||||
style={props.fill ? undefined : { height: props.height ?? 200 }}
|
||||
>
|
||||
<Loader2 size={18} className="animate-spin text-muted-foreground" />
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<ScriptCodeEditorImpl ref={ref} {...props} />
|
||||
</Suspense>
|
||||
),
|
||||
);
|
||||
|
||||
LazyScriptCodeEditor.displayName = 'LazyScriptCodeEditor';
|
||||
Reference in new issue
Block a user