Skip to content

Commit

Permalink
feat(add): directives and node transforms from compiler-core
Browse files Browse the repository at this point in the history
  • Loading branch information
gcclll committed Jan 5, 2021
1 parent 561d41b commit dc15719
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
16 changes: 14 additions & 2 deletions packages/compiler-ssr/src/index.ts
Expand Up @@ -5,7 +5,12 @@ import {
CompilerOptions,
transform,
transformBind,
generate
generate,
transformExpression,
trackVForSlotScopes,
trackSlotScopes,
transformStyle,
noopDirectiveTransform
} from '@vue/compiler-dom'
import { ssrTransformElement } from './transforms/ssrTransformElement'
import { ssrCodegenTransform } from './ssrCodegenTransform'
Expand Down Expand Up @@ -36,13 +41,20 @@ export function compile(
nodeTransforms: [
// TODO ... ssr transforms

trackVForSlotScopes,
transformExpression,
ssrTransformElement,
trackSlotScopes,
transformStyle,
...(options.nodeTransforms || []) // user transforms
],
directiveTransforms: {
// 复用 compiler-core 的 v-bind
bind: transformBind,
// TODO ... more ssr directive transforms
// ssr 中下面三个指令不处理
on: noopDirectiveTransform,
cloak: noopDirectiveTransform,
once: noopDirectiveTransform,
...(options.directiveTransforms || {}) // user transforms
}
})
Expand Down
3 changes: 2 additions & 1 deletion packages/compiler-ssr/src/transforms/ssrTransformElement.ts
Expand Up @@ -6,7 +6,8 @@ import {
NodeTransform,
NodeTypes,
PlainElementNode,
TemplateLiteral
TemplateLiteral,
createSimpleExpression
} from '@vue/compiler-dom'

// for directives with children overwrite (e.g. v-html & v-text), we need to
Expand Down

0 comments on commit dc15719

Please sign in to comment.