From ca7a2fc19e716ea1bbb5f281cdd977364ecb8949 Mon Sep 17 00:00:00 2001 From: zhiyuanzmj <32807958+zhiyuanzmj@users.noreply.github.com> Date: Sat, 8 Jun 2024 14:06:51 +0800 Subject: [PATCH] fix(language-core): use type infer instead of await import (#4436) --- .../language-core/lib/codegen/script/internalComponent.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/language-core/lib/codegen/script/internalComponent.ts b/packages/language-core/lib/codegen/script/internalComponent.ts index 86f99b98fb..207cd8daa9 100644 --- a/packages/language-core/lib/codegen/script/internalComponent.ts +++ b/packages/language-core/lib/codegen/script/internalComponent.ts @@ -12,7 +12,8 @@ export function* generateInternalComponent( templateCodegenCtx: TemplateCodegenContext ): Generator { if (options.sfc.scriptSetup && options.scriptSetupRanges) { - yield `const __VLS_internalComponent = (await import('${options.vueCompilerOptions.lib}')).defineComponent({${newLine}`; + yield `let __VLS_defineComponent!: typeof import('${options.vueCompilerOptions.lib}').defineComponent${endOfLine}`; + yield `const __VLS_internalComponent = __VLS_defineComponent({${newLine}`; yield `setup() {${newLine}`; yield `return {${newLine}`; if (ctx.bypassDefineComponent) { @@ -56,7 +57,7 @@ export function* generateInternalComponent( yield `})${endOfLine}`; // defineComponent { } else if (options.sfc.script) { - yield `const __VLS_internalComponent = (await import('./${options.fileBaseName}')).default${endOfLine}`; + yield `let __VLS_internalComponent!: typeof import('./${options.fileBaseName}').default${endOfLine}`; } else { yield `const __VLS_internalComponent = (await import('${options.vueCompilerOptions.lib}')).defineComponent({})${endOfLine}`;