@@ -10,7 +10,7 @@ import assetUrlsModule, {
1010import srcsetModule from './templateCompilerModules/srcset'
1111import consolidate from '@vue/consolidate'
1212import * as _compiler from 'web/entry-compiler'
13- import transpile from 'vue-template-es2015-compiler '
13+ import { stripWith } from './stripWith '
1414
1515export interface TemplateCompileOptions {
1616 source : string
@@ -26,6 +26,7 @@ export interface TemplateCompileOptions {
2626 isFunctional ?: boolean
2727 optimizeSSR ?: boolean
2828 prettify ?: boolean
29+ isTS ?: boolean
2930}
3031
3132export interface TemplateCompileResult {
@@ -108,7 +109,8 @@ function actuallyCompile(
108109 isProduction = process . env . NODE_ENV === 'production' ,
109110 isFunctional = false ,
110111 optimizeSSR = false ,
111- prettify = true
112+ prettify = true ,
113+ isTS = false
112114 } = options
113115
114116 const compile =
@@ -142,25 +144,20 @@ function actuallyCompile(
142144 errors
143145 }
144146 } else {
145- // TODO better transpile
146- const finalTranspileOptions = Object . assign ( { } , transpileOptions , {
147- transforms : Object . assign ( { } , transpileOptions . transforms , {
148- stripWithFunctional : isFunctional
149- } )
150- } )
151-
152- const toFunction = ( code : string ) : string => {
153- return `function (${ isFunctional ? `_h,_vm` : `` } ) {${ code } }`
154- }
155-
156147 // transpile code with vue-template-es2015-compiler, which is a forked
157148 // version of Buble that applies ES2015 transforms + stripping `with` usage
158149 let code =
159- transpile (
160- `var __render__ = ${ toFunction ( render ) } \n` +
161- `var __staticRenderFns__ = [${ staticRenderFns . map ( toFunction ) } ]` ,
162- finalTranspileOptions
163- ) + `\n`
150+ `var __render__ = ${ stripWith (
151+ render ,
152+ `render` ,
153+ isFunctional ,
154+ isTS ,
155+ transpileOptions
156+ ) } \n` +
157+ `var __staticRenderFns__ = [${ staticRenderFns . map ( code =>
158+ stripWith ( code , `` , isFunctional , isTS , transpileOptions )
159+ ) } ]` +
160+ `\n`
164161
165162 // #23 we use __render__ to avoid `render` not being prefixed by the
166163 // transpiler when stripping with, but revert it back to `render` to
0 commit comments