diff --git a/packages/plugin-vue/src/index.ts b/packages/plugin-vue/src/index.ts index bb08d855..beb2ccee 100644 --- a/packages/plugin-vue/src/index.ts +++ b/packages/plugin-vue/src/index.ts @@ -261,6 +261,7 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin { options.value, this, ssr, + customElementFilter.value(filename), ) } else if (query.type === 'style') { return transformStyle( diff --git a/packages/plugin-vue/src/main.ts b/packages/plugin-vue/src/main.ts index 60693829..2f1288bf 100644 --- a/packages/plugin-vue/src/main.ts +++ b/packages/plugin-vue/src/main.ts @@ -33,7 +33,7 @@ export async function transformMain( options: ResolvedOptions, pluginContext: TransformPluginContext, ssr: boolean, - asCustomElement: boolean, + customElement: boolean, ) { const { devServer, isProduction, devToolsEnabled } = options @@ -74,6 +74,7 @@ export async function transformMain( options, pluginContext, ssr, + customElement, ) // template @@ -88,6 +89,7 @@ export async function transformMain( options, pluginContext, ssr, + customElement, )) } @@ -110,7 +112,7 @@ export async function transformMain( const stylesCode = await genStyleCode( descriptor, pluginContext, - asCustomElement, + customElement, attachedProps, ) @@ -275,6 +277,7 @@ async function genTemplateCode( options: ResolvedOptions, pluginContext: PluginContext, ssr: boolean, + customElement: boolean, ) { const template = descriptor.template! const hasScoped = descriptor.styles.some((style) => style.scoped) @@ -289,6 +292,7 @@ async function genTemplateCode( options, pluginContext, ssr, + customElement, ) } else { if (template.src) { @@ -322,6 +326,7 @@ async function genScriptCode( options: ResolvedOptions, pluginContext: PluginContext, ssr: boolean, + customElement: boolean, ): Promise<{ code: string map: RawSourceMap | undefined @@ -329,7 +334,7 @@ async function genScriptCode( let scriptCode = `const ${scriptIdentifier} = {}` let map: RawSourceMap | undefined - const script = resolveScript(descriptor, options, ssr) + const script = resolveScript(descriptor, options, ssr, customElement) if (script) { // If the script is js/ts and has no external src, it can be directly placed // in the main module. @@ -376,7 +381,7 @@ async function genScriptCode( async function genStyleCode( descriptor: SFCDescriptor, pluginContext: PluginContext, - asCustomElement: boolean, + customElement: boolean, attachedProps: [string, string][], ) { let stylesCode = `` @@ -401,12 +406,12 @@ async function genStyleCode( ? `&src=${descriptor.id}` : '&src=true' : '' - const directQuery = asCustomElement ? `&inline` : `` + const directQuery = customElement ? `&inline` : `` const scopedQuery = style.scoped ? `&scoped=${descriptor.id}` : `` const query = `?vue&type=style&index=${i}${srcQuery}${directQuery}${scopedQuery}` const styleRequest = src + query + attrsQuery if (style.module) { - if (asCustomElement) { + if (customElement) { throw new Error( `