@babel-core: parse should parse only (#10914)
* @babel/core: parse methods should parse only * Update Flow types
This commit is contained in:
committed by
Nicolò Ribaudo
parent
875e9619b7
commit
ee5b79d75d
@@ -1,14 +1,11 @@
|
||||
// @flow
|
||||
|
||||
import loadConfig, { type InputOptions } from "./config";
|
||||
import normalizeFile from "./transformation/normalize-file";
|
||||
import parser from "./parser";
|
||||
import type { ParseResult } from "./parser";
|
||||
import normalizeOptions from "./transformation/normalize-opts";
|
||||
|
||||
type AstRoot = BabelNodeFile | BabelNodeProgram;
|
||||
|
||||
export type ParseResult = AstRoot;
|
||||
|
||||
export type FileParseCallback = {
|
||||
type FileParseCallback = {
|
||||
(Error, null): any,
|
||||
(null, ParseResult | null): any,
|
||||
};
|
||||
@@ -49,7 +46,7 @@ export const parse: Parse = (function parse(code, opts, callback) {
|
||||
const cfg = loadConfig(opts);
|
||||
if (cfg === null) return cb(null, null);
|
||||
|
||||
ast = normalizeFile(cfg.passes, normalizeOptions(cfg), code).ast;
|
||||
ast = parser(cfg.passes, normalizeOptions(cfg), code);
|
||||
} catch (err) {
|
||||
return cb(err);
|
||||
}
|
||||
@@ -68,7 +65,7 @@ export function parseSync(
|
||||
return null;
|
||||
}
|
||||
|
||||
return normalizeFile(config.passes, normalizeOptions(config), code).ast;
|
||||
return parser(config.passes, normalizeOptions(config), code);
|
||||
}
|
||||
|
||||
export function parseAsync(
|
||||
|
||||
Reference in New Issue
Block a user