@@ -2,6 +2,7 @@ import Debug from 'debug'
2
2
import MagicString from 'magic-string'
3
3
import { TransformResult } from 'unplugin'
4
4
import { Transformer } from '../../types'
5
+ import { DISABLE_COMMENT } from '../constants'
5
6
import { Context } from '../context'
6
7
import { pascalCase , stringifyComponentImport } from '../utils'
7
8
@@ -20,7 +21,7 @@ export function Vue2Transformer(ctx: Context): Transformer {
20
21
21
22
const s = new MagicString ( code )
22
23
23
- for ( const match of code . matchAll ( / _ c \( [ ' " ] ( .+ ?) [ " ' ] ( [ , ) ] ) / g) ) {
24
+ for ( const match of code . matchAll ( / _ c \( [ \s \n \t ] * [ ' " ] ( .+ ?) [ " ' ] ( [ , ) ] ) / g) ) {
24
25
const [ full , matchedName , append ] = match
25
26
26
27
if ( match . index != null && matchedName && ! matchedName . startsWith ( '_' ) ) {
@@ -31,7 +32,7 @@ export function Vue2Transformer(ctx: Context): Transformer {
31
32
componentPaths . push ( name )
32
33
const component = ctx . findComponent ( name , [ sfcPath ] , matchedName )
33
34
if ( component ) {
34
- const var_name = `__vite_components_ ${ no } `
35
+ const var_name = `__unplugin_components_ ${ no } `
35
36
head . push ( stringifyComponentImport ( { ...component , name : var_name } , ctx ) )
36
37
no += 1
37
38
s . overwrite ( start , end , `_c(${ var_name } ${ append } ` )
@@ -46,7 +47,7 @@ export function Vue2Transformer(ctx: Context): Transformer {
46
47
if ( ! head . length )
47
48
return null
48
49
49
- s . prepend ( `${ head . join ( ';' ) } ;` )
50
+ s . prepend ( `${ DISABLE_COMMENT } ${ head . join ( ';' ) } ;` )
50
51
51
52
const result : TransformResult = { code : s . toString ( ) }
52
53
if ( ctx . sourcemap )
0 commit comments