MCPcopy Create free account
hub / github.com/babel/babel / parseWithCodeFrame

Function parseWithCodeFrame

packages/babel-template/src/parse.ts:192–223  ·  view source on GitHub ↗
(
  code: string,
  parserOpts: ParserOpts,
  syntacticPlaceholders?: boolean,
)

Source from the content-addressed store, hash-verified

190};
191
192function parseWithCodeFrame(
193 code: string,
194 parserOpts: ParserOpts,
195 syntacticPlaceholders?: boolean,
196): t.File {
197 const plugins = (parserOpts.plugins || []).slice();
198 if (syntacticPlaceholders !== false) {
199 plugins.push("placeholders");
200 }
201
202 parserOpts = {
203 allowAwaitOutsideFunction: true,
204 allowReturnOutsideFunction: true,
205 allowNewTargetOutsideFunction: true,
206 allowSuperOutsideMethod: true,
207 allowYieldOutsideFunction: true,
208 sourceType: "module",
209 ...parserOpts,
210 plugins,
211 };
212
213 try {
214 return parse(code, parserOpts);
215 } catch (err) {
216 const loc = err.loc;
217 if (loc) {
218 err.message += "\n" + codeFrameColumns(code, { start: loc });
219 err.code = "BABEL_TEMPLATE_PARSE_ERROR";
220 }
221 throw err;
222 }
223}

Callers 1

parseAndBuildMetadataFunction · 0.85

Calls 3

parseFunction · 0.90
codeFrameColumnsFunction · 0.90
pushMethod · 0.45

Tested by

no test coverage detected