oxc-parser 0.53.0 → 0.54.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 +43 -6
- package/bindings.js +0 -1
- package/index.d.ts +9 -8
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -2,15 +2,52 @@
|
|
|
2
2
|
|
|
3
3
|
## Features
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
### Fast Mode
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
By default, Oxc parser does not produce semantic errors where symbols and scopes are needed.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
The full compiler is needed for such case, as the compiler does an additional semantic pass.
|
|
9
|
+
To enable semantic errors, apply the option `showSemanticErrors: true`.
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
For example,
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
let foo;
|
|
15
|
+
let foo;
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Does not produce any errors when `showSemanticErrors` is `false`, which is the default behavior.
|
|
19
|
+
|
|
20
|
+
This mode is best suited for parser plugins, where other parts of your build pipeline has already checked for errors.
|
|
21
|
+
|
|
22
|
+
### Returns ESM information.
|
|
23
|
+
|
|
24
|
+
It is likely that you are writing a parser plugin that requires ESM information.
|
|
25
|
+
|
|
26
|
+
To avoid walking the AST again, Oxc Parser returns ESM information directly.
|
|
27
|
+
|
|
28
|
+
This information can be used to rewrite import and exports with the help of [`magic-string`](https://www.npmjs.com/package/magic-string),
|
|
29
|
+
without any AST manipulations.
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
export interface EcmaScriptModule {
|
|
33
|
+
/**
|
|
34
|
+
* Has ESM syntax.
|
|
35
|
+
*
|
|
36
|
+
* i.e. `import` and `export` statements, and `import.meta`.
|
|
37
|
+
*
|
|
38
|
+
* Dynamic imports `import('foo')` are ignored since they can be used in non-ESM files.
|
|
39
|
+
*/
|
|
40
|
+
hasModuleSyntax: boolean;
|
|
41
|
+
/** Import statements. */
|
|
42
|
+
staticImports: Array<StaticImport>;
|
|
43
|
+
/** Export statements. */
|
|
44
|
+
staticExports: Array<StaticExport>;
|
|
45
|
+
/** Dynamic import expressions. */
|
|
46
|
+
dynamicImports: Array<DynamicImport>;
|
|
47
|
+
/** Span positions` of `import.meta` */
|
|
48
|
+
importMetas: Array<Span>;
|
|
49
|
+
}
|
|
50
|
+
```
|
|
14
51
|
|
|
15
52
|
## API
|
|
16
53
|
|
package/bindings.js
CHANGED
|
@@ -377,5 +377,4 @@ module.exports.ExportLocalNameKind = nativeBinding.ExportLocalNameKind
|
|
|
377
377
|
module.exports.ImportNameKind = nativeBinding.ImportNameKind
|
|
378
378
|
module.exports.parseAsync = nativeBinding.parseAsync
|
|
379
379
|
module.exports.parseSync = nativeBinding.parseSync
|
|
380
|
-
module.exports.parseWithoutReturn = nativeBinding.parseWithoutReturn
|
|
381
380
|
module.exports.Severity = nativeBinding.Severity
|
package/index.d.ts
CHANGED
|
@@ -141,21 +141,22 @@ export interface ParserOptions {
|
|
|
141
141
|
* (non-standard) `ParenthesizedExpression` nodes that have a single `expression` property
|
|
142
142
|
* containing the expression inside parentheses.
|
|
143
143
|
*
|
|
144
|
-
*
|
|
144
|
+
* @default true
|
|
145
145
|
*/
|
|
146
146
|
preserveParens?: boolean
|
|
147
|
+
/**
|
|
148
|
+
* Produce semantic errors with an additional AST pass.
|
|
149
|
+
* Semantic errors depend on symbols and scopes, where the parser does not construct.
|
|
150
|
+
* This adds a small performance overhead.
|
|
151
|
+
*
|
|
152
|
+
* @default false
|
|
153
|
+
*/
|
|
154
|
+
showSemanticErrors?: boolean
|
|
147
155
|
}
|
|
148
156
|
|
|
149
157
|
/** Parse synchronously. */
|
|
150
158
|
export declare function parseSync(filename: string, sourceText: string, options?: ParserOptions | undefined | null): ParseResult
|
|
151
159
|
|
|
152
|
-
/**
|
|
153
|
-
* Parse without returning anything.
|
|
154
|
-
*
|
|
155
|
-
* This is for benchmark purposes such as measuring napi communication overhead.
|
|
156
|
-
*/
|
|
157
|
-
export declare function parseWithoutReturn(filename: string, sourceText: string, options?: ParserOptions | undefined | null): void
|
|
158
|
-
|
|
159
160
|
export declare const enum Severity {
|
|
160
161
|
Error = 'Error',
|
|
161
162
|
Warning = 'Warning',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oxc-parser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.54.0",
|
|
4
4
|
"description": "Oxc Parser Node API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Parser"
|
|
@@ -24,16 +24,16 @@
|
|
|
24
24
|
"bindings.js"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@oxc-project/types": "^0.
|
|
27
|
+
"@oxc-project/types": "^0.54.0"
|
|
28
28
|
},
|
|
29
29
|
"optionalDependencies": {
|
|
30
|
-
"@oxc-parser/binding-win32-x64-msvc": "0.
|
|
31
|
-
"@oxc-parser/binding-win32-arm64-msvc": "0.
|
|
32
|
-
"@oxc-parser/binding-linux-x64-gnu": "0.
|
|
33
|
-
"@oxc-parser/binding-linux-arm64-gnu": "0.
|
|
34
|
-
"@oxc-parser/binding-linux-x64-musl": "0.
|
|
35
|
-
"@oxc-parser/binding-linux-arm64-musl": "0.
|
|
36
|
-
"@oxc-parser/binding-darwin-x64": "0.
|
|
37
|
-
"@oxc-parser/binding-darwin-arm64": "0.
|
|
30
|
+
"@oxc-parser/binding-win32-x64-msvc": "0.54.0",
|
|
31
|
+
"@oxc-parser/binding-win32-arm64-msvc": "0.54.0",
|
|
32
|
+
"@oxc-parser/binding-linux-x64-gnu": "0.54.0",
|
|
33
|
+
"@oxc-parser/binding-linux-arm64-gnu": "0.54.0",
|
|
34
|
+
"@oxc-parser/binding-linux-x64-musl": "0.54.0",
|
|
35
|
+
"@oxc-parser/binding-linux-arm64-musl": "0.54.0",
|
|
36
|
+
"@oxc-parser/binding-darwin-x64": "0.54.0",
|
|
37
|
+
"@oxc-parser/binding-darwin-arm64": "0.54.0"
|
|
38
38
|
}
|
|
39
39
|
}
|