oxc-parser 0.93.0 → 0.95.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oxc-parser",
3
- "version": "0.93.0",
3
+ "version": "0.95.0",
4
4
  "type": "module",
5
5
  "main": "src-js/index.js",
6
6
  "browser": "src-js/wasm.js",
@@ -28,11 +28,13 @@
28
28
  "generated/constants.js",
29
29
  "generated/deserialize/js.js",
30
30
  "generated/deserialize/ts.js",
31
+ "generated/deserialize/js_range.js",
32
+ "generated/deserialize/ts_range.js",
31
33
  "generated/lazy/constructors.js",
32
- "generated/lazy/types.js",
34
+ "generated/lazy/type_ids.js",
33
35
  "generated/lazy/walk.js",
34
36
  "generated/visit/keys.js",
35
- "generated/visit/types.js",
37
+ "generated/visit/type_ids.js",
36
38
  "generated/visit/visitor.d.ts",
37
39
  "generated/visit/walk.js",
38
40
  "src-js/bindings.js",
@@ -56,17 +58,17 @@
56
58
  "access": "public"
57
59
  },
58
60
  "dependencies": {
59
- "@oxc-project/types": "^0.93.0"
61
+ "@oxc-project/types": "^0.95.0"
60
62
  },
61
63
  "devDependencies": {
62
- "@codspeed/vitest-plugin": "^4.0.0",
63
- "@napi-rs/wasm-runtime": "1.0.5",
64
+ "@codspeed/vitest-plugin": "^5.0.0",
65
+ "@napi-rs/wasm-runtime": "1.0.7",
64
66
  "@typescript-eslint/visitor-keys": "^8.44.0",
65
67
  "@vitest/browser": "3.2.4",
66
68
  "esbuild": "^0.25.0",
67
69
  "playwright": "^1.51.0",
68
70
  "tinypool": "^2.0.0",
69
- "typescript": "5.9.2",
71
+ "typescript": "5.9.3",
70
72
  "vitest": "3.2.4"
71
73
  },
72
74
  "napi": {
@@ -97,21 +99,21 @@
97
99
  "dtsHeaderFile": "src-js/header.d.ts"
98
100
  },
99
101
  "optionalDependencies": {
100
- "@oxc-parser/binding-win32-x64-msvc": "0.93.0",
101
- "@oxc-parser/binding-win32-arm64-msvc": "0.93.0",
102
- "@oxc-parser/binding-linux-x64-gnu": "0.93.0",
103
- "@oxc-parser/binding-linux-x64-musl": "0.93.0",
104
- "@oxc-parser/binding-freebsd-x64": "0.93.0",
105
- "@oxc-parser/binding-linux-arm64-gnu": "0.93.0",
106
- "@oxc-parser/binding-linux-arm64-musl": "0.93.0",
107
- "@oxc-parser/binding-linux-arm-gnueabihf": "0.93.0",
108
- "@oxc-parser/binding-linux-arm-musleabihf": "0.93.0",
109
- "@oxc-parser/binding-linux-s390x-gnu": "0.93.0",
110
- "@oxc-parser/binding-linux-riscv64-gnu": "0.93.0",
111
- "@oxc-parser/binding-darwin-x64": "0.93.0",
112
- "@oxc-parser/binding-darwin-arm64": "0.93.0",
113
- "@oxc-parser/binding-android-arm64": "0.93.0",
114
- "@oxc-parser/binding-wasm32-wasi": "0.93.0"
102
+ "@oxc-parser/binding-win32-x64-msvc": "0.95.0",
103
+ "@oxc-parser/binding-win32-arm64-msvc": "0.95.0",
104
+ "@oxc-parser/binding-linux-x64-gnu": "0.95.0",
105
+ "@oxc-parser/binding-linux-x64-musl": "0.95.0",
106
+ "@oxc-parser/binding-freebsd-x64": "0.95.0",
107
+ "@oxc-parser/binding-linux-arm64-gnu": "0.95.0",
108
+ "@oxc-parser/binding-linux-arm64-musl": "0.95.0",
109
+ "@oxc-parser/binding-linux-arm-gnueabihf": "0.95.0",
110
+ "@oxc-parser/binding-linux-arm-musleabihf": "0.95.0",
111
+ "@oxc-parser/binding-linux-s390x-gnu": "0.95.0",
112
+ "@oxc-parser/binding-linux-riscv64-gnu": "0.95.0",
113
+ "@oxc-parser/binding-darwin-x64": "0.95.0",
114
+ "@oxc-parser/binding-darwin-arm64": "0.95.0",
115
+ "@oxc-parser/binding-android-arm64": "0.95.0",
116
+ "@oxc-parser/binding-wasm32-wasi": "0.95.0"
115
117
  },
