mirror of https://github.com/sveltejs/svelte
use code-red's parsing functions to preserve comments in AST (#4268)
parent
726567d197
commit
9629de1619
@ -1,14 +1,13 @@
|
|||||||
import * as acorn from 'acorn';
|
import { Node } from 'acorn';
|
||||||
|
import * as code_red from 'code-red';
|
||||||
|
|
||||||
const Parser = acorn.Parser;
|
export const parse = (source: string): Node => code_red.parse(source, {
|
||||||
|
|
||||||
export const parse = (source: string) => Parser.parse(source, {
|
|
||||||
sourceType: 'module',
|
sourceType: 'module',
|
||||||
ecmaVersion: 11,
|
ecmaVersion: 11,
|
||||||
locations: true
|
locations: true
|
||||||
});
|
});
|
||||||
|
|
||||||
export const parse_expression_at = (source: string, index: number) => Parser.parseExpressionAt(source, index, {
|
export const parse_expression_at = (source: string, index: number): Node => code_red.parseExpressionAt(source, index, {
|
||||||
ecmaVersion: 11,
|
ecmaVersion: 11,
|
||||||
locations: true
|
locations: true
|
||||||
});
|
});
|
Loading…
Reference in new issue