Skip to content

Add locations for parser#3186

Open
liuxingbaoyu wants to merge 1 commit intobabel:mainfrom
liuxingbaoyu:add-parser-locations
Open

Add locations for parser#3186
liuxingbaoyu wants to merge 1 commit intobabel:mainfrom
liuxingbaoyu:add-parser-locations

Conversation

@liuxingbaoyu
Copy link
Member

@netlify
Copy link

netlify bot commented Mar 7, 2026

👷 Deploy request for babel-next pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 9c9d896

@netlify
Copy link

netlify bot commented Mar 7, 2026

Deploy Preview for babel ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 9c9d896
🔍 Latest deploy log https://app.netlify.com/projects/babel/deploys/69acbae41ecca00008ba04b2
😎 Deploy Preview https://deploy-preview-3186--babel.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

- **locations**: Can be one of `true`, `false` or `packed`.
`true` is the default and will add a `loc` property to each node, which is an object with `start` and `end` properties, which are objects containing `line` and `column` numbers.
When set to `false`, the "loc" property will not be included in the output AST.
When set to `packed`, the `parse` function will return an `Uint32Array` of the form (`[line1, column1, line2, column2, ...]`). You can access the line and column numbers of a node with `locData[node.start * 2]` for the starting line, `locData[node.start * 2 + 1]` for the starting column, `locData[node.end * 2]` for the ending line and `locData[node.end * 2 + 1]` for the ending column.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add an example for packed? Do we not also return an AST?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants