@nubjs/nub-win32-x64 0.0.3 → 0.0.5
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/bin/nub.exe +0 -0
- package/package.json +1 -1
- package/runtime/addons/nub-native.node +0 -0
- package/runtime/node_modules/@oxc-transform/binding-win32-x64-msvc/README.md +3 -0
- package/runtime/node_modules/@oxc-transform/binding-win32-x64-msvc/package.json +41 -0
- package/runtime/node_modules/@oxc-transform/binding-win32-x64-msvc/transform.win32-x64-msvc.node +0 -0
- package/runtime/node_modules/oxc-transform/index.d.ts +12 -0
- package/runtime/node_modules/oxc-transform/index.js +52 -52
- package/runtime/node_modules/oxc-transform/package.json +22 -22
- package/runtime/node_modules/resolve-pkg-maps/LICENSE +21 -0
- package/runtime/node_modules/resolve-pkg-maps/README.md +216 -0
- package/runtime/node_modules/resolve-pkg-maps/dist/index.cjs +1 -0
- package/runtime/node_modules/resolve-pkg-maps/dist/index.d.cts +11 -0
- package/runtime/node_modules/resolve-pkg-maps/dist/index.d.mts +11 -0
- package/runtime/node_modules/resolve-pkg-maps/dist/index.mjs +1 -0
- package/runtime/node_modules/resolve-pkg-maps/package.json +42 -0
package/bin/nub.exe
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
Binary file
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@oxc-transform/binding-win32-x64-msvc",
|
|
3
|
+
"version": "0.133.0",
|
|
4
|
+
"cpu": [
|
|
5
|
+
"x64"
|
|
6
|
+
],
|
|
7
|
+
"main": "transform.win32-x64-msvc.node",
|
|
8
|
+
"files": [
|
|
9
|
+
"transform.win32-x64-msvc.node"
|
|
10
|
+
],
|
|
11
|
+
"description": "Oxc Transformer Node API",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"babel",
|
|
14
|
+
"javascript",
|
|
15
|
+
"jsx",
|
|
16
|
+
"oxc",
|
|
17
|
+
"transform",
|
|
18
|
+
"transformer",
|
|
19
|
+
"tsx",
|
|
20
|
+
"typescript"
|
|
21
|
+
],
|
|
22
|
+
"author": "Boshen and oxc contributors",
|
|
23
|
+
"homepage": "https://oxc.rs/docs/guide/usage/transformer",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
27
|
+
},
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+https://github.com/oxc-project/oxc.git",
|
|
31
|
+
"directory": "napi/transform"
|
|
32
|
+
},
|
|
33
|
+
"bugs": "https://github.com/oxc-project/oxc/issues",
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"registry": "https://registry.npmjs.org/",
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"os": [
|
|
39
|
+
"win32"
|
|
40
|
+
]
|
|
41
|
+
}
|
package/runtime/node_modules/@oxc-transform/binding-win32-x64-msvc/transform.win32-x64-msvc.node
ADDED
|
Binary file
|
|
@@ -118,6 +118,18 @@ export interface DecoratorOptions {
|
|
|
118
118
|
* @default false
|
|
119
119
|
*/
|
|
120
120
|
emitDecoratorMetadata?: boolean
|
|
121
|
+
/**
|
|
122
|
+
* Aligns nullable-union `design:type` emission with `--strictNullChecks`.
|
|
123
|
+
*
|
|
124
|
+
* When `true` (default), `T | null` and `T | undefined` emit `Object`, matching tsc strict.
|
|
125
|
+
* When `false`, `null` and `undefined` are elided from the union so the underlying
|
|
126
|
+
* primitive constructor is emitted, matching tsc with `--strictNullChecks=false`
|
|
127
|
+
* and `babel-plugin-transform-typescript-metadata`.
|
|
128
|
+
*
|
|
129
|
+
* @see https://www.typescriptlang.org/tsconfig/#strictNullChecks
|
|
130
|
+
* @default true
|
|
131
|
+
*/
|
|
132
|
+
strictNullChecks?: boolean
|
|
121
133
|
}
|
|
122
134
|
|
|
123
135
|
export interface Es2015Options {
|
|
@@ -81,8 +81,8 @@ function requireNative() {
|
|
|
81
81
|
try {
|
|
82
82
|
const binding = require('@oxc-transform/binding-android-arm64')
|
|
83
83
|
const bindingPackageVersion = require('@oxc-transform/binding-android-arm64/package.json').version
|
|
84
|
-
if (bindingPackageVersion !== '0.
|
|
85
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
84
|
+
if (bindingPackageVersion !== '0.133.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.133.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-transform/binding-android-arm-eabi')
|
|
99
99
|
const bindingPackageVersion = require('@oxc-transform/binding-android-arm-eabi/package.json').version
|
|
100
|
-
if (bindingPackageVersion !== '0.
|
|
101
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
100
|
+
if (bindingPackageVersion !== '0.133.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.133.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
102
102
|
}
|
|
103
103
|
return binding
|
|
104
104
|
} catch (e) {
|
|
@@ -118,8 +118,8 @@ function requireNative() {
|
|
|
118
118
|
try {
|
|
119
119
|
const binding = require('@oxc-transform/binding-win32-x64-gnu')
|
|
120
120
|
const bindingPackageVersion = require('@oxc-transform/binding-win32-x64-gnu/package.json').version
|
|
121
|
-
if (bindingPackageVersion !== '0.
|
|
122
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
121
|
+
if (bindingPackageVersion !== '0.133.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.133.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
123
123
|
}
|
|
124
124
|
return binding
|
|
125
125
|
} catch (e) {
|
|
@@ -134,8 +134,8 @@ function requireNative() {
|
|
|
134
134
|
try {
|
|
135
135
|
const binding = require('@oxc-transform/binding-win32-x64-msvc')
|
|
136
136
|
const bindingPackageVersion = require('@oxc-transform/binding-win32-x64-msvc/package.json').version
|
|
137
|
-
if (bindingPackageVersion !== '0.
|
|
138
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
137
|
+
if (bindingPackageVersion !== '0.133.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.133.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
139
139
|
}
|
|
140
140
|
return binding
|
|
141
141
|
} catch (e) {
|
|
@@ -151,8 +151,8 @@ function requireNative() {
|
|
|
151
151
|
try {
|
|
152
152
|
const binding = require('@oxc-transform/binding-win32-ia32-msvc')
|
|
153
153
|
const bindingPackageVersion = require('@oxc-transform/binding-win32-ia32-msvc/package.json').version
|
|
154
|
-
if (bindingPackageVersion !== '0.
|
|
155
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
154
|
+
if (bindingPackageVersion !== '0.133.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.133.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
156
156
|
}
|
|
157
157
|
return binding
|
|
158
158
|
} catch (e) {
|
|
@@ -167,8 +167,8 @@ function requireNative() {
|
|
|
167
167
|
try {
|
|
168
168
|
const binding = require('@oxc-transform/binding-win32-arm64-msvc')
|
|
169
169
|
const bindingPackageVersion = require('@oxc-transform/binding-win32-arm64-msvc/package.json').version
|
|
170
|
-
if (bindingPackageVersion !== '0.
|
|
171
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
170
|
+
if (bindingPackageVersion !== '0.133.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.133.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
172
172
|
}
|
|
173
173
|
return binding
|
|
174
174
|
} catch (e) {
|
|
@@ -186,8 +186,8 @@ function requireNative() {
|
|
|
186
186
|
try {
|
|
187
187
|
const binding = require('@oxc-transform/binding-darwin-universal')
|
|
188
188
|
const bindingPackageVersion = require('@oxc-transform/binding-darwin-universal/package.json').version
|
|
189
|
-
if (bindingPackageVersion !== '0.
|
|
190
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
189
|
+
if (bindingPackageVersion !== '0.133.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.133.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
191
191
|
}
|
|
192
192
|
return binding
|
|
193
193
|
} catch (e) {
|
|
@@ -202,8 +202,8 @@ function requireNative() {
|
|
|
202
202
|
try {
|
|
203
203
|
const binding = require('@oxc-transform/binding-darwin-x64')
|
|
204
204
|
const bindingPackageVersion = require('@oxc-transform/binding-darwin-x64/package.json').version
|
|
205
|
-
if (bindingPackageVersion !== '0.
|
|
206
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
205
|
+
if (bindingPackageVersion !== '0.133.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.133.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
207
207
|
}
|
|
208
208
|
return binding
|
|
209
209
|
} catch (e) {
|
|
@@ -218,8 +218,8 @@ function requireNative() {
|
|
|
218
218
|
try {
|
|
219
219
|
const binding = require('@oxc-transform/binding-darwin-arm64')
|
|
220
220
|
const bindingPackageVersion = require('@oxc-transform/binding-darwin-arm64/package.json').version
|
|
221
|
-
if (bindingPackageVersion !== '0.
|
|
222
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
221
|
+
if (bindingPackageVersion !== '0.133.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.133.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
223
223
|
}
|
|
224
224
|
return binding
|
|
225
225
|
} catch (e) {
|
|
@@ -238,8 +238,8 @@ function requireNative() {
|
|
|
238
238
|
try {
|
|
239
239
|
const binding = require('@oxc-transform/binding-freebsd-x64')
|
|
240
240
|
const bindingPackageVersion = require('@oxc-transform/binding-freebsd-x64/package.json').version
|
|
241
|
-
if (bindingPackageVersion !== '0.
|
|
242
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
241
|
+
if (bindingPackageVersion !== '0.133.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.133.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
243
243
|
}
|
|
244
244
|
return binding
|
|
245
245
|
} catch (e) {
|
|
@@ -254,8 +254,8 @@ function requireNative() {
|
|
|
254
254
|
try {
|
|
255
255
|
const binding = require('@oxc-transform/binding-freebsd-arm64')
|
|
256
256
|
const bindingPackageVersion = require('@oxc-transform/binding-freebsd-arm64/package.json').version
|
|
257
|
-
if (bindingPackageVersion !== '0.
|
|
258
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
257
|
+
if (bindingPackageVersion !== '0.133.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.133.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
259
259
|
}
|
|
260
260
|
return binding
|
|
261
261
|
} catch (e) {
|
|
@@ -275,8 +275,8 @@ function requireNative() {
|
|
|
275
275
|
try {
|
|
276
276
|
const binding = require('@oxc-transform/binding-linux-x64-musl')
|
|
277
277
|
const bindingPackageVersion = require('@oxc-transform/binding-linux-x64-musl/package.json').version
|
|
278
|
-
if (bindingPackageVersion !== '0.
|
|
279
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
278
|
+
if (bindingPackageVersion !== '0.133.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.133.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
280
280
|
}
|
|
281
281
|
return binding
|
|
282
282
|
} catch (e) {
|
|
@@ -291,8 +291,8 @@ function requireNative() {
|
|
|
291
291
|
try {
|
|
292
292
|
const binding = require('@oxc-transform/binding-linux-x64-gnu')
|
|
293
293
|
const bindingPackageVersion = require('@oxc-transform/binding-linux-x64-gnu/package.json').version
|
|
294
|
-
if (bindingPackageVersion !== '0.
|
|
295
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
294
|
+
if (bindingPackageVersion !== '0.133.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.133.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
296
296
|
}
|
|
297
297
|
return binding
|
|
298
298
|
} catch (e) {
|
|
@@ -309,8 +309,8 @@ function requireNative() {
|
|
|
309
309
|
try {
|
|
310
310
|
const binding = require('@oxc-transform/binding-linux-arm64-musl')
|
|
311
311
|
const bindingPackageVersion = require('@oxc-transform/binding-linux-arm64-musl/package.json').version
|
|
312
|
-
if (bindingPackageVersion !== '0.
|
|
313
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
312
|
+
if (bindingPackageVersion !== '0.133.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.133.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
314
314
|
}
|
|
315
315
|
return binding
|
|
316
316
|
} catch (e) {
|
|
@@ -325,8 +325,8 @@ function requireNative() {
|
|
|
325
325
|
try {
|
|
326
326
|
const binding = require('@oxc-transform/binding-linux-arm64-gnu')
|
|
327
327
|
const bindingPackageVersion = require('@oxc-transform/binding-linux-arm64-gnu/package.json').version
|
|
328
|
-
if (bindingPackageVersion !== '0.
|
|
329
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
328
|
+
if (bindingPackageVersion !== '0.133.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.133.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
330
330
|
}
|
|
331
331
|
return binding
|
|
332
332
|
} catch (e) {
|
|
@@ -343,8 +343,8 @@ function requireNative() {
|
|
|
343
343
|
try {
|
|
344
344
|
const binding = require('@oxc-transform/binding-linux-arm-musleabihf')
|
|
345
345
|
const bindingPackageVersion = require('@oxc-transform/binding-linux-arm-musleabihf/package.json').version
|
|
346
|
-
if (bindingPackageVersion !== '0.
|
|
347
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
346
|
+
if (bindingPackageVersion !== '0.133.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.133.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
348
348
|
}
|
|
349
349
|
return binding
|
|
350
350
|
} catch (e) {
|
|
@@ -359,8 +359,8 @@ function requireNative() {
|
|
|
359
359
|
try {
|
|
360
360
|
const binding = require('@oxc-transform/binding-linux-arm-gnueabihf')
|
|
361
361
|
const bindingPackageVersion = require('@oxc-transform/binding-linux-arm-gnueabihf/package.json').version
|
|
362
|
-
if (bindingPackageVersion !== '0.
|
|
363
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
362
|
+
if (bindingPackageVersion !== '0.133.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.133.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
364
364
|
}
|
|
365
365
|
return binding
|
|
366
366
|
} catch (e) {
|
|
@@ -377,8 +377,8 @@ function requireNative() {
|
|
|
377
377
|
try {
|
|
378
378
|
const binding = require('@oxc-transform/binding-linux-loong64-musl')
|
|
379
379
|
const bindingPackageVersion = require('@oxc-transform/binding-linux-loong64-musl/package.json').version
|
|
380
|
-
if (bindingPackageVersion !== '0.
|
|
381
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
380
|
+
if (bindingPackageVersion !== '0.133.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.133.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
382
382
|
}
|
|
383
383
|
return binding
|
|
384
384
|
} catch (e) {
|
|
@@ -393,8 +393,8 @@ function requireNative() {
|
|
|
393
393
|
try {
|
|
394
394
|
const binding = require('@oxc-transform/binding-linux-loong64-gnu')
|
|
395
395
|
const bindingPackageVersion = require('@oxc-transform/binding-linux-loong64-gnu/package.json').version
|
|
396
|
-
if (bindingPackageVersion !== '0.
|
|
397
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
396
|
+
if (bindingPackageVersion !== '0.133.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.133.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
398
398
|
}
|
|
399
399
|
return binding
|
|
400
400
|
} catch (e) {
|
|
@@ -411,8 +411,8 @@ function requireNative() {
|
|
|
411
411
|
try {
|
|
412
412
|
const binding = require('@oxc-transform/binding-linux-riscv64-musl')
|
|
413
413
|
const bindingPackageVersion = require('@oxc-transform/binding-linux-riscv64-musl/package.json').version
|
|
414
|
-
if (bindingPackageVersion !== '0.
|
|
415
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
414
|
+
if (bindingPackageVersion !== '0.133.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.133.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
416
416
|
}
|
|
417
417
|
return binding
|
|
418
418
|
} catch (e) {
|
|
@@ -427,8 +427,8 @@ function requireNative() {
|
|
|
427
427
|
try {
|
|
428
428
|
const binding = require('@oxc-transform/binding-linux-riscv64-gnu')
|
|
429
429
|
const bindingPackageVersion = require('@oxc-transform/binding-linux-riscv64-gnu/package.json').version
|
|
430
|
-
if (bindingPackageVersion !== '0.
|
|
431
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
430
|
+
if (bindingPackageVersion !== '0.133.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.133.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
432
432
|
}
|
|
433
433
|
return binding
|
|
434
434
|
} catch (e) {
|
|
@@ -444,8 +444,8 @@ function requireNative() {
|
|
|
444
444
|
try {
|
|
445
445
|
const binding = require('@oxc-transform/binding-linux-ppc64-gnu')
|
|
446
446
|
const bindingPackageVersion = require('@oxc-transform/binding-linux-ppc64-gnu/package.json').version
|
|
447
|
-
if (bindingPackageVersion !== '0.
|
|
448
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
447
|
+
if (bindingPackageVersion !== '0.133.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.133.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
449
449
|
}
|
|
450
450
|
return binding
|
|
451
451
|
} catch (e) {
|
|
@@ -460,8 +460,8 @@ function requireNative() {
|
|
|
460
460
|
try {
|
|
461
461
|
const binding = require('@oxc-transform/binding-linux-s390x-gnu')
|
|
462
462
|
const bindingPackageVersion = require('@oxc-transform/binding-linux-s390x-gnu/package.json').version
|
|
463
|
-
if (bindingPackageVersion !== '0.
|
|
464
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
463
|
+
if (bindingPackageVersion !== '0.133.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.133.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
465
465
|
}
|
|
466
466
|
return binding
|
|
467
467
|
} catch (e) {
|
|
@@ -480,8 +480,8 @@ function requireNative() {
|
|
|
480
480
|
try {
|
|
481
481
|
const binding = require('@oxc-transform/binding-openharmony-arm64')
|
|
482
482
|
const bindingPackageVersion = require('@oxc-transform/binding-openharmony-arm64/package.json').version
|
|
483
|
-
if (bindingPackageVersion !== '0.
|
|
484
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
483
|
+
if (bindingPackageVersion !== '0.133.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.133.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
485
485
|
}
|
|
486
486
|
return binding
|
|
487
487
|
} catch (e) {
|
|
@@ -496,8 +496,8 @@ function requireNative() {
|
|
|
496
496
|
try {
|
|
497
497
|
const binding = require('@oxc-transform/binding-openharmony-x64')
|
|
498
498
|
const bindingPackageVersion = require('@oxc-transform/binding-openharmony-x64/package.json').version
|
|
499
|
-
if (bindingPackageVersion !== '0.
|
|
500
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
499
|
+
if (bindingPackageVersion !== '0.133.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.133.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
501
501
|
}
|
|
502
502
|
return binding
|
|
503
503
|
} catch (e) {
|
|
@@ -512,8 +512,8 @@ function requireNative() {
|
|
|
512
512
|
try {
|
|
513
513
|
const binding = require('@oxc-transform/binding-openharmony-arm')
|
|
514
514
|
const bindingPackageVersion = require('@oxc-transform/binding-openharmony-arm/package.json').version
|
|
515
|
-
if (bindingPackageVersion !== '0.
|
|
516
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
515
|
+
if (bindingPackageVersion !== '0.133.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.133.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
517
517
|
}
|
|
518
518
|
return binding
|
|
519
519
|
} catch (e) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oxc-transform",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.133.0",
|
|
4
4
|
"description": "Oxc Transformer Node API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"babel",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@napi-rs/cli": "3.6.2",
|
|
44
44
|
"@types/node": "24.1.0",
|
|
45
45
|
"publint": "0.3.21",
|
|
46
|
-
"vitest": "4.1.
|
|
46
|
+
"vitest": "4.1.7"
|
|
47
47
|
},
|
|
48
48
|
"napi": {
|
|
49
49
|
"binaryName": "transform",
|
|
@@ -80,26 +80,26 @@
|
|
|
80
80
|
"node": "^20.19.0 || >=22.12.0"
|
|
81
81
|
},
|
|
82
82
|
"optionalDependencies": {
|
|
83
|
-
"@oxc-transform/binding-darwin-arm64": "0.
|
|
84
|
-
"@oxc-transform/binding-android-arm64": "0.
|
|
85
|
-
"@oxc-transform/binding-win32-arm64-msvc": "0.
|
|
86
|
-
"@oxc-transform/binding-linux-arm64-gnu": "0.
|
|
87
|
-
"@oxc-transform/binding-linux-arm64-musl": "0.
|
|
88
|
-
"@oxc-transform/binding-openharmony-arm64": "0.
|
|
89
|
-
"@oxc-transform/binding-android-arm-eabi": "0.
|
|
90
|
-
"@oxc-transform/binding-linux-arm-gnueabihf": "0.
|
|
91
|
-
"@oxc-transform/binding-linux-arm-musleabihf": "0.
|
|
92
|
-
"@oxc-transform/binding-win32-ia32-msvc": "0.
|
|
93
|
-
"@oxc-transform/binding-linux-ppc64-gnu": "0.
|
|
94
|
-
"@oxc-transform/binding-linux-riscv64-gnu": "0.
|
|
95
|
-
"@oxc-transform/binding-linux-riscv64-musl": "0.
|
|
96
|
-
"@oxc-transform/binding-linux-s390x-gnu": "0.
|
|
97
|
-
"@oxc-transform/binding-wasm32-wasi": "0.
|
|
98
|
-
"@oxc-transform/binding-darwin-x64": "0.
|
|
99
|
-
"@oxc-transform/binding-win32-x64-msvc": "0.
|
|
100
|
-
"@oxc-transform/binding-freebsd-x64": "0.
|
|
101
|
-
"@oxc-transform/binding-linux-x64-gnu": "0.
|
|
102
|
-
"@oxc-transform/binding-linux-x64-musl": "0.
|
|
83
|
+
"@oxc-transform/binding-darwin-arm64": "0.133.0",
|
|
84
|
+
"@oxc-transform/binding-android-arm64": "0.133.0",
|
|
85
|
+
"@oxc-transform/binding-win32-arm64-msvc": "0.133.0",
|
|
86
|
+
"@oxc-transform/binding-linux-arm64-gnu": "0.133.0",
|
|
87
|
+
"@oxc-transform/binding-linux-arm64-musl": "0.133.0",
|
|
88
|
+
"@oxc-transform/binding-openharmony-arm64": "0.133.0",
|
|
89
|
+
"@oxc-transform/binding-android-arm-eabi": "0.133.0",
|
|
90
|
+
"@oxc-transform/binding-linux-arm-gnueabihf": "0.133.0",
|
|
91
|
+
"@oxc-transform/binding-linux-arm-musleabihf": "0.133.0",
|
|
92
|
+
"@oxc-transform/binding-win32-ia32-msvc": "0.133.0",
|
|
93
|
+
"@oxc-transform/binding-linux-ppc64-gnu": "0.133.0",
|
|
94
|
+
"@oxc-transform/binding-linux-riscv64-gnu": "0.133.0",
|
|
95
|
+
"@oxc-transform/binding-linux-riscv64-musl": "0.133.0",
|
|
96
|
+
"@oxc-transform/binding-linux-s390x-gnu": "0.133.0",
|
|
97
|
+
"@oxc-transform/binding-wasm32-wasi": "0.133.0",
|
|
98
|
+
"@oxc-transform/binding-darwin-x64": "0.133.0",
|
|
99
|
+
"@oxc-transform/binding-win32-x64-msvc": "0.133.0",
|
|
100
|
+
"@oxc-transform/binding-freebsd-x64": "0.133.0",
|
|
101
|
+
"@oxc-transform/binding-linux-x64-gnu": "0.133.0",
|
|
102
|
+
"@oxc-transform/binding-linux-x64-musl": "0.133.0"
|
|
103
103
|
},
|
|
104
104
|
"scripts": {
|
|
105
105
|
"build-dev": "napi build --esm --platform",
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Hiroki Osame <hiroki.osame@gmail.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
# resolve-pkg-maps
|
|
2
|
+
|
|
3
|
+
Utils to resolve `package.json` subpath & conditional [`exports`](https://nodejs.org/api/packages.html#exports)/[`imports`](https://nodejs.org/api/packages.html#imports) in resolvers.
|
|
4
|
+
|
|
5
|
+
Implements the [ESM resolution algorithm](https://nodejs.org/api/esm.html#resolver-algorithm-specification). Tested [against Node.js](/tests/) for accuracy.
|
|
6
|
+
|
|
7
|
+
<sub>Support this project by ⭐️ starring and sharing it. [Follow me](https://github.com/privatenumber) to see what other cool projects I'm working on! ❤️</sub>
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
### Resolving `exports`
|
|
12
|
+
|
|
13
|
+
_utils/package.json_
|
|
14
|
+
```json5
|
|
15
|
+
{
|
|
16
|
+
// ...
|
|
17
|
+
"exports": {
|
|
18
|
+
"./reverse": {
|
|
19
|
+
"require": "./file.cjs",
|
|
20
|
+
"default": "./file.mjs"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
// ...
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { resolveExports } from 'resolve-pkg-maps'
|
|
29
|
+
|
|
30
|
+
const [packageName, packageSubpath] = parseRequest('utils/reverse')
|
|
31
|
+
|
|
32
|
+
const resolvedPaths: string[] = resolveExports(
|
|
33
|
+
getPackageJson(packageName).exports,
|
|
34
|
+
packageSubpath,
|
|
35
|
+
['import', ...otherConditions]
|
|
36
|
+
)
|
|
37
|
+
// => ['./file.mjs']
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Resolving `imports`
|
|
41
|
+
|
|
42
|
+
_package.json_
|
|
43
|
+
```json5
|
|
44
|
+
{
|
|
45
|
+
// ...
|
|
46
|
+
"imports": {
|
|
47
|
+
"#supports-color": {
|
|
48
|
+
"node": "./index.js",
|
|
49
|
+
"default": "./browser.js"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
// ...
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
import { resolveImports } from 'resolve-pkg-maps'
|
|
58
|
+
|
|
59
|
+
const resolvedPaths: string[] = resolveImports(
|
|
60
|
+
getPackageJson('.').imports,
|
|
61
|
+
'#supports-color',
|
|
62
|
+
['node', ...otherConditions]
|
|
63
|
+
)
|
|
64
|
+
// => ['./index.js']
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## API
|
|
68
|
+
|
|
69
|
+
### resolveExports(exports, request, conditions)
|
|
70
|
+
|
|
71
|
+
Returns: `string[]`
|
|
72
|
+
|
|
73
|
+
Resolves the `request` based on `exports` and `conditions`. Returns an array of paths (e.g. in case a fallback array is matched).
|
|
74
|
+
|
|
75
|
+
#### exports
|
|
76
|
+
|
|
77
|
+
Type:
|
|
78
|
+
```ts
|
|
79
|
+
type Exports = PathOrMap | readonly PathOrMap[]
|
|
80
|
+
|
|
81
|
+
type PathOrMap = string | PathConditionsMap
|
|
82
|
+
|
|
83
|
+
type PathConditionsMap = {
|
|
84
|
+
[condition: string]: PathConditions | null
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
The [`exports` property](https://nodejs.org/api/packages.html#exports) value in `package.json`.
|
|
89
|
+
|
|
90
|
+
#### request
|
|
91
|
+
|
|
92
|
+
Type: `string`
|
|
93
|
+
|
|
94
|
+
The package subpath to resolve. Assumes a normalized path is passed in (eg. [repeating slashes `//`](https://github.com/nodejs/node/issues/44316)).
|
|
95
|
+
|
|
96
|
+
It _should not_ start with `/` or `./`.
|
|
97
|
+
|
|
98
|
+
Example: if the full import path is `some-package/subpath/file`, the request is `subpath/file`.
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
#### conditions
|
|
102
|
+
|
|
103
|
+
Type: `readonly string[]`
|
|
104
|
+
|
|
105
|
+
An array of conditions to use when resolving the request. For reference, Node.js's default conditions are [`['node', 'import']`](https://nodejs.org/api/esm.html#:~:text=defaultConditions%20is%20the%20conditional%20environment%20name%20array%2C%20%5B%22node%22%2C%20%22import%22%5D.).
|
|
106
|
+
|
|
107
|
+
The order of this array does not matter; the order of condition keys in the export map is what matters instead.
|
|
108
|
+
|
|
109
|
+
Not all conditions in the array need to be met to resolve the request. It just needs enough to resolve to a path.
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
### resolveImports(imports, request, conditions)
|
|
114
|
+
|
|
115
|
+
Returns: `string[]`
|
|
116
|
+
|
|
117
|
+
Resolves the `request` based on `imports` and `conditions`. Returns an array of paths (e.g. in case a fallback array is matched).
|
|
118
|
+
|
|
119
|
+
#### imports
|
|
120
|
+
|
|
121
|
+
Type:
|
|
122
|
+
```ts
|
|
123
|
+
type Imports = {
|
|
124
|
+
[condition: string]: PathOrMap | readonly PathOrMap[] | null
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
type PathOrMap = string | Imports
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
The [`imports` property](https://nodejs.org/api/packages.html#imports) value in `package.json`.
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
#### request
|
|
134
|
+
|
|
135
|
+
Type: `string`
|
|
136
|
+
|
|
137
|
+
The request resolve. Assumes a normalized path is passed in (eg. [repeating slashes `//`](https://github.com/nodejs/node/issues/44316)).
|
|
138
|
+
|
|
139
|
+
> **Note:** In Node.js, imports resolutions are limited to requests prefixed with `#`. However, this package does not enforce that requirement in case you want to add custom support for non-prefixed entries.
|
|
140
|
+
|
|
141
|
+
#### conditions
|
|
142
|
+
|
|
143
|
+
Type: `readonly string[]`
|
|
144
|
+
|
|
145
|
+
An array of conditions to use when resolving the request. For reference, Node.js's default conditions are [`['node', 'import']`](https://nodejs.org/api/esm.html#:~:text=defaultConditions%20is%20the%20conditional%20environment%20name%20array%2C%20%5B%22node%22%2C%20%22import%22%5D.).
|
|
146
|
+
|
|
147
|
+
The order of this array does not matter; the order of condition keys in the import map is what matters instead.
|
|
148
|
+
|
|
149
|
+
Not all conditions in the array need to be met to resolve the request. It just needs enough to resolve to a path.
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
### Errors
|
|
154
|
+
|
|
155
|
+
#### `ERR_PACKAGE_PATH_NOT_EXPORTED`
|
|
156
|
+
- If the request is not exported by the export map
|
|
157
|
+
|
|
158
|
+
#### `ERR_PACKAGE_IMPORT_NOT_DEFINED`
|
|
159
|
+
- If the request is not defined by the import map
|
|
160
|
+
|
|
161
|
+
#### `ERR_INVALID_PACKAGE_CONFIG`
|
|
162
|
+
|
|
163
|
+
- If an object contains properties that are both paths and conditions (e.g. start with and without `.`)
|
|
164
|
+
- If an object contains numeric properties
|
|
165
|
+
|
|
166
|
+
#### `ERR_INVALID_PACKAGE_TARGET`
|
|
167
|
+
- If a resolved exports path is not a valid path (e.g. not relative or has protocol)
|
|
168
|
+
- If a resolved path includes `..` or `node_modules`
|
|
169
|
+
- If a resolved path is a type that cannot be parsed
|
|
170
|
+
|
|
171
|
+
## FAQ
|
|
172
|
+
|
|
173
|
+
### Why do the APIs return an array of paths?
|
|
174
|
+
|
|
175
|
+
`exports`/`imports` supports passing in a [fallback array](https://github.com/jkrems/proposal-pkg-exports/#:~:text=Whenever%20there%20is,to%20new%20cases.) to provide fallback paths if the previous one is invalid:
|
|
176
|
+
|
|
177
|
+
```json5
|
|
178
|
+
{
|
|
179
|
+
"exports": {
|
|
180
|
+
"./feature": [
|
|
181
|
+
"./file.js",
|
|
182
|
+
"./fallback.js"
|
|
183
|
+
]
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Node.js's implementation [picks the first valid path (without attempting to resolve it)](https://github.com/nodejs/node/issues/44282#issuecomment-1220151715) and throws an error if it can't be resolved. Node.js's fallback array is designed for [forward compatibility with features](https://github.com/jkrems/proposal-pkg-exports/#:~:text=providing%20forwards%20compatiblitiy%20for%20new%20features) (e.g. protocols) that can be immediately/inexpensively validated:
|
|
189
|
+
|
|
190
|
+
```json5
|
|
191
|
+
{
|
|
192
|
+
"exports": {
|
|
193
|
+
"./core-polyfill": ["std:core-module", "./core-polyfill.js"]
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
However, [Webpack](https://webpack.js.org/guides/package-exports/#alternatives) and [TypeScript](https://github.com/microsoft/TypeScript/blob/71e852922888337ef51a0e48416034a94a6c34d9/src/compiler/moduleSpecifiers.ts#L695) have deviated from this behavior and attempts to resolve the next path if a path cannot be resolved.
|
|
199
|
+
|
|
200
|
+
By returning an array of matched paths instead of just the first one, the user can decide which behavior to adopt.
|
|
201
|
+
|
|
202
|
+
### How is it different from [`resolve.exports`](https://github.com/lukeed/resolve.exports)?
|
|
203
|
+
|
|
204
|
+
`resolve.exports` only resolves `exports`, whereas this package resolves both `exports` & `imports`. This comparison will only cover resolving `exports`.
|
|
205
|
+
|
|
206
|
+
- Despite it's name, `resolve.exports` handles more than just `exports`. It takes in the entire `package.json` object to handle resolving `.` and [self-references](https://nodejs.org/api/packages.html#self-referencing-a-package-using-its-name). This package only accepts `exports`/`imports` maps from `package.json` and is scoped to only resolving what's defined in the maps.
|
|
207
|
+
|
|
208
|
+
- `resolve.exports` accepts the full request (e.g. `foo/bar`), whereas this package only accepts the requested subpath (e.g. `bar`).
|
|
209
|
+
|
|
210
|
+
- `resolve.exports` only returns the first result in a fallback array. This package returns an array of results for the user to decide how to handle it.
|
|
211
|
+
|
|
212
|
+
- `resolve.exports` supports [subpath folder mapping](https://nodejs.org/docs/latest-v16.x/api/packages.html#subpath-folder-mappings) (deprecated in Node.js v16 & removed in v17) but seems to [have a bug](https://github.com/lukeed/resolve.exports/issues/7). This package does not support subpath folder mapping because Node.js has removed it in favor of using subpath patterns.
|
|
213
|
+
|
|
214
|
+
- Neither resolvers rely on a file-system
|
|
215
|
+
|
|
216
|
+
This package also addresses many of the bugs in `resolve.exports`, demonstrated in [this test](/tests/exports/compare-resolve.exports.ts).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const d=r=>r!==null&&typeof r=="object",s=(r,t)=>Object.assign(new Error(`[${r}]: ${t}`),{code:r}),g="ERR_INVALID_PACKAGE_CONFIG",E="ERR_INVALID_PACKAGE_TARGET",I="ERR_PACKAGE_PATH_NOT_EXPORTED",P="ERR_PACKAGE_IMPORT_NOT_DEFINED",R=/^\d+$/,O=/^(\.{1,2}|node_modules)$/i,u=/\/|\\/;var h=(r=>(r.Export="exports",r.Import="imports",r))(h||{});const f=(r,t,n,o,c)=>{if(t==null)return[];if(typeof t=="string"){const[e,...i]=t.split(u);if(e===".."||i.some(l=>O.test(l)))throw s(E,`Invalid "${r}" target "${t}" defined in the package config`);return[c?t.replace(/\*/g,c):t]}if(Array.isArray(t))return t.flatMap(e=>f(r,e,n,o,c));if(d(t)){for(const e of Object.keys(t)){if(R.test(e))throw s(g,"Cannot contain numeric property keys");if(e==="default"||o.includes(e))return f(r,t[e],n,o,c)}return[]}throw s(E,`Invalid "${r}" target "${t}"`)},a="*",v=(r,t)=>{const n=r.indexOf(a),o=t.indexOf(a);return n===o?t.length>r.length:o>n};function A(r,t){if(!t.includes(a)&&r.hasOwnProperty(t))return[t];let n,o;for(const c of Object.keys(r))if(c.includes(a)){const[e,i,l]=c.split(a);if(l===void 0&&t.startsWith(e)&&t.endsWith(i)){const _=t.slice(e.length,-i.length||void 0);_&&(!n||v(n,c))&&(n=c,o=_)}}return[n,o]}const p=r=>Object.keys(r).reduce((t,n)=>{const o=n===""||n[0]!==".";if(t===void 0||t===o)return o;throw s(g,'"exports" cannot contain some keys starting with "." and some not')},void 0),w=/^\w+:/,m=(r,t,n)=>{if(!r)throw new Error('"exports" is required');t=t===""?".":`./${t}`,(typeof r=="string"||Array.isArray(r)||d(r)&&p(r))&&(r={".":r});const[o,c]=A(r,t),e=f(h.Export,r[o],t,n,c);if(e.length===0)throw s(I,t==="."?'No "exports" main defined':`Package subpath '${t}' is not defined by "exports"`);for(const i of e)if(!i.startsWith("./")&&!w.test(i))throw s(E,`Invalid "exports" target "${i}" defined in the package config`);return e},T=(r,t,n)=>{if(!r)throw new Error('"imports" is required');const[o,c]=A(r,t),e=f(h.Import,r[o],t,n,c);if(e.length===0)throw s(P,`Package import specifier "${t}" is not defined in package`);return e};exports.resolveExports=m,exports.resolveImports=T;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type PathConditionsMap = {
|
|
2
|
+
[condition: string]: PathConditions | null;
|
|
3
|
+
};
|
|
4
|
+
type PathOrMap = string | PathConditionsMap;
|
|
5
|
+
type PathConditions = PathOrMap | readonly PathOrMap[];
|
|
6
|
+
|
|
7
|
+
declare const resolveExports: (exports: PathConditions, request: string, conditions: readonly string[]) => string[];
|
|
8
|
+
|
|
9
|
+
declare const resolveImports: (imports: PathConditionsMap, request: string, conditions: readonly string[]) => string[];
|
|
10
|
+
|
|
11
|
+
export { PathConditions, PathConditionsMap, resolveExports, resolveImports };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type PathConditionsMap = {
|
|
2
|
+
[condition: string]: PathConditions | null;
|
|
3
|
+
};
|
|
4
|
+
type PathOrMap = string | PathConditionsMap;
|
|
5
|
+
type PathConditions = PathOrMap | readonly PathOrMap[];
|
|
6
|
+
|
|
7
|
+
declare const resolveExports: (exports: PathConditions, request: string, conditions: readonly string[]) => string[];
|
|
8
|
+
|
|
9
|
+
declare const resolveImports: (imports: PathConditionsMap, request: string, conditions: readonly string[]) => string[];
|
|
10
|
+
|
|
11
|
+
export { PathConditions, PathConditionsMap, resolveExports, resolveImports };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const A=r=>r!==null&&typeof r=="object",a=(r,t)=>Object.assign(new Error(`[${r}]: ${t}`),{code:r}),_="ERR_INVALID_PACKAGE_CONFIG",E="ERR_INVALID_PACKAGE_TARGET",I="ERR_PACKAGE_PATH_NOT_EXPORTED",P="ERR_PACKAGE_IMPORT_NOT_DEFINED",R=/^\d+$/,O=/^(\.{1,2}|node_modules)$/i,w=/\/|\\/;var h=(r=>(r.Export="exports",r.Import="imports",r))(h||{});const f=(r,t,e,o,c)=>{if(t==null)return[];if(typeof t=="string"){const[n,...i]=t.split(w);if(n===".."||i.some(l=>O.test(l)))throw a(E,`Invalid "${r}" target "${t}" defined in the package config`);return[c?t.replace(/\*/g,c):t]}if(Array.isArray(t))return t.flatMap(n=>f(r,n,e,o,c));if(A(t)){for(const n of Object.keys(t)){if(R.test(n))throw a(_,"Cannot contain numeric property keys");if(n==="default"||o.includes(n))return f(r,t[n],e,o,c)}return[]}throw a(E,`Invalid "${r}" target "${t}"`)},s="*",m=(r,t)=>{const e=r.indexOf(s),o=t.indexOf(s);return e===o?t.length>r.length:o>e};function d(r,t){if(!t.includes(s)&&r.hasOwnProperty(t))return[t];let e,o;for(const c of Object.keys(r))if(c.includes(s)){const[n,i,l]=c.split(s);if(l===void 0&&t.startsWith(n)&&t.endsWith(i)){const g=t.slice(n.length,-i.length||void 0);g&&(!e||m(e,c))&&(e=c,o=g)}}return[e,o]}const p=r=>Object.keys(r).reduce((t,e)=>{const o=e===""||e[0]!==".";if(t===void 0||t===o)return o;throw a(_,'"exports" cannot contain some keys starting with "." and some not')},void 0),u=/^\w+:/,v=(r,t,e)=>{if(!r)throw new Error('"exports" is required');t=t===""?".":`./${t}`,(typeof r=="string"||Array.isArray(r)||A(r)&&p(r))&&(r={".":r});const[o,c]=d(r,t),n=f(h.Export,r[o],t,e,c);if(n.length===0)throw a(I,t==="."?'No "exports" main defined':`Package subpath '${t}' is not defined by "exports"`);for(const i of n)if(!i.startsWith("./")&&!u.test(i))throw a(E,`Invalid "exports" target "${i}" defined in the package config`);return n},T=(r,t,e)=>{if(!r)throw new Error('"imports" is required');const[o,c]=d(r,t),n=f(h.Import,r[o],t,e,c);if(n.length===0)throw a(P,`Package import specifier "${t}" is not defined in package`);return n};export{v as resolveExports,T as resolveImports};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "resolve-pkg-maps",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Resolve package.json exports & imports maps",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"node.js",
|
|
7
|
+
"package.json",
|
|
8
|
+
"exports",
|
|
9
|
+
"imports"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"repository": "privatenumber/resolve-pkg-maps",
|
|
13
|
+
"funding": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1",
|
|
14
|
+
"author": {
|
|
15
|
+
"name": "Hiroki Osame",
|
|
16
|
+
"email": "hiroki.osame@gmail.com"
|
|
17
|
+
},
|
|
18
|
+
"type": "module",
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"main": "./dist/index.cjs",
|
|
23
|
+
"module": "./dist/index.mjs",
|
|
24
|
+
"types": "./dist/index.d.cts",
|
|
25
|
+
"exports": {
|
|
26
|
+
"require": {
|
|
27
|
+
"types": "./dist/index.d.cts",
|
|
28
|
+
"default": "./dist/index.cjs"
|
|
29
|
+
},
|
|
30
|
+
"import": {
|
|
31
|
+
"types": "./dist/index.d.mts",
|
|
32
|
+
"default": "./dist/index.mjs"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"imports": {
|
|
36
|
+
"#resolve-pkg-maps": {
|
|
37
|
+
"types": "./src/index.ts",
|
|
38
|
+
"development": "./src/index.ts",
|
|
39
|
+
"default": "./dist/index.mjs"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|