@@ -2,6 +2,7 @@ import Debug from 'debug'
22import MagicString from 'magic-string'
33import { TransformResult } from 'unplugin'
44import { Transformer } from '../../types'
5+ import { DISABLE_COMMENT } from '../constants'
56import { Context } from '../context'
67import { pascalCase , stringifyComponentImport } from '../utils'
78
@@ -20,7 +21,7 @@ export function Vue2Transformer(ctx: Context): Transformer {
2021
2122 const s = new MagicString ( code )
2223
23- for ( const match of code . matchAll ( / _ c \( [ ' " ] ( .+ ?) [ " ' ] ( [ , ) ] ) / g) ) {
24+ for ( const match of code . matchAll ( / _ c \( [ \s \n \t ] * [ ' " ] ( .+ ?) [ " ' ] ( [ , ) ] ) / g) ) {
2425 const [ full , matchedName , append ] = match
2526
2627 if ( match . index != null && matchedName && ! matchedName . startsWith ( '_' ) ) {
@@ -31,7 +32,7 @@ export function Vue2Transformer(ctx: Context): Transformer {
3132 componentPaths . push ( name )
3233 const component = ctx . findComponent ( name , [ sfcPath ] , matchedName )
3334 if ( component ) {
34- const var_name = `__vite_components_ ${ no } `
35+ const var_name = `__unplugin_components_ ${ no } `
3536 head . push ( stringifyComponentImport ( { ...component , name : var_name } , ctx ) )
3637 no += 1
3738 s . overwrite ( start , end , `_c(${ var_name } ${ append } ` )
@@ -46,7 +47,7 @@ export function Vue2Transformer(ctx: Context): Transformer {
4647 if ( ! head . length )
4748 return null
4849
49- s . prepend ( `${ head . join ( ';' ) } ;` )
50+ s . prepend ( `${ DISABLE_COMMENT } ${ head . join ( ';' ) } ;` )
5051
5152 const result : TransformResult = { code : s . toString ( ) }
5253 if ( ctx . sourcemap )
0 commit comments