@@ -39,7 +39,7 @@ import { walk } from 'estree-walker'
3939import { RawSourceMap } from 'source-map'
4040import { warnOnce } from './warn'
4141import { isReservedTag } from 'web/util'
42- import { dirRE } from 'compiler/parser'
42+ import { bindRE , dirRE , onRE } from 'compiler/parser'
4343import { parseText } from 'compiler/parser/text-parser'
4444import { DEFAULT_FILENAME } from './parseComponent'
4545import {
@@ -278,23 +278,16 @@ export function compileScript(
278278 local : string ,
279279 imported : string | false ,
280280 isType : boolean ,
281- isFromSetup : boolean ,
282- needTemplateUsageCheck : boolean
281+ isFromSetup : boolean
283282 ) {
284283 if ( source === 'vue' && imported ) {
285284 userImportAlias [ imported ] = local
286285 }
287286
288287 // template usage check is only needed in non-inline mode, so we can skip
289288 // the work if inlineTemplate is true.
290- let isUsedInTemplate = needTemplateUsageCheck
291- if (
292- needTemplateUsageCheck &&
293- isTS &&
294- sfc . template &&
295- ! sfc . template . src &&
296- ! sfc . template . lang
297- ) {
289+ let isUsedInTemplate = true
290+ if ( isTS && sfc . template && ! sfc . template . src && ! sfc . template . lang ) {
298291 isUsedInTemplate = isImportUsed ( local , sfc )
299292 }
300293
@@ -658,8 +651,7 @@ export function compileScript(
658651 node . importKind === 'type' ||
659652 ( specifier . type === 'ImportSpecifier' &&
660653 specifier . importKind === 'type' ) ,
661- false ,
662- true
654+ false
663655 )
664656 }
665657 } else if ( node . type === 'ExportDefaultDeclaration' ) {
@@ -872,7 +864,6 @@ export function compileScript(
872864 node . importKind === 'type' ||
873865 ( specifier . type === 'ImportSpecifier' &&
874866 specifier . importKind === 'type' ) ,
875- true ,
876867 true
877868 )
878869 }
@@ -1809,7 +1800,11 @@ function resolveTemplateUsageCheckString(sfc: SFCDescriptor) {
18091800 for ( let i = 0 ; i < attrs . length ; i ++ ) {
18101801 const { name, value } = attrs [ i ]
18111802 if ( dirRE . test ( name ) ) {
1812- const baseName = name . replace ( dirRE , '' )
1803+ const baseName = onRE . test ( name )
1804+ ? 'on'
1805+ : bindRE . test ( name )
1806+ ? 'bind'
1807+ : name . replace ( dirRE , '' )
18131808 if ( ! isBuiltInDir ( baseName ) ) {
18141809 code += `,v${ capitalize ( camelize ( baseName ) ) } `
18151810 }
@@ -1838,6 +1833,8 @@ function processExp(exp: string, dir?: string): string {
18381833 if ( / a s \s + \w | < .* > | : / . test ( exp ) ) {
18391834 if ( dir === 'slot' ) {
18401835 exp = `(${ exp } )=>{}`
1836+ } else if ( dir === 'on' ) {
1837+ exp = `()=>{${ exp } }`
18411838 } else if ( dir === 'for' ) {
18421839 const inMatch = exp . match ( forAliasRE )
18431840 if ( inMatch ) {
0 commit comments