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 1
1
import LRU from 'lru-cache'
2
2
3
- export function createCache < T > ( size = 500 ) {
3
+ export function createCache < T > ( size = 500 ) : Map < string , T > & { max ?: number } {
4
4
if ( __GLOBAL__ || __ESM_BROWSER__ ) {
5
5
return new Map < string , T > ( )
6
6
}
Original file line number Diff line number Diff line change 1
1
export const version = __VERSION__
2
2
3
3
// API
4
- export { parse } from './parse'
4
+ export { parse , parseCache } from './parse'
5
5
export { compileTemplate } from './compileTemplate'
6
6
export { compileStyle , compileStyleAsync } from './compileStyle'
7
7
export { compileScript } from './compileScript'
Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ export interface SFCParseResult {
93
93
errors : ( CompilerError | SyntaxError ) [ ]
94
94
}
95
95
96
- const sourceToSFC = createCache < SFCParseResult > ( )
96
+ export const parseCache = createCache < SFCParseResult > ( )
97
97
98
98
export function parse (
99
99
source : string ,
@@ -108,7 +108,7 @@ export function parse(
108
108
) : SFCParseResult {
109
109
const sourceKey =
110
110
source + sourceMap + filename + sourceRoot + pad + compiler . parse
111
- const cache = sourceToSFC . get ( sourceKey )
111
+ const cache = parseCache . get ( sourceKey )
112
112
if ( cache ) {
113
113
return cache
114
114
}
@@ -284,7 +284,7 @@ export function parse(
284
284
descriptor,
285
285
errors
286
286
}
287
- sourceToSFC . set ( sourceKey , result )
287
+ parseCache . set ( sourceKey , result )
288
288
return result
289
289
}
290
290
You can’t perform that action at this time.
0 commit comments