Skip to content

[Bug]: regression for module block parse #15051

@fisker

Description

@fisker

💻

  • Would you like to work on a fix?

How are you using Babel?

Programmatic API (babel.transform, babel.parse)

Input code

> require('@babel/parser').parse('module {/* comment */}', {plugins: ['moduleBlocks']}).program.body[0].expression.body
Node {
  type: 'Program',
  start: 21,   // <---------------------
  end: 8,  // <---------------------
  loc: SourceLocation {
    start: Position { line: 1, column: 21, index: 21 },
    end: Position { line: 1, column: 8, index: 8 },
    filename: undefined,
    identifierName: undefined
  },
  sourceType: 'module',
  interpreter: null,
  body: [],
  directives: [],
  trailingComments: [
    {
      type: 'CommentBlock',
      value: ' comment ',
      start: 8,
      end: 21,
      loc: [SourceLocation]
    }
  ]
}

Configuration file name

No response

Configuration

N/A

Current and expected behavior

Range should be 8 ~ 21

Environment

N/A

Possible solution

No response

Additional context

Possible introduced in #14980 @JLHwung

Metadata

Metadata

Assignees

Labels

i: regressionoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: parser

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions