File tree Expand file tree Collapse file tree 3 files changed +5
-5
lines changed
packages/compiler-sfc/src Expand file tree Collapse file tree 3 files changed +5
-5
lines changed Original file line number Diff line number Diff line change 11import LRU from 'lru-cache'
22
3- export function createCache < T > ( size = 500 ) {
3+ export function createCache < T > ( size = 500 ) : Map < string , T > & { max ?: number } {
44 if ( __GLOBAL__ || __ESM_BROWSER__ ) {
55 return new Map < string , T > ( )
66 }
Original file line number Diff line number Diff line change 11export const version = __VERSION__
22
33// API
4- export { parse } from './parse'
4+ export { parse , parseCache } from './parse'
55export { compileTemplate } from './compileTemplate'
66export { compileStyle , compileStyleAsync } from './compileStyle'
77export { compileScript } from './compileScript'
Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ export interface SFCParseResult {
9393 errors : ( CompilerError | SyntaxError ) [ ]
9494}
9595
96- const sourceToSFC = createCache < SFCParseResult > ( )
96+ export const parseCache = createCache < SFCParseResult > ( )
9797
9898export function parse (
9999 source : string ,
@@ -108,7 +108,7 @@ export function parse(
108108) : SFCParseResult {
109109 const sourceKey =
110110 source + sourceMap + filename + sourceRoot + pad + compiler . parse
111- const cache = sourceToSFC . get ( sourceKey )
111+ const cache = parseCache . get ( sourceKey )
112112 if ( cache ) {
113113 return cache
114114 }
@@ -284,7 +284,7 @@ export function parse(
284284 descriptor,
285285 errors
286286 }
287- sourceToSFC . set ( sourceKey , result )
287+ parseCache . set ( sourceKey , result )
288288 return result
289289}
290290
You can’t perform that action at this time.
0 commit comments