oxc-parser 0.49.0 → 0.50.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.
Files changed (3) hide show
  1. package/index.d.ts +5 -0
  2. package/index.js +20 -1
  3. package/package.json +10 -10
package/index.d.ts CHANGED
@@ -198,6 +198,11 @@ export interface ParserOptions {
198
198
  * Default: true
199
199
  */
200
200
  preserveParens?: boolean
201
+ /**
202
+ * Default: false
203
+ * @experimental Only for internal usage on Rolldown and Vite.
204
+ */
205
+ convertSpanUtf16?: boolean
201
206
  }
202
207
 
203
208
  /** Parse synchronously. */
package/index.js CHANGED
@@ -12,7 +12,26 @@ function wrap(result) {
12
12
  let program, module, comments, errors, magicString;
13
13
  return {
14
14
  get program() {
15
- if (!program) program = JSON.parse(result.program);
15
+ if (!program) {
16
+ program = JSON.parse(result.program, function(key, value) {
17
+ // Set `value` field of `Literal`s for `BigInt`s and `RegExp`s.
18
+ // This is not possible to do on Rust side, as neither can be represented correctly in JSON.
19
+ if (value === null && key === 'value' && Object.hasOwn(this, 'type') && this.type === 'Literal') {
20
+ if (Object.hasOwn(this, 'bigint')) {
21
+ return BigInt(this.bigint);
22
+ }
23
+ if (Object.hasOwn(this, 'regex')) {
24
+ const { regex } = this;
25
+ try {
26
+ return RegExp(regex.pattern, regex.flags);
27
+ } catch (_err) {
28
+ // Invalid regexp, or valid regexp using syntax not supported by this version of NodeJS
29
+ }
30
+ }
31
+ }
32
+ return value;
33
+ });
34
+ }
16
35
  return program;
17
36
  },
18
37
  get module() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oxc-parser",
3
- "version": "0.49.0",
3
+ "version": "0.50.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.49.0"
27
+ "@oxc-project/types": "^0.50.0"
28
28
  },
29
29
  "optionalDependencies": {
30
- "@oxc-parser/binding-win32-x64-msvc": "0.49.0",
31
- "@oxc-parser/binding-win32-arm64-msvc": "0.49.0",
32
- "@oxc-parser/binding-linux-x64-gnu": "0.49.0",
33
- "@oxc-parser/binding-linux-arm64-gnu": "0.49.0",
34
- "@oxc-parser/binding-linux-x64-musl": "0.49.0",
35
- "@oxc-parser/binding-linux-arm64-musl": "0.49.0",
36
- "@oxc-parser/binding-darwin-x64": "0.49.0",
37
- "@oxc-parser/binding-darwin-arm64": "0.49.0"
30
+ "@oxc-parser/binding-win32-x64-msvc": "0.50.0",
31
+ "@oxc-parser/binding-win32-arm64-msvc": "0.50.0",
32
+ "@oxc-parser/binding-linux-x64-gnu": "0.50.0",
33
+ "@oxc-parser/binding-linux-arm64-gnu": "0.50.0",
34
+ "@oxc-parser/binding-linux-x64-musl": "0.50.0",
35
+ "@oxc-parser/binding-linux-arm64-musl": "0.50.0",
36
+ "@oxc-parser/binding-darwin-x64": "0.50.0",
37
+ "@oxc-parser/binding-darwin-arm64": "0.50.0"
38
38
  }
39
39
  }