From 236d375708f82c422347c9f44d20856581b0bc59 Mon Sep 17 00:00:00 2001
From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com>
Date: Sun, 8 Mar 2026 07:54:19 +0800
Subject: [PATCH 1/2] locations
---
docs/parser.md | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/docs/parser.md b/docs/parser.md
index a6e4c701e9..95340f49b8 100644
--- a/docs/parser.md
+++ b/docs/parser.md
@@ -34,6 +34,7 @@ mind. When in doubt, use `.parse()`.
| Version | Changes |
| --------- | -------------------------------------------------- |
+| `v8.0.0` | Added `locations` |
| `v7.28.0` | Added `sourceType: "commonjs"` |
| `v7.27.0` | Added `allowYieldOutsideFunction` |
| `v7.26.0` | Added `startIndex` |
@@ -94,6 +95,11 @@ mind. When in doubt, use `.parse()`.
The resulting AST will have an `errors` property representing an array of all the parsing errors.
Note that even when this option is enabled, `@babel/parser` could throw for unrecoverable errors.
+- **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.
+
- **plugins**: Array containing the plugins that you want to enable.
- **sourceType**: Indicate the mode the code should be parsed in. Can be
From 2e06ad9475939360656d09fc220cfbd813c28004 Mon Sep 17 00:00:00 2001
From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com>
Date: Sun, 31 May 2026 13:32:37 +0800
Subject: [PATCH 2/2] update
---
docs/parser.md | 31 ++++++++++++++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)
diff --git a/docs/parser.md b/docs/parser.md
index 95340f49b8..4dfc46fde3 100644
--- a/docs/parser.md
+++ b/docs/parser.md
@@ -29,6 +29,8 @@ mind. When in doubt, use `.parse()`.
### Options
+:::babel8
+
History
@@ -48,6 +50,30 @@ mind. When in doubt, use `.parse()`.
+:::
+
+:::babel7
+
+
+ History
+
+| Version | Changes |
+| --------- | -------------------------------------------------- |
+| `v7.28.0` | Added `sourceType: "commonjs"` |
+| `v7.27.0` | Added `allowYieldOutsideFunction` |
+| `v7.26.0` | Added `startIndex` |
+| `v7.23.0` | Added `createImportExpressions` |
+| `v7.21.0` | Added `allowNewTargetOutsideFunction` and `annexB` |
+| `v7.16.0` | Added `startColumn` |
+| `v7.15.0` | Added `attachComment` |
+| `v7.7.0` | Added `errorRecovery` |
+| `v7.5.0` | Added `allowUndeclaredExports` |
+| `v7.2.0` | Added `createParenthesizedExpressions` |
+
+
+
+:::
+
- **allowImportExportEverywhere**: By default, `import` and `export`
declarations can only appear at a program's top level. Setting this
option to `true` allows them anywhere where a statement is allowed.
@@ -95,10 +121,13 @@ mind. When in doubt, use `.parse()`.
The resulting AST will have an `errors` property representing an array of all the parsing errors.
Note that even when this option is enabled, `@babel/parser` could throw for unrecoverable errors.
+:::babel8
+
- **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.
+
+:::
- **plugins**: Array containing the plugins that you want to enable.