mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 09:38:19 +08:00
ui: lazyload types
This commit is contained in:
2 files changed
+4
-3
No files matched your search
@@ -24,7 +24,8 @@ const libUri = 'ts:filename/basic.d.ts';
|
||||
monaco.languages.typescript.javascriptDefaults.addExtraLib(libSource, libUri);
|
||||
monaco.editor.createModel(libSource, 'typescript', monaco.Uri.parse(libUri));
|
||||
const modules = [];
|
||||
(async () => {
|
||||
|
||||
export async function loadTypes() {
|
||||
for (const key of types.keys()) {
|
||||
if (!key.startsWith('.')) continue;
|
||||
const m = await types(key);
|
||||
@@ -41,4 +42,4 @@ const modules = [];
|
||||
val += '((id:string)=>any)';
|
||||
monaco.languages.typescript.javascriptDefaults.addExtraLib(val, 'ts:node/require.d.ts');
|
||||
monaco.editor.createModel(val, 'typescript', monaco.Uri.parse('ts:node/require.d.ts'));
|
||||
})();
|
||||
}
|
||||
@@ -32,7 +32,7 @@ const loaders = {
|
||||
if (resource) setLocaleData(resource);
|
||||
},
|
||||
markdown: () => import('./languages/markdown'),
|
||||
typescript: () => import('./languages/typescript'),
|
||||
typescript: () => import('./languages/typescript').then((m) => m.loadTypes()),
|
||||
yaml: () => import('./languages/yaml'),
|
||||
external: async (monaco, feat) => {
|
||||
for (const item of await getFeatures(`monaco-${feat}`)) {
|
||||
|
||||
Reference in new issue
Block a user