Skip to content

Commit 604867a

Browse files
committed
use code-red's parsing functions to preserve comments in AST (sveltejs#4258)
1 parent 726567d commit 604867a

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/compiler/parse/acorn.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
import * as acorn from 'acorn';
1+
import { Node } from 'acorn';
2+
import * as code_red from 'code-red';
23

3-
const Parser = acorn.Parser;
4-
5-
export const parse = (source: string) => Parser.parse(source, {
4+
export const parse = (source: string): Node => code_red.parse(source, {
65
sourceType: 'module',
76
ecmaVersion: 11,
87
locations: true
98
});
109

11-
export const parse_expression_at = (source: string, index: number) => Parser.parseExpressionAt(source, index, {
10+
export const parse_expression_at = (source: string, index: number): Node => code_red.parseExpressionAt(source, index, {
1211
ecmaVersion: 11,
1312
locations: true
1413
});

0 commit comments

Comments
 (0)