@@ -2,19 +2,12 @@ import { traverse } from '@babel/core';
22import type {
33 BlockStatement ,
44 File ,
5- Node ,
65 ObjectExpression ,
76 StaticBlock ,
87} from '@babel/types' ;
9- import type { Parser } from 'prettier' ;
10- import { parsers as babelParsers } from 'prettier/plugins/babel.js' ;
118
12- import type { PluginOptions } from '../options.js' ;
139import { assert } from '../utils/assert.js' ;
14- import { PRINTER_NAME } from '../utils/index.js' ;
15- import { preprocess , type Template } from './preprocess.js' ;
16-
17- const typescript = babelParsers [ 'babel-ts' ] as Parser < Node | undefined > ;
10+ import type { Template } from './preprocess.js' ;
1811
1912/** Converts a node into a GlimmerTemplate node */
2013function convertNode (
@@ -29,7 +22,7 @@ function convertNode(
2922}
3023
3124/** Traverses the AST and replaces the transformed template parts with other AST */
32- function convertAst ( ast : File , templates : Template [ ] ) : void {
25+ export function convertAst ( ast : File , templates : Template [ ] ) : void {
3326 traverse ( ast , {
3427 enter ( path ) {
3528 const { node } = path ;
@@ -89,18 +82,3 @@ function convertAst(ast: File, templates: Template[]): void {
8982 ) ;
9083 }
9184}
92-
93- export const parser : Parser < Node | undefined > = {
94- ...typescript ,
95- astFormat : PRINTER_NAME ,
96-
97- async parse ( code : string , options : PluginOptions ) : Promise < Node > {
98- const preprocessed = preprocess ( code , options . filepath ) ;
99-
100- const ast = await typescript . parse ( preprocessed . code , options ) ;
101- assert ( 'expected ast' , ast ) ;
102- convertAst ( ast as File , preprocessed . templates ) ;
103-
104- return ast ;
105- } ,
106- } ;
0 commit comments