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

Function parseModuleExpression

packages/babel-parser/src/parser/expression.ts:3201–3221  ·  view source on GitHub ↗
(this: Parser)

Source from the content-addressed store, hash-verified

3199
3200 // https://github.com/tc39/proposal-js-module-blocks
3201 parseModuleExpression(this: Parser): N.ModuleExpression {
3202 this.expectPlugin("moduleBlocks");
3203 const node = this.startNode<N.ModuleExpression>();
3204 this.next(); // eat "module"
3205 if (!this.match(tt.braceL)) {
3206 this.unexpected(null, tt.braceL);
3207 }
3208 // start program node immediately after `{`
3209 const program = this.startNodeAt<N.Program>(this.state.endLoc);
3210 this.next(); // eat `{`
3211
3212 const revertScopes = this.initializeScopes(/** inModule */ true);
3213 this.enterInitialScopes();
3214
3215 try {
3216 node.body = this.parseProgram(program, tt.braceR, "module");
3217 } finally {
3218 revertScopes();
3219 }
3220 return this.finishNode<N.ModuleExpression>(node, "ModuleExpression");
3221 }
3222
3223 parseVoidPattern(
3224 this: Parser,

Callers

nothing calls this directly

Calls 3

nextMethod · 0.80
matchMethod · 0.80
finishNodeMethod · 0.80

Tested by

no test coverage detected