File tree 2 files changed +8
-12
lines changed
packages/compiler-vapor/src
2 files changed +8
-12
lines changed Original file line number Diff line number Diff line change @@ -23,16 +23,15 @@ import { transformVOn } from './transforms/vOn'
23
23
import { transformVShow } from './transforms/vShow'
24
24
import { transformRef } from './transforms/transformRef'
25
25
import { transformText } from './transforms/transformText'
26
- import type { HackOptions } from './ir'
27
26
import { transformVModel } from './transforms/vModel'
28
27
import { transformVIf } from './transforms/vIf'
29
28
import { transformVFor } from './transforms/vFor'
30
29
import { transformComment } from './transforms/transformComment'
30
+ import type { HackOptions } from './ir'
31
31
32
32
export { wrapTemplate } from './transforms/utils'
33
33
34
- // TODO: copied from @vue /compiler-core
35
- // code/AST -> IR -> JS codegen
34
+ // code/AST -> IR (transform) -> JS (generate)
36
35
export function compile (
37
36
source : string | RootNode ,
38
37
options : CompilerOptions = { } ,
Original file line number Diff line number Diff line change @@ -89,10 +89,7 @@ export class TransformContext<T extends AllNode = AllNode> {
89
89
this . root = this as TransformContext < RootNode >
90
90
}
91
91
92
- enterBlock (
93
- ir : TransformContext [ 'block' ] ,
94
- isVFor : boolean = false ,
95
- ) : ( ) => void {
92
+ enterBlock ( ir : BlockIRNode , isVFor : boolean = false ) : ( ) => void {
96
93
const { block, template, dynamic, childrenTemplate } = this
97
94
this . block = ir
98
95
this . dynamic = ir . dynamic
@@ -205,26 +202,26 @@ const defaultOptions = {
205
202
206
203
// AST -> IR
207
204
export function transform (
208
- root : RootNode ,
205
+ node : RootNode ,
209
206
options : TransformOptions = { } ,
210
207
) : RootIRNode {
211
208
const ir : RootIRNode = {
212
209
type : IRNodeTypes . ROOT ,
213
- node : root ,
214
- source : root . source ,
210
+ node,
211
+ source : node . source ,
215
212
template : [ ] ,
216
213
component : new Set ( ) ,
217
214
block : {
218
215
type : IRNodeTypes . BLOCK ,
219
- node : root ,
216
+ node,
220
217
dynamic : newDynamic ( ) ,
221
218
effect : [ ] ,
222
219
operation : [ ] ,
223
220
returns : [ ] ,
224
221
} ,
225
222
}
226
223
227
- const context = new TransformContext ( ir , root , options )
224
+ const context = new TransformContext ( ir , node , options )
228
225
229
226
transformNode ( context )
230
227
You can’t perform that action at this time.
0 commit comments