Skip to content

Commit 17d598f

Browse files
committed
refactor(compiler-vapor): cleanup
1 parent d535c64 commit 17d598f

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

packages/compiler-vapor/src/compile.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,15 @@ import { transformVOn } from './transforms/vOn'
2323
import { transformVShow } from './transforms/vShow'
2424
import { transformRef } from './transforms/transformRef'
2525
import { transformText } from './transforms/transformText'
26-
import type { HackOptions } from './ir'
2726
import { transformVModel } from './transforms/vModel'
2827
import { transformVIf } from './transforms/vIf'
2928
import { transformVFor } from './transforms/vFor'
3029
import { transformComment } from './transforms/transformComment'
30+
import type { HackOptions } from './ir'
3131

3232
export { wrapTemplate } from './transforms/utils'
3333

34-
// TODO: copied from @vue/compiler-core
35-
// code/AST -> IR -> JS codegen
34+
// code/AST -> IR (transform) -> JS (generate)
3635
export function compile(
3736
source: string | RootNode,
3837
options: CompilerOptions = {},

packages/compiler-vapor/src/transform.ts

+6-9
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,7 @@ export class TransformContext<T extends AllNode = AllNode> {
8989
this.root = this as TransformContext<RootNode>
9090
}
9191

92-
enterBlock(
93-
ir: TransformContext['block'],
94-
isVFor: boolean = false,
95-
): () => void {
92+
enterBlock(ir: BlockIRNode, isVFor: boolean = false): () => void {
9693
const { block, template, dynamic, childrenTemplate } = this
9794
this.block = ir
9895
this.dynamic = ir.dynamic
@@ -205,26 +202,26 @@ const defaultOptions = {
205202

206203
// AST -> IR
207204
export function transform(
208-
root: RootNode,
205+
node: RootNode,
209206
options: TransformOptions = {},
210207
): RootIRNode {
211208
const ir: RootIRNode = {
212209
type: IRNodeTypes.ROOT,
213-
node: root,
214-
source: root.source,
210+
node,
211+
source: node.source,
215212
template: [],
216213
component: new Set(),
217214
block: {
218215
type: IRNodeTypes.BLOCK,
219-
node: root,
216+
node,
220217
dynamic: newDynamic(),
221218
effect: [],
222219
operation: [],
223220
returns: [],
224221
},
225222
}
226223

227-
const context = new TransformContext(ir, root, options)
224+
const context = new TransformContext(ir, node, options)
228225

229226
transformNode(context)
230227

0 commit comments

Comments
 (0)