mirror of
https://github.com/marko-js/marko.git
synced 2026-02-01 16:07:13 +00:00
feat: add cached analyze stage
This commit is contained in:
parent
0baaf8ce0b
commit
bb6a050bbb
@ -22,9 +22,9 @@ export default (api, markoOpts) => {
|
||||
markoOpts.optimize = api.env("production");
|
||||
}
|
||||
|
||||
if (!translator || !translator.visitor) {
|
||||
if (!translator || !translator.translate) {
|
||||
throw new Error(
|
||||
"@marko/compiler: translator must provide a visitor object"
|
||||
"@marko/compiler: translator must provide a translate visitor object"
|
||||
);
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ export default (api, markoOpts) => {
|
||||
file.markoOpts = markoOpts;
|
||||
file.___taglibLookup = sourceFile.___taglibLookup;
|
||||
file.___getMarkoFile = getMarkoFile;
|
||||
traverse(ast, translator.visitor, file.scope, {});
|
||||
traverse(ast, translator.translate, file.scope, {});
|
||||
file.buildCodeFrameError = buildCodeFrameError;
|
||||
file.hub.buildError = buildError;
|
||||
file.markoOpts = file.___taglibLookup = file.___getMarkoFile = undefined;
|
||||
@ -176,6 +176,10 @@ export function getMarkoFile(code, jsParseOptions, markoOpts) {
|
||||
}
|
||||
}
|
||||
|
||||
if (markoOpts.translator.analyze) {
|
||||
traverse(file.ast, markoOpts.translator.analyze, file.scope, {});
|
||||
}
|
||||
|
||||
compileCache.set(cacheKey, {
|
||||
time: Date.now(),
|
||||
file,
|
||||
|
||||
@ -23,7 +23,7 @@ import getComponentFiles from "./util/get-component-files";
|
||||
|
||||
export { default as taglibs } from "./taglib";
|
||||
|
||||
export const visitor = {
|
||||
export const translate = {
|
||||
MarkoDocumentType,
|
||||
MarkoDeclaration,
|
||||
MarkoCDATA,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user