@@ -33,7 +33,7 @@ export async function transformMain(
33
33
options : ResolvedOptions ,
34
34
pluginContext : TransformPluginContext ,
35
35
ssr : boolean ,
36
- asCustomElement : boolean ,
36
+ customElement : boolean ,
37
37
) {
38
38
const { devServer, isProduction, devToolsEnabled } = options
39
39
@@ -74,6 +74,7 @@ export async function transformMain(
74
74
options ,
75
75
pluginContext ,
76
76
ssr ,
77
+ customElement ,
77
78
)
78
79
79
80
// template
@@ -88,6 +89,7 @@ export async function transformMain(
88
89
options ,
89
90
pluginContext ,
90
91
ssr ,
92
+ customElement ,
91
93
) )
92
94
}
93
95
@@ -110,7 +112,7 @@ export async function transformMain(
110
112
const stylesCode = await genStyleCode (
111
113
descriptor ,
112
114
pluginContext ,
113
- asCustomElement ,
115
+ customElement ,
114
116
attachedProps ,
115
117
)
116
118
@@ -275,6 +277,7 @@ async function genTemplateCode(
275
277
options : ResolvedOptions ,
276
278
pluginContext : PluginContext ,
277
279
ssr : boolean ,
280
+ customElement : boolean ,
278
281
) {
279
282
const template = descriptor . template !
280
283
const hasScoped = descriptor . styles . some ( ( style ) => style . scoped )
@@ -289,6 +292,7 @@ async function genTemplateCode(
289
292
options ,
290
293
pluginContext ,
291
294
ssr ,
295
+ customElement ,
292
296
)
293
297
} else {
294
298
if ( template . src ) {
@@ -322,14 +326,15 @@ async function genScriptCode(
322
326
options : ResolvedOptions ,
323
327
pluginContext : PluginContext ,
324
328
ssr : boolean ,
329
+ customElement : boolean ,
325
330
) : Promise < {
326
331
code : string
327
332
map : RawSourceMap | undefined
328
333
} > {
329
334
let scriptCode = `const ${ scriptIdentifier } = {}`
330
335
let map : RawSourceMap | undefined
331
336
332
- const script = resolveScript ( descriptor , options , ssr )
337
+ const script = resolveScript ( descriptor , options , ssr , customElement )
333
338
if ( script ) {
334
339
// If the script is js/ts and has no external src, it can be directly placed
335
340
// in the main module.
@@ -376,7 +381,7 @@ async function genScriptCode(
376
381
async function genStyleCode (
377
382
descriptor : SFCDescriptor ,
378
383
pluginContext : PluginContext ,
379
- asCustomElement : boolean ,
384
+ customElement : boolean ,
380
385
attachedProps : [ string , string ] [ ] ,
381
386
) {
382
387
let stylesCode = ``
@@ -401,12 +406,12 @@ async function genStyleCode(
401
406
? `&src=${ descriptor . id } `
402
407
: '&src=true'
403
408
: ''
404
- const directQuery = asCustomElement ? `&inline` : ``
409
+ const directQuery = customElement ? `&inline` : ``
405
410
const scopedQuery = style . scoped ? `&scoped=${ descriptor . id } ` : ``
406
411
const query = `?vue&type=style&index=${ i } ${ srcQuery } ${ directQuery } ${ scopedQuery } `
407
412
const styleRequest = src + query + attrsQuery
408
413
if ( style . module ) {
409
- if ( asCustomElement ) {
414
+ if ( customElement ) {
410
415
throw new Error (
411
416
`<style module> is not supported in custom elements mode.` ,
412
417
)
@@ -419,7 +424,7 @@ async function genStyleCode(
419
424
stylesCode += importCode
420
425
Object . assign ( ( cssModulesMap ||= { } ) , nameMap )
421
426
} else {
422
- if ( asCustomElement ) {
427
+ if ( customElement ) {
423
428
stylesCode += `\nimport _style_${ i } from ${ JSON . stringify (
424
429
styleRequest ,
425
430
) } `
@@ -429,7 +434,7 @@ async function genStyleCode(
429
434
}
430
435
// TODO SSR critical CSS collection
431
436
}
432
- if ( asCustomElement ) {
437
+ if ( customElement ) {
433
438
attachedProps . push ( [
434
439
`styles` ,
435
440
`[${ descriptor . styles . map ( ( _ , i ) => `_style_${ i } ` ) . join ( ',' ) } ]` ,
0 commit comments