@@ -33,7 +33,7 @@ export async function transformMain(
3333 options : ResolvedOptions ,
3434 pluginContext : TransformPluginContext ,
3535 ssr : boolean ,
36- asCustomElement : boolean ,
36+ customElement : boolean ,
3737) {
3838 const { devServer, isProduction, devToolsEnabled } = options
3939
@@ -74,6 +74,7 @@ export async function transformMain(
7474 options ,
7575 pluginContext ,
7676 ssr ,
77+ customElement ,
7778 )
7879
7980 // template
@@ -88,6 +89,7 @@ export async function transformMain(
8889 options ,
8990 pluginContext ,
9091 ssr ,
92+ customElement ,
9193 ) )
9294 }
9395
@@ -110,7 +112,7 @@ export async function transformMain(
110112 const stylesCode = await genStyleCode (
111113 descriptor ,
112114 pluginContext ,
113- asCustomElement ,
115+ customElement ,
114116 attachedProps ,
115117 )
116118
@@ -275,6 +277,7 @@ async function genTemplateCode(
275277 options : ResolvedOptions ,
276278 pluginContext : PluginContext ,
277279 ssr : boolean ,
280+ customElement : boolean ,
278281) {
279282 const template = descriptor . template !
280283 const hasScoped = descriptor . styles . some ( ( style ) => style . scoped )
@@ -289,6 +292,7 @@ async function genTemplateCode(
289292 options ,
290293 pluginContext ,
291294 ssr ,
295+ customElement ,
292296 )
293297 } else {
294298 if ( template . src ) {
@@ -322,14 +326,15 @@ async function genScriptCode(
322326 options : ResolvedOptions ,
323327 pluginContext : PluginContext ,
324328 ssr : boolean ,
329+ customElement : boolean ,
325330) : Promise < {
326331 code : string
327332 map : RawSourceMap | undefined
328333} > {
329334 let scriptCode = `const ${ scriptIdentifier } = {}`
330335 let map : RawSourceMap | undefined
331336
332- const script = resolveScript ( descriptor , options , ssr )
337+ const script = resolveScript ( descriptor , options , ssr , customElement )
333338 if ( script ) {
334339 // If the script is js/ts and has no external src, it can be directly placed
335340 // in the main module.
@@ -376,7 +381,7 @@ async function genScriptCode(
376381async function genStyleCode (
377382 descriptor : SFCDescriptor ,
378383 pluginContext : PluginContext ,
379- asCustomElement : boolean ,
384+ customElement : boolean ,
380385 attachedProps : [ string , string ] [ ] ,
381386) {
382387 let stylesCode = ``
@@ -401,12 +406,12 @@ async function genStyleCode(
401406 ? `&src=${ descriptor . id } `
402407 : '&src=true'
403408 : ''
404- const directQuery = asCustomElement ? `&inline` : ``
409+ const directQuery = customElement ? `&inline` : ``
405410 const scopedQuery = style . scoped ? `&scoped=${ descriptor . id } ` : ``
406411 const query = `?vue&type=style&index=${ i } ${ srcQuery } ${ directQuery } ${ scopedQuery } `
407412 const styleRequest = src + query + attrsQuery
408413 if ( style . module ) {
409- if ( asCustomElement ) {
414+ if ( customElement ) {
410415 throw new Error (
411416 `<style module> is not supported in custom elements mode.` ,
412417 )
@@ -419,7 +424,7 @@ async function genStyleCode(
419424 stylesCode += importCode
420425 Object . assign ( ( cssModulesMap ||= { } ) , nameMap )
421426 } else {
422- if ( asCustomElement ) {
427+ if ( customElement ) {
423428 stylesCode += `\nimport _style_${ i } from ${ JSON . stringify (
424429 styleRequest ,
425430 ) } `
@@ -429,7 +434,7 @@ async function genStyleCode(
429434 }
430435 // TODO SSR critical CSS collection
431436 }
432- if ( asCustomElement ) {
437+ if ( customElement ) {
433438 attachedProps . push ( [
434439 `styles` ,
435440 `[${ descriptor . styles . map ( ( _ , i ) => `_style_${ i } ` ) . join ( ',' ) } ]` ,
0 commit comments