Open chenjf5 opened 5 years ago
babel
Core-transformation-index.js
export function runSync( config: ResolvedConfig, code: string, ast: ?(BabelNodeFile | BabelNodeProgram), ): FileResult { const file = normalizeFile( config.passes, normalizeOptions(config), code, ast, ); transformFile(file, config.passes); const opts = file.opts; const { outputCode, outputMap } = opts.code !== false ? generateCode(config.passes, file) : {}; return { metadata: file.metadata, options: opts, ast: opts.ast === true ? file.ast : null, code: outputCode === undefined ? null : outputCode, map: outputMap === undefined ? null : outputMap, sourceType: file.ast.program.sourceType, }; }
normalizeFile
调用@babel/parser
babel
Core-transformation-index.js
normalizeFile
调用@babel/parser