From aacf9d5b9b5b550c7a6f2ce4ce55123d55cade0b Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Tue, 27 Sep 2022 17:46:41 +0800 Subject: [PATCH] fix(mp): Compatible with vite@3 --- packages/uni-cli-shared/src/mp/usingComponents.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/uni-cli-shared/src/mp/usingComponents.ts b/packages/uni-cli-shared/src/mp/usingComponents.ts index b658593dd9..c4a0fb7e6d 100644 --- a/packages/uni-cli-shared/src/mp/usingComponents.ts +++ b/packages/uni-cli-shared/src/mp/usingComponents.ts @@ -231,7 +231,10 @@ export function updateMiniProgramComponentsByMainFilename( return } const bindingComponents = parseBindingComponents( - templateDescriptor.bindingComponents, + { + ...templateDescriptor.bindingComponents, + ...scriptDescriptor.setupBindingComponents, + }, scriptDescriptor.bindingComponents ) const imports = parseImports( @@ -341,7 +344,9 @@ interface ParseDescriptor { resolve: PluginContext['resolve'] isExternal: boolean } -export interface ScriptDescriptor extends TemplateDescriptor {} +export interface ScriptDescriptor extends TemplateDescriptor { + setupBindingComponents: BindingComponents +} async function parseGlobalDescriptor( filename: string, @@ -386,10 +391,12 @@ export async function parseScriptDescriptor( options.resolve ) : [] - const descriptor = { + const descriptor: ScriptDescriptor = { bindingComponents: parseComponents(ast), + setupBindingComponents: findBindingComponents(ast.body), imports, } + scriptDescriptors.set(filename, descriptor) return descriptor } -- GitLab