wip(ssr): ssr helper codegen

This commit is contained in:
Evan You
2020-02-03 17:47:06 -05:00
parent d1d81cf1f9
commit b685805a26
18 changed files with 374 additions and 253 deletions

View File

@@ -22,20 +22,23 @@ export function compile(
template: string,
options: SSRCompilerOptions = {}
): CodegenResult {
// apply DOM-specific parsing options
options = {
mode: 'cjs',
...options,
// apply DOM-specific parsing options
...parserOptions,
...options
ssr: true,
// always prefix since compiler-ssr doesn't have size concern
prefixIdentifiers: true,
// disalbe optimizations that are unnecessary for ssr
cacheHandlers: false,
hoistStatic: false
}
const ast = baseParse(template, options)
transform(ast, {
...options,
prefixIdentifiers: true,
// disalbe optimizations that are unnecessary for ssr
cacheHandlers: false,
hoistStatic: false,
nodeTransforms: [
ssrTransformIf,
ssrTransformFor,
@@ -57,10 +60,5 @@ export function compile(
// by replacing ast.codegenNode.
ssrCodegenTransform(ast, options)
return generate(ast, {
mode: 'cjs',
...options,
ssr: true,
prefixIdentifiers: true
})
return generate(ast, options)
}