@@ -10,7 +10,7 @@ import assetUrlsModule, {
10
10
import srcsetModule from './templateCompilerModules/srcset'
11
11
import consolidate from '@vue/consolidate'
12
12
import * as _compiler from 'web/entry-compiler'
13
- import transpile from 'vue-template-es2015-compiler '
13
+ import { stripWith } from './stripWith '
14
14
15
15
export interface TemplateCompileOptions {
16
16
source : string
@@ -26,6 +26,7 @@ export interface TemplateCompileOptions {
26
26
isFunctional ?: boolean
27
27
optimizeSSR ?: boolean
28
28
prettify ?: boolean
29
+ isTS ?: boolean
29
30
}
30
31
31
32
export interface TemplateCompileResult {
@@ -108,7 +109,8 @@ function actuallyCompile(
108
109
isProduction = process . env . NODE_ENV === 'production' ,
109
110
isFunctional = false ,
110
111
optimizeSSR = false ,
111
- prettify = true
112
+ prettify = true ,
113
+ isTS = false
112
114
} = options
113
115
114
116
const compile =
@@ -142,25 +144,20 @@ function actuallyCompile(
142
144
errors
143
145
}
144
146
} 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
-
156
147
// transpile code with vue-template-es2015-compiler, which is a forked
157
148
// version of Buble that applies ES2015 transforms + stripping `with` usage
158
149
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`
164
161
165
162
// #23 we use __render__ to avoid `render` not being prefixed by the
166
163
// transpiler when stripping with, but revert it back to `render` to
0 commit comments