@@ -13,9 +13,9 @@ import {
1313} from '@vue/runtime-dom'
1414import * as runtimeDom from '@vue/runtime-dom'
1515import {
16- EMPTY_OBJ ,
1716 NOOP ,
1817 extend ,
18+ genCacheKey ,
1919 generateCodeFrame ,
2020 isString ,
2121} from '@vue/shared'
@@ -25,19 +25,7 @@ if (__DEV__) {
2525 initDev ( )
2626}
2727
28- const compileCache = new WeakMap <
29- CompilerOptions ,
30- Record < string , RenderFunction >
31- > ( )
32-
33- function getCache ( options ?: CompilerOptions ) {
34- let c = compileCache . get ( options ?? EMPTY_OBJ )
35- if ( ! c ) {
36- c = Object . create ( null ) as Record < string , RenderFunction >
37- compileCache . set ( options ?? EMPTY_OBJ , c )
38- }
39- return c
40- }
28+ const compileCache : Record < string , RenderFunction > = Object . create ( null )
4129
4230function compileToFunction (
4331 template : string | HTMLElement ,
@@ -52,9 +40,8 @@ function compileToFunction(
5240 }
5341 }
5442
55- const key = template
56- const cache = getCache ( options )
57- const cached = cache [ key ]
43+ const key = genCacheKey ( template , options )
44+ const cached = compileCache [ key ]
5845 if ( cached ) {
5946 return cached
6047 }
@@ -111,7 +98,7 @@ function compileToFunction(
11198 // mark the function as runtime compiled
11299 ; ( render as InternalRenderFunction ) . _rc = true
113100
114- return ( cache [ key ] = render )
101+ return ( compileCache [ key ] = render )
115102}
116103
117104registerRuntimeCompiler ( compileToFunction )
0 commit comments