oxc-parser 0.54.0 → 0.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -2
- package/bindings.js +3 -0
- package/deserialize-js.js +5791 -0
- package/deserialize-ts.js +5844 -0
- package/index.d.ts +47 -0
- package/index.js +97 -2
- package/package.json +13 -11
package/README.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
## Features
|
|
4
4
|
|
|
5
|
+
### ESTree
|
|
6
|
+
|
|
7
|
+
The returned JavaScript AST follows the [ESTree](https://github.com/estree/estree) specification.
|
|
8
|
+
|
|
9
|
+
It is fully aligned with Acorn's AST, and any deviation would be considered a bug.
|
|
10
|
+
|
|
11
|
+
The returned TypeScript AST will conform to (`@typescript-eslint/typescript-estree`)[https://www.npmjs.com/package/@typescript-eslint/typescript-estree] in the near future.
|
|
12
|
+
|
|
13
|
+
### AST Types
|
|
14
|
+
|
|
15
|
+
[@oxc-project/types](https://www.npmjs.com/package/@oxc-project/types) can be used. For example:
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { Statement } from '@oxc-project/types';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Visitor
|
|
22
|
+
|
|
23
|
+
[oxc-walker](https://www.npmjs.com/package/oxc-walker) or [estree-walker](https://www.npmjs.com/package/estree-walker) can be used.
|
|
24
|
+
|
|
5
25
|
### Fast Mode
|
|
6
26
|
|
|
7
27
|
By default, Oxc parser does not produce semantic errors where symbols and scopes are needed.
|
|
@@ -17,7 +37,20 @@ let foo;
|
|
|
17
37
|
|
|
18
38
|
Does not produce any errors when `showSemanticErrors` is `false`, which is the default behavior.
|
|
19
39
|
|
|
20
|
-
|
|
40
|
+
Fast mode is best suited for parser plugins, where other parts of your build pipeline has already checked for errors.
|
|
41
|
+
|
|
42
|
+
Please note that turning off fast mode incurs a small performance overhead.
|
|
43
|
+
|
|
44
|
+
### ESTree compatibility
|
|
45
|
+
|
|
46
|
+
When parsing JS or JSX files, the AST returned is fully conformant with the
|
|
47
|
+
[ESTree standard](https://github.com/estree/estree).
|
|
48
|
+
|
|
49
|
+
When parsing TS or TSX files, the AST has additional properties related to TypeScript syntax.
|
|
50
|
+
These extra properties are broadly (but not entirely) in line with
|
|
51
|
+
[TypeScript ESLint](https://typescript-eslint.io/packages/parser/)'s AST.
|
|
52
|
+
|
|
53
|
+
If you need all ASTs in the same with-TS-properties format, use the `astType: 'ts'` option.
|
|
21
54
|
|
|
22
55
|
### Returns ESM information.
|
|
23
56
|
|
|
@@ -52,7 +85,7 @@ export interface EcmaScriptModule {
|
|
|
52
85
|
## API
|
|
53
86
|
|
|
54
87
|
```javascript
|
|
55
|
-
import oxc from '
|
|
88
|
+
import oxc from 'oxc-parser';
|
|
56
89
|
|
|
57
90
|
const code = 'const url: String = /* 🤨 */ import.meta.url;';
|
|
58
91
|
|
package/bindings.js
CHANGED
|
@@ -374,7 +374,10 @@ module.exports.ParseResult = nativeBinding.ParseResult
|
|
|
374
374
|
module.exports.ExportExportNameKind = nativeBinding.ExportExportNameKind
|
|
375
375
|
module.exports.ExportImportNameKind = nativeBinding.ExportImportNameKind
|
|
376
376
|
module.exports.ExportLocalNameKind = nativeBinding.ExportLocalNameKind
|
|
377
|
+
module.exports.getBufferOffset = nativeBinding.getBufferOffset
|
|
377
378
|
module.exports.ImportNameKind = nativeBinding.ImportNameKind
|
|
378
379
|
module.exports.parseAsync = nativeBinding.parseAsync
|
|
379
380
|
module.exports.parseSync = nativeBinding.parseSync
|
|
381
|
+
module.exports.parseSyncRaw = nativeBinding.parseSyncRaw
|
|
382
|
+
module.exports.rawTransferSupported = nativeBinding.rawTransferSupported
|
|
380
383
|
module.exports.Severity = nativeBinding.Severity
|