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

Function parseModuleExpression

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

nextMethod · 0.80
matchMethod · 0.80
finishNodeMethod · 0.80

Tested by

no test coverage detected