Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

acorn

Package Overview
Dependencies
Maintainers
3
Versions
138
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

acorn - npm Package Compare versions

Comparing version
8.15.0
to
8.16.0
+18
-0
CHANGELOG.md

@@ -0,1 +1,19 @@

## 8.16.0 (2026-02-19)
### New features
The `sourceType` option can now be set to `"commonjs"` to have the parser treat the top level scope as a function scope.
Add support for Unicode 17.
### Bug fixes
Don't recognize `await using` as contextual keywords when followed directly by a backslash.
Fix an issue where the parser would allow `return` statements in `static` blocks when `allowReturnOutsideFunction` was enabled.
Properly reject `using` declarations that appear directly in `switch` or `for` head scopes.
Fix some corner case issues in the recognition of `using` syntax.
## 8.15.0 (2025-06-08)

@@ -2,0 +20,0 @@

+2
-2

@@ -617,6 +617,6 @@ export interface Node {

* `sourceType` indicates the mode the code should be parsed in.
* Can be either `"script"` or `"module"`. This influences global
* Can be either `"script"`, `"module"` or `"commonjs"`. This influences global
* strict mode and parsing of `import` and `export` declarations.
*/
sourceType?: "script" | "module"
sourceType?: "script" | "module" | "commonjs"

@@ -623,0 +623,0 @@ /**

@@ -617,6 +617,6 @@ export interface Node {

* `sourceType` indicates the mode the code should be parsed in.
* Can be either `"script"` or `"module"`. This influences global
* Can be either `"script"`, `"module"` or `"commonjs"`. This influences global
* strict mode and parsing of `import` and `export` declarations.
*/
sourceType?: "script" | "module"
sourceType?: "script" | "module" | "commonjs"

@@ -623,0 +623,0 @@ /**

@@ -19,3 +19,3 @@ {

},
"version": "8.15.0",
"version": "8.16.0",
"engines": {

@@ -22,0 +22,0 @@ "node": ">=0.4.0"

+29
-10

@@ -29,3 +29,21 @@ # Acorn

```
## Importing acorn
ESM as well as CommonJS is supported for all 3: `acorn`, `acorn-walk` and `acorn-loose`.
ESM example for `acorn`:
```js
import * as acorn from "acorn"
```
CommonJS example for `acorn`:
```js
let acorn = require("acorn")
```
ESM is preferred, as it allows better editor auto-completions by offering TypeScript support.
For this reason, following examples will use ESM imports.
## Interface

@@ -40,4 +58,4 @@

```javascript
let acorn = require("acorn");
console.log(acorn.parse("1 + 1", {ecmaVersion: 2020}));
import * as acorn from "acorn"
console.log(acorn.parse("1 + 1", {ecmaVersion: 2020}))
```

@@ -66,7 +84,8 @@

- **sourceType**: Indicate the mode the code should be parsed in. Can be
either `"script"` or `"module"`. This influences global strict mode
either `"script"`, `"module"` or `"commonjs"`. This influences global strict mode
and parsing of `import` and `export` declarations.
**NOTE**: If set to `"module"`, then static `import` / `export` syntax
will be valid, even if `ecmaVersion` is less than 6.
will be valid, even if `ecmaVersion` is less than 6. If set to `"commonjs"`,
it is the same as `"script"` except that the top-level scope behaves like a function.

@@ -103,3 +122,3 @@ - **onInsertedSemicolon**: If given a callback, that callback will be

expressions. They are still not allowed in non-`async` functions,
though.
though. Setting this option to `true` is not allowed when `sourceType: "commonjs"`.

@@ -224,3 +243,3 @@ - **allowSuperOutsideMethod**: By default, `super` outside a method

// transform code to array of tokens:
var tokens = [...acorn.tokenizer(str)];
var tokens = [...acorn.tokenizer(str)]
```

@@ -246,6 +265,6 @@

```javascript
var acorn = require("acorn");
var jsx = require("acorn-jsx");
var JSXParser = acorn.Parser.extend(jsx());
JSXParser.parse("foo(<bar/>)", {ecmaVersion: 2020});
var acorn = require("acorn")
var jsx = require("acorn-jsx")
var JSXParser = acorn.Parser.extend(jsx())
JSXParser.parse("foo(<bar/>)", {ecmaVersion: 2020})
```

@@ -252,0 +271,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display