Skip to content

Commit f53a32a

Browse files
nodejs-github-botaduh95
authored andcommitted
deps: update acorn to 8.16.0
PR-URL: #61925 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent b771529 commit f53a32a

File tree

8 files changed

+209
-106
lines changed

8 files changed

+209
-106
lines changed

β€Ždeps/acorn/acorn/CHANGELOG.mdβ€Ž

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
## 8.16.0 (2026-02-19)
2+
3+
### New features
4+
5+
The `sourceType` option can now be set to `"commonjs"` to have the parser treat the top level scope as a function scope.
6+
7+
Add support for Unicode 17.
8+
9+
### Bug fixes
10+
11+
Don't recognize `await using` as contextual keywords when followed directly by a backslash.
12+
13+
Fix an issue where the parser would allow `return` statements in `static` blocks when `allowReturnOutsideFunction` was enabled.
14+
15+
Properly reject `using` declarations that appear directly in `switch` or `for` head scopes.
16+
17+
Fix some corner case issues in the recognition of `using` syntax.
18+
119
## 8.15.0 (2025-06-08)
220

321
### New features

β€Ždeps/acorn/acorn/README.mdβ€Ž

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,24 @@ git clone https://github.com/acornjs/acorn.git
2626
cd acorn
2727
npm install
2828
```
29+
## Importing acorn
30+
31+
ESM as well as CommonJS is supported for all 3: `acorn`, `acorn-walk` and `acorn-loose`.
32+
33+
ESM example for `acorn`:
34+
35+
```js
36+
import * as acorn from "acorn"
37+
```
38+
39+
CommonJS example for `acorn`:
40+
41+
```js
42+
let acorn = require("acorn")
43+
```
44+
45+
ESM is preferred, as it allows better editor auto-completions by offering TypeScript support.
46+
For this reason, following examples will use ESM imports.
2947

3048
## Interface
3149

@@ -36,8 +54,8 @@ syntax tree object as specified by the [ESTree
3654
spec](https://github.com/estree/estree).
3755

3856
```javascript
39-
let acorn = require("acorn");
40-
console.log(acorn.parse("1 + 1", {ecmaVersion: 2020}));
57+
import * as acorn from "acorn"
58+
console.log(acorn.parse("1 + 1", {ecmaVersion: 2020}))
4159
```
4260

4361
When encountering a syntax error, the parser will raise a
@@ -61,11 +79,12 @@ required):
6179
implemented through plugins.
6280

6381
- **sourceType**: Indicate the mode the code should be parsed in. Can be
64-
either `"script"` or `"module"`. This influences global strict mode
82+
either `"script"`, `"module"` or `"commonjs"`. This influences global strict mode
6583
and parsing of `import` and `export` declarations.
6684

6785
**NOTE**: If set to `"module"`, then static `import` / `export` syntax
68-
will be valid, even if `ecmaVersion` is less than 6.
86+
will be valid, even if `ecmaVersion` is less than 6. If set to `"commonjs"`,
87+
it is the same as `"script"` except that the top-level scope behaves like a function.
6988

7089
- **onInsertedSemicolon**: If given a callback, that callback will be
7190
called whenever a missing semicolon is inserted by the parser. The
@@ -97,7 +116,7 @@ required):
97116
for `ecmaVersion` 2022 and later, `false` for lower versions.
98117
Setting this option to `true` allows to have top-level `await`
99118
expressions. They are still not allowed in non-`async` functions,
100-
though.
119+
though. Setting this option to `true` is not allowed when `sourceType: "commonjs"`.
101120

102121
- **allowSuperOutsideMethod**: By default, `super` outside a method
103122
raises an error. Set this to `true` to accept such code.
@@ -217,7 +236,7 @@ for (let token of acorn.tokenizer(str)) {
217236
}
218237

219238
// transform code to array of tokens:
220-
var tokens = [...acorn.tokenizer(str)];
239+
var tokens = [...acorn.tokenizer(str)]
221240
```
222241

223242
**tokTypes** holds an object mapping names to the token type objects
@@ -238,10 +257,10 @@ on the extended version of the class. To extend a parser with plugins,
238257
you can use its static `extend` method.
239258

240259
```javascript
241-
var acorn = require("acorn");
242-
var jsx = require("acorn-jsx");
243-
var JSXParser = acorn.Parser.extend(jsx());
244-
JSXParser.parse("foo(<bar/>)", {ecmaVersion: 2020});
260+
var acorn = require("acorn")
261+
var jsx = require("acorn-jsx")
262+
var JSXParser = acorn.Parser.extend(jsx())
263+
JSXParser.parse("foo(<bar/>)", {ecmaVersion: 2020})
245264
```
246265

247266
The `extend` method takes any number of plugin values, and returns a

β€Ždeps/acorn/acorn/dist/acorn.d.mtsβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,10 +614,10 @@ export interface Options {
614614

615615
/**
616616
* `sourceType` indicates the mode the code should be parsed in.
617-
* Can be either `"script"` or `"module"`. This influences global
617+
* Can be either `"script"`, `"module"` or `"commonjs"`. This influences global
618618
* strict mode and parsing of `import` and `export` declarations.
619619
*/
620-
sourceType?: "script" | "module"
620+
sourceType?: "script" | "module" | "commonjs"
621621

622622
/**
623623
* a callback that will be called when a semicolon is automatically inserted.

β€Ždeps/acorn/acorn/dist/acorn.d.tsβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,10 +614,10 @@ export interface Options {
614614

615615
/**
616616
* `sourceType` indicates the mode the code should be parsed in.
617-
* Can be either `"script"` or `"module"`. This influences global
617+
* Can be either `"script"`, `"module"` or `"commonjs"`. This influences global
618618
* strict mode and parsing of `import` and `export` declarations.
619619
*/
620-
sourceType?: "script" | "module"
620+
sourceType?: "script" | "module" | "commonjs"
621621

622622
/**
623623
* a callback that will be called when a semicolon is automatically inserted.

β€Ždeps/acorn/acorn/dist/acorn.jsβ€Ž

Lines changed: 78 additions & 45 deletions
Large diffs are not rendered by default.

β€Ždeps/acorn/acorn/dist/acorn.mjsβ€Ž

Lines changed: 78 additions & 45 deletions
Large diffs are not rendered by default.

β€Ždeps/acorn/acorn/package.jsonβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
],
1717
"./package.json": "./package.json"
1818
},
19-
"version": "8.15.0",
19+
"version": "8.16.0",
2020
"engines": {
2121
"node": ">=0.4.0"
2222
},

β€Žsrc/acorn_version.hβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
// Refer to tools/dep_updaters/update-acorn.sh
33
#ifndef SRC_ACORN_VERSION_H_
44
#define SRC_ACORN_VERSION_H_
5-
#define ACORN_VERSION "8.15.0"
5+
#define ACORN_VERSION "8.16.0"
66
#endif // SRC_ACORN_VERSION_H_

0 commit comments

Comments
Β (0)