File tree Expand file tree Collapse file tree 3 files changed +31
-3
lines changed
Expand file tree Collapse file tree 3 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -93,3 +93,27 @@ export class Parser {
9393 bindParserOpts(parserOpts : ParserOptions ): Parser
9494}
9595```
96+
97+ ## ` tsParser `
98+
99+ ``` ts
100+ import { tsParser } from ' babel-parse-wild-code'
101+ ```
102+
103+ The parser used for ` .ts ` files.
104+
105+ ## ` tsxParser `
106+
107+ ``` ts
108+ import { tsxParser } from ' babel-parse-wild-code'
109+ ```
110+
111+ The parser used for ` .tsx ` files.
112+
113+ ## ` jsParser `
114+
115+ ``` ts
116+ import { jsParser } from ' babel-parse-wild-code'
117+ ```
118+
119+ The fallback parser used for parsing ` .js ` files when ` babel-parse-wild-code ` failed to load Babel modules or config for the file's directory.
Original file line number Diff line number Diff line change @@ -21,6 +21,10 @@ declare export class Parser {
2121 bindParserOpts(parserOpts: ParserOptions): Parser;
2222}
2323
24+ declare export var tsParser: Parser
25+ declare export var tsxParser: Parser
26+ declare export var jsParser: Parser
27+
2428declare export function clearCache(): void
2529declare export function getParserSync(
2630 file: string,
Original file line number Diff line number Diff line change @@ -66,18 +66,18 @@ const tsPlugins: ParserPlugin[] = [
6666 'typescript' ,
6767]
6868
69- const tsParser : Parser = new Parser ( defaultBabelParser , {
69+ export const tsParser : Parser = new Parser ( defaultBabelParser , {
7070 sourceType : 'module' ,
7171 allowImportExportEverywhere : true ,
7272 allowReturnOutsideFunction : true ,
7373 startLine : 1 ,
7474 plugins : tsPlugins ,
7575} )
76- const tsxParser : Parser = new Parser ( defaultBabelParser , {
76+ export const tsxParser : Parser = new Parser ( defaultBabelParser , {
7777 ...tsParser . parserOpts ,
7878 plugins : [ ...tsPlugins , 'jsx' ] ,
7979} )
80- const jsParser : Parser = new Parser ( defaultBabelParser , {
80+ export const jsParser : Parser = new Parser ( defaultBabelParser , {
8181 sourceType : 'module' ,
8282 allowImportExportEverywhere : true ,
8383 allowReturnOutsideFunction : true ,
You can’t perform that action at this time.
0 commit comments