116
118
  "scripts": {
117
119
  "build-dev": "napi build --esm --platform --js bindings.js --dts index.d.ts --output-dir src-js",
@@ -81,8 +81,8 @@ function requireNative() {
81
81
  try {
82
82
  const binding = require('@oxc-parser/binding-android-arm64')
83
83
  const bindingPackageVersion = require('@oxc-parser/binding-android-arm64/package.json').version
84
- if (bindingPackageVersion !== '0.93.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
85
- throw new Error(`Native binding package version mismatch, expected 0.93.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
84
+ if (bindingPackageVersion !== '0.95.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
85
+ throw new Error(`Native binding package version mismatch, expected 0.95.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
86
86
  }
87
87
  return binding
88
88
  } catch (e) {
@@ -97,8 +97,8 @@ function requireNative() {
97
97
  try {
98
98
  const binding = require('@oxc-parser/binding-android-arm-eabi')
99
99
  const bindingPackageVersion = require('@oxc-parser/binding-android-arm-eabi/package.json').version
100
- if (bindingPackageVersion !== '0.93.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
101
- throw new Error(`Native binding package version mismatch, expected 0.93.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
100
+ if (bindingPackageVersion !== '0.95.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
101
+ throw new Error(`Native binding package version mismatch, expected 0.95.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
102
102
  }
103
103
  return binding
104
104
  } catch (e) {
@@ -109,7 +109,24 @@ function requireNative() {
109
109
  }
110
110
  } else if (process.platform === 'win32') {
111
111
  if (process.arch === 'x64') {
112
+ if (process.report?.getReport?.()?.header?.osName?.startsWith?.('MINGW')) {
113
+ try {
114
+ return require('./parser.win32-x64-gnu.node')
115
+ } catch (e) {
116
+ loadErrors.push(e)
117
+ }
112
118
  try {
119
+ const binding = require('@oxc-parser/binding-win32-x64-gnu')
120
+ const bindingPackageVersion = require('@oxc-parser/binding-win32-x64-gnu/package.json').version
121
+ if (bindingPackageVersion !== '0.95.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
122
+ throw new Error(`Native binding package version mismatch, expected 0.95.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
123
+ }
124
+ return binding
125
+ } catch (e) {
126
+ loadErrors.push(e)
127
+ }
128
+ } else {
129
+ try {
113
130
  return require('./parser.win32-x64-msvc.node')
114
131
  } catch (e) {
115
132
  loadErrors.push(e)
@@ -117,13 +134,14 @@ function requireNative() {
117
134
  try {
118
135
  const binding = require('@oxc-parser/binding-win32-x64-msvc')
119
136
  const bindingPackageVersion = require('@oxc-parser/binding-win32-x64-msvc/package.json').version
120
- if (bindingPackageVersion !== '0.93.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
121
- throw new Error(`Native binding package version mismatch, expected 0.93.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
137
+ if (bindingPackageVersion !== '0.95.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
138
+ throw new Error(`Native binding package version mismatch, expected 0.95.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
122
139
  }
123
140
  return binding
124
141
  } catch (e) {
125
142
  loadErrors.push(e)
126
143
  }
144
+ }
127
145
  } else if (process.arch === 'ia32') {
128
146
  try {
129
147
  return require('./parser.win32-ia32-msvc.node')
@@ -133,8 +151,8 @@ function requireNative() {
133
151
  try {
134
152
  const binding = require('@oxc-parser/binding-win32-ia32-msvc')
135
153
  const bindingPackageVersion = require('@oxc-parser/binding-win32-ia32-msvc/package.json').version
136
- if (bindingPackageVersion !== '0.93.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
137
- throw new Error(`Native binding package version mismatch, expected 0.93.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
154
+ if (bindingPackageVersion !== '0.95.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
155
+ throw new Error(`Native binding package version mismatch, expected 0.95.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
138
156
  }
139
157
  return binding
140
158
  } catch (e) {
@@ -149,8 +167,8 @@ function requireNative() {
149
167
  try {
150
168
  const binding = require('@oxc-parser/binding-win32-arm64-msvc')
151
169
  const bindingPackageVersion = require('@oxc-parser/binding-win32-arm64-msvc/package.json').version
152
- if (bindingPackageVersion !== '0.93.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
153
- throw new Error(`Native binding package version mismatch, expected 0.93.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
170
+ if (bindingPackageVersion !== '0.95.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
171
+ throw new Error(`Native binding package version mismatch, expected 0.95.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
154
172
  }
155
173
  return binding
156
174
  } catch (e) {
@@ -168,8 +186,8 @@ function requireNative() {
168
186
  try {
169
187
  const binding = require('@oxc-parser/binding-darwin-universal')
170
188
  const bindingPackageVersion = require('@oxc-parser/binding-darwin-universal/package.json').version
171
- if (bindingPackageVersion !== '0.93.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
172
- throw new Error(`Native binding package version mismatch, expected 0.93.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
189
+ if (bindingPackageVersion !== '0.95.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
190
+ throw new Error(`Native binding package version mismatch, expected 0.95.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
173
191
  }
174
192
  return binding
175
193
  } catch (e) {
@@ -184,8 +202,8 @@ function requireNative() {
184
202
  try {
185
203
  const binding = require('@oxc-parser/binding-darwin-x64')
186
204
  const bindingPackageVersion = require('@oxc-parser/binding-darwin-x64/package.json').version
187
- if (bindingPackageVersion !== '0.93.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
188
- throw new Error(`Native binding package version mismatch, expected 0.93.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
205
+ if (bindingPackageVersion !== '0.95.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
206
+ throw new Error(`Native binding package version mismatch, expected 0.95.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
189
207
  }
190
208
  return binding
191
209
  } catch (e) {
@@ -200,8 +218,8 @@ function requireNative() {
200
218
  try {
201
219
  const binding = require('@oxc-parser/binding-darwin-arm64')
202
220
  const bindingPackageVersion = require('@oxc-parser/binding-darwin-arm64/package.json').version
203
- if (bindingPackageVersion !== '0.93.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
204
- throw new Error(`Native binding package version mismatch, expected 0.93.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
221
+ if (bindingPackageVersion !== '0.95.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
222
+ throw new Error(`Native binding package version mismatch, expected 0.95.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
205
223
  }
206
224
  return binding
207
225
  } catch (e) {
@@ -220,8 +238,8 @@ function requireNative() {
220
238
  try {
221
239
  const binding = require('@oxc-parser/binding-freebsd-x64')
222
240
  const bindingPackageVersion = require('@oxc-parser/binding-freebsd-x64/package.json').version
223
- if (bindingPackageVersion !== '0.93.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
224
- throw new Error(`Native binding package version mismatch, expected 0.93.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
241
+ if (bindingPackageVersion !== '0.95.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
242
+ throw new Error(`Native binding package version mismatch, expected 0.95.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
225
243
  }
226
244
  return binding
227
245
  } catch (e) {
@@ -236,8 +254,8 @@ function requireNative() {
236
254
  try {
237
255
  const binding = require('@oxc-parser/binding-freebsd-arm64')
238
256
  const bindingPackageVersion = require('@oxc-parser/binding-freebsd-arm64/package.json').version
239
- if (bindingPackageVersion !== '0.93.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
240
- throw new Error(`Native binding package version mismatch, expected 0.93.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
257
+ if (bindingPackageVersion !== '0.95.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
258
+ throw new Error(`Native binding package version mismatch, expected 0.95.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
241
259
  }
242
260
  return binding
243
261
  } catch (e) {
@@ -257,8 +275,8 @@ function requireNative() {
257
275
  try {
258
276
  const binding = require('@oxc-parser/binding-linux-x64-musl')
259
277
  const bindingPackageVersion = require('@oxc-parser/binding-linux-x64-musl/package.json').version
260
- if (bindingPackageVersion !== '0.93.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
261
- throw new Error(`Native binding package version mismatch, expected 0.93.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
278
+ if (bindingPackageVersion !== '0.95.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
279
+ throw new Error(`Native binding package version mismatch, expected 0.95.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
262
280
  }
263
281
  return binding
264
282
  } catch (e) {
@@ -273,8 +291,8 @@ function requireNative() {
273
291
  try {
274
292
  const binding = require('@oxc-parser/binding-linux-x64-gnu')
275
293
  const bindingPackageVersion = require('@oxc-parser/binding-linux-x64-gnu/package.json').version
276
- if (bindingPackageVersion !== '0.93.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
277
- throw new Error(`Native binding package version mismatch, expected 0.93.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
294
+ if (bindingPackageVersion !== '0.95.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
295
+ throw new Error(`Native binding package version mismatch, expected 0.95.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
278
296
  }
279
297
  return binding
280
298
  } catch (e) {
@@ -291,8 +309,8 @@ function requireNative() {
291
309
  try {
292
310
  const binding = require('@oxc-parser/binding-linux-arm64-musl')
293
311
  const bindingPackageVersion = require('@oxc-parser/binding-linux-arm64-musl/package.json').version
294
- if (bindingPackageVersion !== '0.93.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
295
- throw new Error(`Native binding package version mismatch, expected 0.93.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
312
+ if (bindingPackageVersion !== '0.95.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
313
+ throw new Error(`Native binding package version mismatch, expected 0.95.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
296
314
  }
297
315
  return binding
298
316
  } catch (e) {
@@ -307,8 +325,8 @@ function requireNative() {
307
325
  try {
308
326
  const binding = require('@oxc-parser/binding-linux-arm64-gnu')
309
327
  const bindingPackageVersion = require('@oxc-parser/binding-linux-arm64-gnu/package.json').version
310
- if (bindingPackageVersion !== '0.93.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
311
- throw new Error(`Native binding package version mismatch, expected 0.93.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
328
+ if (bindingPackageVersion !== '0.95.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
329
+ throw new Error(`Native binding package version mismatch, expected 0.95.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
312
330
  }
313
331
  return binding
314
332
  } catch (e) {
@@ -325,8 +343,8 @@ function requireNative() {
325
343
  try {
326
344
  const binding = require('@oxc-parser/binding-linux-arm-musleabihf')
327
345
  const bindingPackageVersion = require('@oxc-parser/binding-linux-arm-musleabihf/package.json').version
328
- if (bindingPackageVersion !== '0.93.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
329
- throw new Error(`Native binding package version mismatch, expected 0.93.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
346
+ if (bindingPackageVersion !== '0.95.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
347
+ throw new Error(`Native binding package version mismatch, expected 0.95.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
330
348
  }
331
349
  return binding
332
350
  } catch (e) {
@@ -341,8 +359,8 @@ function requireNative() {
341
359
  try {
342
360
  const binding = require('@oxc-parser/binding-linux-arm-gnueabihf')
343
361
  const bindingPackageVersion = require('@oxc-parser/binding-linux-arm-gnueabihf/package.json').version
344
- if (bindingPackageVersion !== '0.93.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
345
- throw new Error(`Native binding package version mismatch, expected 0.93.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
362
+ if (bindingPackageVersion !== '0.95.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
363
+ throw new Error(`Native binding package version mismatch, expected 0.95.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
346
364
  }
347
365
  return binding
348
366
  } catch (e) {
@@ -359,8 +377,8 @@ function requireNative() {
359
377
  try {
360
378
  const binding = require('@oxc-parser/binding-linux-loong64-musl')
361
379
  const bindingPackageVersion = require('@oxc-parser/binding-linux-loong64-musl/package.json').version
362
- if (bindingPackageVersion !== '0.93.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
363
- throw new Error(`Native binding package version mismatch, expected 0.93.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
380
+ if (bindingPackageVersion !== '0.95.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
381
+ throw new Error(`Native binding package version mismatch, expected 0.95.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
364
382
  }
365
383
  return binding
366
384
  } catch (e) {
@@ -375,8 +393,8 @@ function requireNative() {
375
393
  try {
376
394
  const binding = require('@oxc-parser/binding-linux-loong64-gnu')
377
395
  const bindingPackageVersion = require('@oxc-parser/binding-linux-loong64-gnu/package.json').version
378
- if (bindingPackageVersion !== '0.93.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
379
- throw new Error(`Native binding package version mismatch, expected 0.93.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
396
+ if (bindingPackageVersion !== '0.95.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
397
+ throw new Error(`Native binding package version mismatch, expected 0.95.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
380
398
  }
381
399
  return binding
382
400
  } catch (e) {
@@ -393,8 +411,8 @@ function requireNative() {
393
411
  try {
394
412
  const binding = require('@oxc-parser/binding-linux-riscv64-musl')
395
413
  const bindingPackageVersion = require('@oxc-parser/binding-linux-riscv64-musl/package.json').version
396
- if (bindingPackageVersion !== '0.93.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
397
- throw new Error(`Native binding package version mismatch, expected 0.93.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
414
+ if (bindingPackageVersion !== '0.95.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
415
+ throw new Error(`Native binding package version mismatch, expected 0.95.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
398
416
  }
399
417
  return binding
400
418
  } catch (e) {
@@ -409,8 +427,8 @@ function requireNative() {
409
427
  try {
410
428
  const binding = require('@oxc-parser/binding-linux-riscv64-gnu')
411
429
  const bindingPackageVersion = require('@oxc-parser/binding-linux-riscv64-gnu/package.json').version
412
- if (bindingPackageVersion !== '0.93.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
413
- throw new Error(`Native binding package version mismatch, expected 0.93.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
430
+ if (bindingPackageVersion !== '0.95.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
431
+ throw new Error(`Native binding package version mismatch, expected 0.95.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
414
432
  }
415
433
  return binding
416
434
  } catch (e) {
@@ -426,8 +444,8 @@ function requireNative() {
426
444
  try {
427
445
  const binding = require('@oxc-parser/binding-linux-ppc64-gnu')
428
446
  const bindingPackageVersion = require('@oxc-parser/binding-linux-ppc64-gnu/package.json').version
429
- if (bindingPackageVersion !== '0.93.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
430
- throw new Error(`Native binding package version mismatch, expected 0.93.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
447
+ if (bindingPackageVersion !== '0.95.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
448
+ throw new Error(`Native binding package version mismatch, expected 0.95.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
431
449
  }
432
450
  return binding
433
451
  } catch (e) {
@@ -442,8 +460,8 @@ function requireNative() {
442
460
  try {
443
461
  const binding = require('@oxc-parser/binding-linux-s390x-gnu')
444
462
  const bindingPackageVersion = require('@oxc-parser/binding-linux-s390x-gnu/package.json').version
445
- if (bindingPackageVersion !== '0.93.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
446
- throw new Error(`Native binding package version mismatch, expected 0.93.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
463
+ if (bindingPackageVersion !== '0.95.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
464
+ throw new Error(`Native binding package version mismatch, expected 0.95.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
447
465
  }
448
466
  return binding
449
467
  } catch (e) {
@@ -462,8 +480,8 @@ function requireNative() {
462
480
  try {
463
481
  const binding = require('@oxc-parser/binding-openharmony-arm64')
464
482
  const bindingPackageVersion = require('@oxc-parser/binding-openharmony-arm64/package.json').version
465
- if (bindingPackageVersion !== '0.93.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
466
- throw new Error(`Native binding package version mismatch, expected 0.93.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
483
+ if (bindingPackageVersion !== '0.95.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
484
+ throw new Error(`Native binding package version mismatch, expected 0.95.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
467
485
  }
468
486
  return binding
469
487
  } catch (e) {
@@ -478,8 +496,8 @@ function requireNative() {
478
496
  try {
479
497
  const binding = require('@oxc-parser/binding-openharmony-x64')
480
498
  const bindingPackageVersion = require('@oxc-parser/binding-openharmony-x64/package.json').version
481
- if (bindingPackageVersion !== '0.93.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
482
- throw new Error(`Native binding package version mismatch, expected 0.93.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
499
+ if (bindingPackageVersion !== '0.95.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
500
+ throw new Error(`Native binding package version mismatch, expected 0.95.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
483
501
  }
484
502
  return binding
485
503
  } catch (e) {
@@ -494,8 +512,8 @@ function requireNative() {
494
512
  try {
495
513
  const binding = require('@oxc-parser/binding-openharmony-arm')
496
514
  const bindingPackageVersion = require('@oxc-parser/binding-openharmony-arm/package.json').version
497
- if (bindingPackageVersion !== '0.93.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
498
- throw new Error(`Native binding package version mismatch, expected 0.93.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
515
+ if (bindingPackageVersion !== '0.95.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
516
+ throw new Error(`Native binding package version mismatch, expected 0.95.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
499
517
  }
500
518
  return binding
501
519
  } catch (e) {
@@ -28,14 +28,14 @@ if (!rawTransferSupported()) {
28
28
  *
29
29
  * @param {string} filename - Filename
30
30
  * @param {string} sourceText - Source text of file
31
- * @param {Object|undefined} options - Parsing options
31
+ * @param {Object} options - Parsing options
32
32
  * @param {function} convert - Function to convert the buffer returned from Rust into a JS object
33
33
  * @returns {Object} - The return value of `convert`
34
34
  */
35
35
  export function parseSyncRawImpl(filename, sourceText, options, convert) {
36
36
  const { buffer, sourceByteLen } = prepareRaw(sourceText);
37
37
  parseSyncRawBinding(filename, buffer, sourceByteLen, options);
38
- return convert(buffer, sourceText, sourceByteLen);
38
+ return convert(buffer, sourceText, sourceByteLen, options);
39
39
  }
40
40
 
41
41
  // User should not schedule more async tasks than there are available CPUs, as it hurts performance,
@@ -87,7 +87,7 @@ const queue = [];
87
87
  *
88
88
  * @param {string} filename - Filename
89
89
  * @param {string} sourceText - Source text of file
90
- * @param {Object|undefined} options - Parsing options
90
+ * @param {Object} options - Parsing options
91
91
  * @param {function} convert - Function to convert the buffer returned from Rust into a JS object
92
92
  * @returns {Object} - The return value of `convert`
93
93
  */
@@ -115,7 +115,7 @@ export async function parseAsyncRawImpl(filename, sourceText, options, convert)
115
115
  // Parse
116
116
  const { buffer, sourceByteLen } = prepareRaw(sourceText);
117
117
  await parseAsyncRawBinding(filename, buffer, sourceByteLen, options);
118
- const data = convert(buffer, sourceText, sourceByteLen);
118
+ const data = convert(buffer, sourceText, sourceByteLen, options);
119
119
 
120
120
  // Free the CPU core
121
121
  if (queue.length > 0) {
@@ -41,7 +41,20 @@ export function parseAsyncRaw(filename, sourceText, options) {
41
41
  return parseAsyncRawImpl(filename, sourceText, options, deserialize);
42
42
  }
43
43
 
44
- let deserializeJS = null, deserializeTS = null;
44
+ // Deserializers are large files, so lazy-loaded.
45
+ // `deserialize` functions are stored in this array once loaded.
46
+ // Index into these arrays is `isJs * 1 + range * 2 + experimentalParent * 4`.
47
+ const deserializers = [null, null, null, null, null, null, null, null];
48
+ const deserializerNames = [
49
+ 'ts',
50
+ 'js',
51
+ 'ts_range',
52
+ 'js_range',
53
+ 'ts_parent',
54
+ 'js_parent',
55
+ 'ts_range_parent',
56
+ 'js_range_parent',
57
+ ];
45
58
 
46
59
  /**
47
60
  * Deserialize whole AST from buffer.
@@ -49,32 +62,37 @@ let deserializeJS = null, deserializeTS = null;
49
62
  * @param {Uint8Array} buffer - Buffer containing AST in raw form
50
63
  * @param {string} sourceText - Source for the file
51
64
  * @param {number} sourceByteLen - Length of source text in UTF-8 bytes
65
+ * @param {Object} options - Parsing options
52
66
  * @returns {Object} - Object with property getters for `program`, `module`, `comments`, and `errors`
53
67
  */
54
- function deserialize(buffer, sourceText, sourceByteLen) {
68
+ function deserialize(buffer, sourceText, sourceByteLen, options) {
69
+ const isJs = isJsAst(buffer),
70
+ range = !!options.range,
71
+ parent = !!options.experimentalParent;
72
+
55
73
  // Lazy load deserializer, and deserialize buffer to JS objects
56
- let data;
57
- if (isJsAst(buffer)) {
58
- if (deserializeJS === null) deserializeJS = require('../../generated/deserialize/js.js').deserialize;
74
+ const deserializerIndex = (+isJs) | ((+range) << 1) | ((+parent) << 2);
75
+ let deserializeThis = deserializers[deserializerIndex];
76
+ if (deserializeThis === null) {
77
+ deserializeThis = deserializers[deserializerIndex] = require(
78
+ `../../generated/deserialize/${deserializerNames[deserializerIndex]}.js`,
79
+ ).deserialize;
80
+ }
59
81
 
60
- // `preserveParens` argument is unconditionally `true` here. If `options` contains `preserveParens: false`,
61
- // `ParenthesizedExpression` nodes won't be in AST anyway, so the value is irrelevant.
62
- data = deserializeJS(buffer, sourceText, sourceByteLen, true);
82
+ const data = deserializeThis(buffer, sourceText, sourceByteLen);
63
83
 
64
- // Add a line comment for hashbang
84
+ // Add a line comment for hashbang if JS.
85
+ // Do not add comment if TS, to match `@typescript-eslint/parser`.
86
+ // See https://github.com/oxc-project/oxc/blob/ea784f5f082e4c53c98afde9bf983afd0b95e44e/napi/parser/src/lib.rs#L106-L130
87
+ if (isJs) {
65
88
  const { hashbang } = data.program;
66
89
  if (hashbang !== null) {
67
- data.comments.unshift({ type: 'Line', value: hashbang.value, start: hashbang.start, end: hashbang.end });
90
+ data.comments.unshift(
91
+ range
92
+ ? { type: 'Line', value: hashbang.value, start: hashbang.start, end: hashbang.end, range: hashbang.range }
93
+ : { type: 'Line', value: hashbang.value, start: hashbang.start, end: hashbang.end },
94
+ );
68
95
  }
69
- } else {
70
- if (deserializeTS === null) deserializeTS = require('../../generated/deserialize/ts.js').deserialize;
71
-
72
- // `preserveParens` argument is unconditionally `true` here. If `options` contains `preserveParens: false`,
73
- // `ParenthesizedExpression` nodes won't be in AST anyway, so the value is irrelevant.
74
- data = deserializeTS(buffer, sourceText, sourceByteLen, true);
75
-
76
- // Note: Do not add line comment for hashbang, to match `@typescript-eslint/parser`.
77
- // See https://github.com/oxc-project/oxc/blob/ea784f5f082e4c53c98afde9bf983afd0b95e44e/napi/parser/src/lib.rs#L106-L130
78
96
  }
79
97
 
80
98
  // Return buffer to cache, to be reused
@@ -87,10 +87,11 @@ const bufferRecycleRegistry = typeof FinalizationRegistry === 'undefined'
87
87
  * @param {Uint8Array} buffer - Buffer containing AST in raw form
88
88
  * @param {string} sourceText - Source for the file
89
89
  * @param {number} sourceByteLen - Length of source text in UTF-8 bytes
90
+ * @param {Object} _options - Parsing options
90
91
  * @returns {Object} - Object with property getters for `program`, `module`, `comments`, and `errors`,
91
92
  * and `dispose` and `visit` methods
92
93
  */
93
- function construct(buffer, sourceText, sourceByteLen) {
94
+ function construct(buffer, sourceText, sourceByteLen, _options) {
94
95
  // Create AST object
95
96
  const sourceIsAscii = sourceText.length === sourceByteLen;
96
97
  const ast = { buffer, sourceText, sourceByteLen, sourceIsAscii, nodes: new Map(), token: TOKEN };
@@ -149,6 +149,7 @@ export class NodeArray extends Array {
149
149
  }
150
150
  }
151
151
 
152
+ // oxlint-disable-next-line typescript/unbound-method
152
153
  NodeArray.prototype[Symbol.iterator] = NodeArray.prototype.values;
153
154
 
154
155
  /**
@@ -1,4 +1,4 @@
1
- import { LEAF_NODE_TYPES_COUNT, NODE_TYPE_IDS_MAP, NODE_TYPES_COUNT } from '../../generated/lazy/types.js';
1
+ import { LEAF_NODE_TYPES_COUNT, NODE_TYPE_IDS_MAP, NODE_TYPES_COUNT } from '../../generated/lazy/type_ids.js';
2
2
 
3
3
  // Getter for private `#visitorsArr` property of `Visitor` class. Initialized in class body below.
4
4
  let getVisitorsArrTemp;
@@ -72,9 +72,7 @@
72
72
  // for objects created by user code in visitors. If ephemeral user-created objects all fit in new space,
73
73
  // it will avoid full GC runs, which should greatly improve performance.
74
74
 
75
- // TODO(camc314): we need to generate `.d.ts` file for this module.
76
- // @ts-expect-error
77
- import { LEAF_NODE_TYPES_COUNT, NODE_TYPE_IDS_MAP, NODE_TYPES_COUNT } from '../../generated/visit/types.js';
75
+ import { LEAF_NODE_TYPES_COUNT, NODE_TYPE_IDS_MAP, NODE_TYPES_COUNT } from '../../generated/visit/type_ids.js';
78
76
 
79
77
  const { isArray } = Array;
80
78
 
@@ -370,6 +368,7 @@ function createMerger(fnCount) {
370
368
  }
371
369
  body += '}';
372
370
  args.push(body);
371
+ // oxlint-disable-next-line typescript/no-implied-eval
373
372
  return new Function(...args);
374
373
  }
375
374
 
File without changes
File without changes