nf3 0.3.14 → 0.3.16
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 +10 -0
- package/dist/_chunks/libs/exsolve.mjs +198 -198
- package/dist/_chunks/trace.mjs +60 -11
- package/dist/_chunks/types.d.mts +0 -3
- package/dist/db.d.mts +9 -3
- package/dist/db.mjs +96 -48
- package/dist/index.d.mts +0 -3
- package/dist/node_modules/acorn/dist/acorn.js +6 -6
- package/dist/node_modules/glob/dist/commonjs/index.min.js +1 -1
- package/dist/node_modules/semver/classes/semver.js +1 -1
- package/dist/plugin.d.mts +0 -3
- package/dist/plugin.mjs +0 -2
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -119,6 +119,16 @@ These packages cannot be bundled and should be traced as external dependencies m
|
|
|
119
119
|
import { NodeNativePackages } from "nf3/db";
|
|
120
120
|
```
|
|
121
121
|
|
|
122
|
+
NF3 exports a list of packages that need full tracing (all files copied instead of only NFT-detected ones), because they use dynamic requires or runtime asset loading that static analysis cannot detect. You can use this with the `traceInclude` plugin option to ensure they are always traced:
|
|
123
|
+
|
|
124
|
+
```js
|
|
125
|
+
import { FullTracePackages } from "nf3/db";
|
|
126
|
+
|
|
127
|
+
externals({
|
|
128
|
+
traceInclude: [...FullTracePackages],
|
|
129
|
+
});
|
|
130
|
+
```
|
|
131
|
+
|
|
122
132
|
NF3 also exports a list of packages that must be externalized rather than bundled, due to bundler compatibility issues with their module format or dynamic imports.
|
|
123
133
|
|
|
124
134
|
```js
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import e, { lstatSync as t, realpathSync as n, statSync as r } from "node:fs";
|
|
2
|
+
import { URL as i, fileURLToPath as a, pathToFileURL as o } from "node:url";
|
|
3
3
|
import s, { isAbsolute as c } from "node:path";
|
|
4
4
|
import l from "node:assert";
|
|
5
5
|
import u from "node:process";
|
|
@@ -105,19 +105,19 @@ b(`ERR_INVALID_ARG_VALUE`, (e, t, n = `is invalid`) => {
|
|
|
105
105
|
return r.length > 128 && (r = `${r.slice(0, 128)}...`), `The ${e.includes(`.`) ? `property` : `argument`} '${e}' ${n}. Received ${r}`;
|
|
106
106
|
}, TypeError);
|
|
107
107
|
const A = {}.hasOwnProperty, j = /* @__PURE__ */ new Map();
|
|
108
|
-
function M(
|
|
109
|
-
let
|
|
110
|
-
if (
|
|
108
|
+
function M(t, { base: n, specifier: r }) {
|
|
109
|
+
let i = j.get(t);
|
|
110
|
+
if (i) return i;
|
|
111
111
|
let o;
|
|
112
112
|
try {
|
|
113
|
-
o =
|
|
113
|
+
o = e.readFileSync(s.toNamespacedPath(t), `utf8`);
|
|
114
114
|
} catch (e) {
|
|
115
115
|
let t = e;
|
|
116
116
|
if (t.code !== `ENOENT`) throw t;
|
|
117
117
|
}
|
|
118
118
|
let c = {
|
|
119
119
|
exists: !1,
|
|
120
|
-
pjsonPath:
|
|
120
|
+
pjsonPath: t,
|
|
121
121
|
main: void 0,
|
|
122
122
|
name: void 0,
|
|
123
123
|
type: `none`,
|
|
@@ -125,27 +125,27 @@ function M(e, { base: n, specifier: i }) {
|
|
|
125
125
|
imports: void 0
|
|
126
126
|
};
|
|
127
127
|
if (o !== void 0) {
|
|
128
|
-
let
|
|
128
|
+
let e;
|
|
129
129
|
try {
|
|
130
|
-
|
|
131
|
-
} catch (
|
|
132
|
-
let
|
|
133
|
-
throw
|
|
130
|
+
e = JSON.parse(o);
|
|
131
|
+
} catch (e) {
|
|
132
|
+
let i = new w(t, (n ? `"${r}" from ` : ``) + a(n || r), e.message);
|
|
133
|
+
throw i.cause = e, i;
|
|
134
134
|
}
|
|
135
|
-
c.exists = !0, A.call(
|
|
135
|
+
c.exists = !0, A.call(e, `name`) && typeof e.name == `string` && (c.name = e.name), A.call(e, `main`) && typeof e.main == `string` && (c.main = e.main), A.call(e, `exports`) && (c.exports = e.exports), A.call(e, `imports`) && (c.imports = e.imports), A.call(e, `type`) && (e.type === `commonjs` || e.type === `module`) && (c.type = e.type);
|
|
136
136
|
}
|
|
137
|
-
return j.set(
|
|
137
|
+
return j.set(t, c), c;
|
|
138
138
|
}
|
|
139
139
|
function N(e) {
|
|
140
|
-
let
|
|
141
|
-
for (; !
|
|
142
|
-
let
|
|
143
|
-
if (
|
|
144
|
-
let
|
|
145
|
-
if (
|
|
140
|
+
let t = new URL(`package.json`, e);
|
|
141
|
+
for (; !t.pathname.endsWith(`node_modules/package.json`);) {
|
|
142
|
+
let n = M(a(t), { specifier: e });
|
|
143
|
+
if (n.exists) return n;
|
|
144
|
+
let r = t;
|
|
145
|
+
if (t = new URL(`../package.json`, t), t.pathname === r.pathname) break;
|
|
146
146
|
}
|
|
147
147
|
return {
|
|
148
|
-
pjsonPath: t
|
|
148
|
+
pjsonPath: a(t),
|
|
149
149
|
exists: !1,
|
|
150
150
|
type: `none`
|
|
151
151
|
};
|
|
@@ -185,144 +185,144 @@ function de(e) {
|
|
|
185
185
|
}
|
|
186
186
|
return ``;
|
|
187
187
|
}
|
|
188
|
-
function fe(e,
|
|
189
|
-
let
|
|
190
|
-
if (
|
|
188
|
+
function fe(e, t, n) {
|
|
189
|
+
let r = de(e);
|
|
190
|
+
if (r === `.js`) {
|
|
191
191
|
let { type: t } = N(e);
|
|
192
192
|
return t === `none` ? `commonjs` : t;
|
|
193
193
|
}
|
|
194
|
-
if (
|
|
194
|
+
if (r === ``) {
|
|
195
195
|
let { type: t } = N(e);
|
|
196
196
|
return t === `none` || t === `commonjs` ? `commonjs` : `module`;
|
|
197
197
|
}
|
|
198
|
-
let
|
|
199
|
-
if (
|
|
200
|
-
if (!
|
|
198
|
+
let i = ce[r];
|
|
199
|
+
if (i) return i;
|
|
200
|
+
if (!n) throw new oe(r, a(e));
|
|
201
201
|
}
|
|
202
202
|
function pe(e, t) {
|
|
203
203
|
let n = e.protocol;
|
|
204
204
|
return se.call(P, n) && P[n](e, t, !0) || null;
|
|
205
205
|
}
|
|
206
206
|
const F = RegExp.prototype[Symbol.replace], I = {}.hasOwnProperty, L = /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))?(\\|\/|$)/i, R = /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))(\\|\/|$)/i, z = /^\.|%|\\/, B = /\*/g, me = /%2f|%5c/i, V = /* @__PURE__ */ new Set(), he = /[/\\]{2}/;
|
|
207
|
-
function H(e, n, r, i,
|
|
207
|
+
function H(e, t, n, r, i, o, s) {
|
|
208
208
|
if (u.noDeprecation) return;
|
|
209
|
-
let c =
|
|
210
|
-
u.emitWarning(`Use of deprecated ${l ? `double slash` : `leading or trailing slash matching`} resolving "${e}" for module request "${
|
|
209
|
+
let c = a(r), l = he.exec(s ? e : t) !== null;
|
|
210
|
+
u.emitWarning(`Use of deprecated ${l ? `double slash` : `leading or trailing slash matching`} resolving "${e}" for module request "${t}" ${t === n ? `` : `matched to "${n}" `}in the "${i ? `imports` : `exports`}" field module resolution of the package at ${c}${o ? ` imported from ${a(o)}` : ``}.`, `DeprecationWarning`, `DEP0166`);
|
|
211
211
|
}
|
|
212
|
-
function U(
|
|
213
|
-
if (u.noDeprecation || pe(
|
|
214
|
-
let o =
|
|
215
|
-
|
|
212
|
+
function U(e, t, n, r) {
|
|
213
|
+
if (u.noDeprecation || pe(e, { parentURL: n.href }) !== `module`) return;
|
|
214
|
+
let o = a(e.href), c = a(new i(`.`, t)), l = a(n);
|
|
215
|
+
r ? s.resolve(c, r) !== o && u.emitWarning(`Package ${c} has a "main" field set to "${r}", excluding the full filename and extension to the resolved file at "${o.slice(c.length)}", imported from ${l}.\n Automatic extension resolution of the "main" field is deprecated for ES modules.`, `DeprecationWarning`, `DEP0151`) : u.emitWarning(`No "main" or "exports" field defined in the package.json for ${c} resolving the main entry point "${o.slice(c.length)}", imported from ${l}.\nDefault "index" lookups for the main are deprecated for ES modules.`, `DeprecationWarning`, `DEP0151`);
|
|
216
216
|
}
|
|
217
217
|
function W(e) {
|
|
218
218
|
try {
|
|
219
|
-
return
|
|
219
|
+
return r(e);
|
|
220
220
|
} catch {}
|
|
221
221
|
}
|
|
222
222
|
function G(e) {
|
|
223
|
-
let t =
|
|
223
|
+
let t = r(e, { throwIfNoEntry: !1 });
|
|
224
224
|
return (t ? t.isFile() : void 0) ?? !1;
|
|
225
225
|
}
|
|
226
|
-
function ge(
|
|
227
|
-
let
|
|
228
|
-
if (
|
|
229
|
-
if (
|
|
230
|
-
let
|
|
231
|
-
`./${
|
|
232
|
-
`./${
|
|
233
|
-
`./${
|
|
234
|
-
`./${
|
|
235
|
-
`./${
|
|
236
|
-
`./${
|
|
226
|
+
function ge(e, t, n) {
|
|
227
|
+
let r;
|
|
228
|
+
if (t.main !== void 0) {
|
|
229
|
+
if (r = new i(t.main, e), G(r)) return r;
|
|
230
|
+
let a = [
|
|
231
|
+
`./${t.main}.js`,
|
|
232
|
+
`./${t.main}.json`,
|
|
233
|
+
`./${t.main}.node`,
|
|
234
|
+
`./${t.main}/index.js`,
|
|
235
|
+
`./${t.main}/index.json`,
|
|
236
|
+
`./${t.main}/index.node`
|
|
237
237
|
], o = -1;
|
|
238
|
-
for (; ++o <
|
|
239
|
-
if (
|
|
238
|
+
for (; ++o < a.length && (r = new i(a[o], e), !G(r));) r = void 0;
|
|
239
|
+
if (r) return U(r, e, n, t.main), r;
|
|
240
240
|
}
|
|
241
241
|
let o = [
|
|
242
242
|
`./index.js`,
|
|
243
243
|
`./index.json`,
|
|
244
244
|
`./index.node`
|
|
245
245
|
], s = -1;
|
|
246
|
-
for (; ++s < o.length && (
|
|
247
|
-
if (
|
|
248
|
-
throw new T(
|
|
246
|
+
for (; ++s < o.length && (r = new i(o[s], e), !G(r));) r = void 0;
|
|
247
|
+
if (r) return U(r, e, n, t.main), r;
|
|
248
|
+
throw new T(a(new i(`.`, e)), a(n));
|
|
249
249
|
}
|
|
250
|
-
function _e(e,
|
|
251
|
-
if (me.exec(e.pathname) !== null) throw new C(e.pathname, String.raw`must not include encoded "/" or "\" characters`, t
|
|
252
|
-
let
|
|
250
|
+
function _e(e, t, r) {
|
|
251
|
+
if (me.exec(e.pathname) !== null) throw new C(e.pathname, String.raw`must not include encoded "/" or "\" characters`, a(t));
|
|
252
|
+
let i;
|
|
253
253
|
try {
|
|
254
|
-
|
|
255
|
-
} catch (
|
|
256
|
-
throw Object.defineProperty(
|
|
254
|
+
i = a(e);
|
|
255
|
+
} catch (n) {
|
|
256
|
+
throw Object.defineProperty(n, `input`, { value: String(e) }), Object.defineProperty(n, `module`, { value: String(t) }), n;
|
|
257
257
|
}
|
|
258
|
-
let c = W(
|
|
258
|
+
let c = W(i.endsWith(`/`) ? i.slice(-1) : i);
|
|
259
259
|
if (c && c.isDirectory()) {
|
|
260
|
-
let n = new O(
|
|
260
|
+
let n = new O(i, a(t));
|
|
261
261
|
throw n.url = String(e), n;
|
|
262
262
|
}
|
|
263
263
|
if (!c || !c.isFile()) {
|
|
264
|
-
let n = new T(
|
|
264
|
+
let n = new T(i || e.pathname, t && a(t), !0);
|
|
265
265
|
throw n.url = String(e), n;
|
|
266
266
|
}
|
|
267
|
-
if (!
|
|
268
|
-
let t =
|
|
269
|
-
e =
|
|
267
|
+
if (!r) {
|
|
268
|
+
let t = n(i), { search: r, hash: a } = e;
|
|
269
|
+
e = o(t + (i.endsWith(s.sep) ? `/` : ``)), e.search = r, e.hash = a;
|
|
270
270
|
}
|
|
271
271
|
return e;
|
|
272
272
|
}
|
|
273
|
-
function ve(
|
|
274
|
-
return new E(
|
|
273
|
+
function ve(e, t, n) {
|
|
274
|
+
return new E(e, t && a(new i(`.`, t)), a(n));
|
|
275
275
|
}
|
|
276
|
-
function K(
|
|
277
|
-
return new D(
|
|
276
|
+
function K(e, t, n) {
|
|
277
|
+
return new D(a(new i(`.`, t)), e, n && a(n));
|
|
278
278
|
}
|
|
279
|
-
function ye(e, n, r, i
|
|
280
|
-
throw new C(e, `request is not a valid match in pattern "${
|
|
279
|
+
function ye(e, t, n, r, i) {
|
|
280
|
+
throw new C(e, `request is not a valid match in pattern "${t}" for the "${r ? `imports` : `exports`}" resolution of ${a(n)}`, i && a(i));
|
|
281
281
|
}
|
|
282
|
-
function q(
|
|
283
|
-
return
|
|
282
|
+
function q(e, t, n, r, o) {
|
|
283
|
+
return t = typeof t == `object` && t ? JSON.stringify(t, null, ``) : `${t}`, new ae(a(new i(`.`, n)), e, t, r, o && a(o));
|
|
284
284
|
}
|
|
285
|
-
function be(t, n, r,
|
|
286
|
-
if (
|
|
287
|
-
if (!
|
|
288
|
-
if (s && !
|
|
289
|
-
let
|
|
285
|
+
function be(e, t, n, r, a, o, s, c, l) {
|
|
286
|
+
if (t !== `` && !o && e.at(-1) !== `/`) throw q(n, e, r, s, a);
|
|
287
|
+
if (!e.startsWith(`./`)) {
|
|
288
|
+
if (s && !e.startsWith(`../`) && !e.startsWith(`/`)) {
|
|
289
|
+
let n = !1;
|
|
290
290
|
try {
|
|
291
|
-
new e
|
|
291
|
+
new i(e), n = !0;
|
|
292
292
|
} catch {}
|
|
293
|
-
if (!
|
|
293
|
+
if (!n) return Z(o ? F.call(B, e, () => t) : e + t, r, l);
|
|
294
294
|
}
|
|
295
|
-
throw q(
|
|
295
|
+
throw q(n, e, r, s, a);
|
|
296
296
|
}
|
|
297
|
-
if (L.exec(
|
|
297
|
+
if (L.exec(e.slice(2)) !== null) if (R.exec(e.slice(2)) === null) {
|
|
298
298
|
if (!c) {
|
|
299
|
-
let
|
|
300
|
-
H(o ? F.call(B,
|
|
299
|
+
let i = o ? n.replace(`*`, () => t) : n + t;
|
|
300
|
+
H(o ? F.call(B, e, () => t) : e, i, n, r, s, a, !0);
|
|
301
301
|
}
|
|
302
|
-
} else throw q(
|
|
303
|
-
let u = new e
|
|
304
|
-
if (!d.startsWith(f)) throw q(
|
|
305
|
-
if (
|
|
306
|
-
if (L.exec(
|
|
307
|
-
let
|
|
308
|
-
R.exec(
|
|
302
|
+
} else throw q(n, e, r, s, a);
|
|
303
|
+
let u = new i(e, r), d = u.pathname, f = new i(`.`, r).pathname;
|
|
304
|
+
if (!d.startsWith(f)) throw q(n, e, r, s, a);
|
|
305
|
+
if (t === ``) return u;
|
|
306
|
+
if (L.exec(t) !== null) {
|
|
307
|
+
let i = o ? n.replace(`*`, () => t) : n + t;
|
|
308
|
+
R.exec(t) === null ? c || H(o ? F.call(B, e, () => t) : e, i, n, r, s, a, !1) : ye(i, n, r, s, a);
|
|
309
309
|
}
|
|
310
|
-
return o ? new
|
|
310
|
+
return o ? new i(F.call(B, u.href, () => t)) : new i(t, u);
|
|
311
311
|
}
|
|
312
312
|
function xe(e) {
|
|
313
313
|
let t = Number(e);
|
|
314
314
|
return `${t}` === e ? t >= 0 && t < 4294967295 : !1;
|
|
315
315
|
}
|
|
316
|
-
function J(e, n, r, i,
|
|
317
|
-
if (typeof
|
|
318
|
-
if (Array.isArray(
|
|
319
|
-
let
|
|
320
|
-
if (
|
|
316
|
+
function J(e, t, n, r, i, o, s, c, l) {
|
|
317
|
+
if (typeof t == `string`) return be(t, n, r, e, i, o, s, c, l);
|
|
318
|
+
if (Array.isArray(t)) {
|
|
319
|
+
let a = t;
|
|
320
|
+
if (a.length === 0) return null;
|
|
321
321
|
let u, d = -1;
|
|
322
|
-
for (; ++d <
|
|
323
|
-
let
|
|
322
|
+
for (; ++d < a.length;) {
|
|
323
|
+
let t = a[d], f;
|
|
324
324
|
try {
|
|
325
|
-
f = J(e, n, r, i,
|
|
325
|
+
f = J(e, t, n, r, i, o, s, c, l);
|
|
326
326
|
} catch (e) {
|
|
327
327
|
let t = e;
|
|
328
328
|
if (u = t, t.code === `ERR_INVALID_PACKAGE_TARGET`) continue;
|
|
@@ -339,40 +339,40 @@ function J(e, n, r, i, a, o, s, c, l) {
|
|
|
339
339
|
if (u == null) return null;
|
|
340
340
|
throw u;
|
|
341
341
|
}
|
|
342
|
-
if (typeof
|
|
343
|
-
let u = Object.getOwnPropertyNames(
|
|
342
|
+
if (typeof t == `object` && t) {
|
|
343
|
+
let u = Object.getOwnPropertyNames(t), d = -1;
|
|
344
344
|
for (; ++d < u.length;) {
|
|
345
|
-
let
|
|
346
|
-
if (xe(
|
|
345
|
+
let t = u[d];
|
|
346
|
+
if (xe(t)) throw new w(a(e), a(i), `"exports" cannot contain numeric property keys.`);
|
|
347
347
|
}
|
|
348
348
|
for (d = -1; ++d < u.length;) {
|
|
349
|
-
let
|
|
350
|
-
if (
|
|
351
|
-
let u =
|
|
349
|
+
let a = u[d];
|
|
350
|
+
if (a === `default` || l && l.has(a)) {
|
|
351
|
+
let u = t[a], d = J(e, u, n, r, i, o, s, c, l);
|
|
352
352
|
if (d === void 0) continue;
|
|
353
353
|
return d;
|
|
354
354
|
}
|
|
355
355
|
}
|
|
356
356
|
return null;
|
|
357
357
|
}
|
|
358
|
-
if (
|
|
359
|
-
throw q(
|
|
358
|
+
if (t === null) return null;
|
|
359
|
+
throw q(r, t, e, s, i);
|
|
360
360
|
}
|
|
361
|
-
function Se(e,
|
|
361
|
+
function Se(e, t, n) {
|
|
362
362
|
if (typeof e == `string` || Array.isArray(e)) return !0;
|
|
363
363
|
if (typeof e != `object` || !e) return !1;
|
|
364
|
-
let
|
|
365
|
-
for (; ++s <
|
|
366
|
-
let e =
|
|
367
|
-
if (o++ === 0)
|
|
368
|
-
else if (
|
|
364
|
+
let r = Object.getOwnPropertyNames(e), i = !1, o = 0, s = -1;
|
|
365
|
+
for (; ++s < r.length;) {
|
|
366
|
+
let e = r[s], c = e === `` || e[0] !== `.`;
|
|
367
|
+
if (o++ === 0) i = c;
|
|
368
|
+
else if (i !== c) throw new w(a(t), a(n), `"exports" cannot contain some keys starting with '.' and some not. The exports object must either be an object of package subpath keys or an object of main entry condition name keys only.`);
|
|
369
369
|
}
|
|
370
|
-
return
|
|
370
|
+
return i;
|
|
371
371
|
}
|
|
372
|
-
function Ce(e,
|
|
372
|
+
function Ce(e, t, n) {
|
|
373
373
|
if (u.noDeprecation) return;
|
|
374
|
-
let
|
|
375
|
-
V.has(
|
|
374
|
+
let r = a(t);
|
|
375
|
+
V.has(r + `|` + e) || (V.add(r + `|` + e), u.emitWarning(`Use of deprecated trailing slash pattern mapping "${e}" in the "exports" field module resolution of the package at ${r}${n ? ` imported from ${a(n)}` : ``}. Mapping specifiers ending in "/" is no longer supported.`, `DeprecationWarning`, `DEP0155`));
|
|
376
376
|
}
|
|
377
377
|
function Y(e, t, n, r, i) {
|
|
378
378
|
let a = n.exports;
|
|
@@ -399,63 +399,63 @@ function Y(e, t, n, r, i) {
|
|
|
399
399
|
}
|
|
400
400
|
function X(e, t) {
|
|
401
401
|
let n = e.indexOf(`*`), r = t.indexOf(`*`), i = n === -1 ? e.length : n + 1, a = r === -1 ? t.length : r + 1;
|
|
402
|
-
return i > a ? -1 : a > i || n === -1 ? 1 : r === -1 || e.length > t.length ? -1 : t.length > e.length
|
|
403
|
-
}
|
|
404
|
-
function we(e,
|
|
405
|
-
if (e === `#` || e.startsWith(`#/`) || e.endsWith(`/`)) throw new C(e, `is not a valid internal imports specifier name`, t
|
|
406
|
-
let
|
|
407
|
-
if (
|
|
408
|
-
|
|
409
|
-
let
|
|
410
|
-
if (
|
|
411
|
-
let
|
|
412
|
-
if (
|
|
402
|
+
return i > a ? -1 : a > i || n === -1 ? 1 : r === -1 || e.length > t.length ? -1 : +(t.length > e.length);
|
|
403
|
+
}
|
|
404
|
+
function we(e, t, n) {
|
|
405
|
+
if (e === `#` || e.startsWith(`#/`) || e.endsWith(`/`)) throw new C(e, `is not a valid internal imports specifier name`, a(t));
|
|
406
|
+
let r, i = N(t);
|
|
407
|
+
if (i.exists) {
|
|
408
|
+
r = o(i.pjsonPath);
|
|
409
|
+
let a = i.imports;
|
|
410
|
+
if (a) if (I.call(a, e) && !e.includes(`*`)) {
|
|
411
|
+
let i = J(r, a[e], ``, e, t, !1, !0, !1, n);
|
|
412
|
+
if (i != null) return i;
|
|
413
413
|
} else {
|
|
414
|
-
let
|
|
414
|
+
let i = ``, o = ``, s = Object.getOwnPropertyNames(a), c = -1;
|
|
415
415
|
for (; ++c < s.length;) {
|
|
416
|
-
let t = s[c],
|
|
417
|
-
if (
|
|
418
|
-
let
|
|
419
|
-
e.length >= t.length && e.endsWith(
|
|
416
|
+
let t = s[c], n = t.indexOf(`*`);
|
|
417
|
+
if (n !== -1 && e.startsWith(t.slice(0, -1))) {
|
|
418
|
+
let r = t.slice(n + 1);
|
|
419
|
+
e.length >= t.length && e.endsWith(r) && X(i, t) === 1 && t.lastIndexOf(`*`) === n && (i = t, o = e.slice(n, e.length - r.length));
|
|
420
420
|
}
|
|
421
421
|
}
|
|
422
|
-
if (
|
|
423
|
-
let e =
|
|
422
|
+
if (i) {
|
|
423
|
+
let e = a[i], s = J(r, e, o, i, t, !0, !0, !1, n);
|
|
424
424
|
if (s != null) return s;
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
427
|
}
|
|
428
|
-
throw ve(e,
|
|
428
|
+
throw ve(e, r, t);
|
|
429
429
|
}
|
|
430
|
-
function Te(e,
|
|
431
|
-
let
|
|
432
|
-
e[0] === `@` && (
|
|
433
|
-
let o =
|
|
434
|
-
if (z.exec(o) !== null && (
|
|
430
|
+
function Te(e, t) {
|
|
431
|
+
let n = e.indexOf(`/`), r = !0, i = !1;
|
|
432
|
+
e[0] === `@` && (i = !0, n === -1 || e.length === 0 ? r = !1 : n = e.indexOf(`/`, n + 1));
|
|
433
|
+
let o = n === -1 ? e : e.slice(0, n);
|
|
434
|
+
if (z.exec(o) !== null && (r = !1), !r) throw new C(e, `is not a valid package name`, a(t));
|
|
435
435
|
return {
|
|
436
436
|
packageName: o,
|
|
437
|
-
packageSubpath: `.` + (
|
|
438
|
-
isScoped:
|
|
437
|
+
packageSubpath: `.` + (n === -1 ? `` : e.slice(n)),
|
|
438
|
+
isScoped: i
|
|
439
439
|
};
|
|
440
440
|
}
|
|
441
|
-
function Z(
|
|
442
|
-
if (m.includes(
|
|
443
|
-
let { packageName:
|
|
444
|
-
if (l.exists && l.name ===
|
|
445
|
-
let u = new
|
|
441
|
+
function Z(e, t, n) {
|
|
442
|
+
if (m.includes(e)) return new i(`node:` + e);
|
|
443
|
+
let { packageName: r, packageSubpath: s, isScoped: c } = Te(e, t), l = N(t);
|
|
444
|
+
if (l.exists && l.name === r && l.exports !== void 0 && l.exports !== null) return Y(o(l.pjsonPath), s, l, t, n);
|
|
445
|
+
let u = new i(`./node_modules/` + r + `/package.json`, t), d = a(u), f;
|
|
446
446
|
do {
|
|
447
|
-
let
|
|
448
|
-
if (!
|
|
449
|
-
f = d, u = new
|
|
447
|
+
let o = W(d.slice(0, -13));
|
|
448
|
+
if (!o || !o.isDirectory()) {
|
|
449
|
+
f = d, u = new i((c ? `../../../../node_modules/` : `../../../node_modules/`) + r + `/package.json`, u), d = a(u);
|
|
450
450
|
continue;
|
|
451
451
|
}
|
|
452
452
|
let l = M(d, {
|
|
453
|
-
base:
|
|
454
|
-
specifier:
|
|
453
|
+
base: t,
|
|
454
|
+
specifier: e
|
|
455
455
|
});
|
|
456
|
-
return l.exports !== void 0 && l.exports !== null ? Y(u, s, l,
|
|
456
|
+
return l.exports !== void 0 && l.exports !== null ? Y(u, s, l, t, n) : s === `.` ? ge(u, l, t) : new i(s, u);
|
|
457
457
|
} while (d.length !== f.length);
|
|
458
|
-
throw new T(
|
|
458
|
+
throw new T(r, a(t), !1);
|
|
459
459
|
}
|
|
460
460
|
function Ee(e) {
|
|
461
461
|
return e[0] === `.` && (e.length === 1 || e[1] === `/` || e[1] === `.` && (e.length === 2 || e[2] === `/`));
|
|
@@ -463,46 +463,46 @@ function Ee(e) {
|
|
|
463
463
|
function De(e) {
|
|
464
464
|
return e === `` ? !1 : e[0] === `/` ? !0 : Ee(e);
|
|
465
465
|
}
|
|
466
|
-
function Oe(t, n, r
|
|
467
|
-
let a =
|
|
468
|
-
if (De(
|
|
469
|
-
s = new e
|
|
470
|
-
} catch (
|
|
471
|
-
let r = new k(
|
|
472
|
-
throw r.cause =
|
|
466
|
+
function Oe(e, t, n, r) {
|
|
467
|
+
let a = t.protocol, o = a === `data:`, s;
|
|
468
|
+
if (De(e)) try {
|
|
469
|
+
s = new i(e, t);
|
|
470
|
+
} catch (n) {
|
|
471
|
+
let r = new k(e, t);
|
|
472
|
+
throw r.cause = n, r;
|
|
473
473
|
}
|
|
474
|
-
else if (a === `file:` &&
|
|
474
|
+
else if (a === `file:` && e[0] === `#`) s = we(e, t, n);
|
|
475
475
|
else try {
|
|
476
|
-
s = new e
|
|
477
|
-
} catch (
|
|
478
|
-
if (o && !m.includes(
|
|
479
|
-
let
|
|
480
|
-
throw
|
|
476
|
+
s = new i(e);
|
|
477
|
+
} catch (r) {
|
|
478
|
+
if (o && !m.includes(e)) {
|
|
479
|
+
let n = new k(e, t);
|
|
480
|
+
throw n.cause = r, n;
|
|
481
481
|
}
|
|
482
|
-
s = Z(t, n
|
|
482
|
+
s = Z(e, t, n);
|
|
483
483
|
}
|
|
484
|
-
return l.ok(s !== void 0, `expected to be defined`), s.protocol === `file:` ? _e(s,
|
|
484
|
+
return l.ok(s !== void 0, `expected to be defined`), s.protocol === `file:` ? _e(s, t, r) : s;
|
|
485
485
|
}
|
|
486
486
|
const ke = new Set([`node`, `import`]), Ae = process.platform === `win32`, je = globalThis.__EXSOLVE_CACHE__ ||= /* @__PURE__ */ new Map();
|
|
487
|
-
function Q(e,
|
|
488
|
-
let
|
|
489
|
-
if (`external` in
|
|
490
|
-
let
|
|
491
|
-
if (
|
|
487
|
+
function Q(e, r) {
|
|
488
|
+
let i = Be(e);
|
|
489
|
+
if (`external` in i) return i.external;
|
|
490
|
+
let a = i.specifier, s = i.url, c = i.absolutePath, l, u;
|
|
491
|
+
if (r?.cache !== !1 && (l = Le(c || a, r), u = r?.cache && typeof r?.cache == `object` ? r.cache : je), u) {
|
|
492
492
|
let e = u.get(l);
|
|
493
493
|
if (typeof e == `string`) return e;
|
|
494
494
|
if (e instanceof Error) {
|
|
495
|
-
if (
|
|
495
|
+
if (r?.try) return;
|
|
496
496
|
throw e;
|
|
497
497
|
}
|
|
498
498
|
}
|
|
499
499
|
if (c) try {
|
|
500
|
-
let e =
|
|
501
|
-
if (e.isSymbolicLink() && (c =
|
|
500
|
+
let e = t(c);
|
|
501
|
+
if (e.isSymbolicLink() && (c = n(c), s = o(c)), e.isFile()) return u && u.set(l, s.href), s.href;
|
|
502
502
|
} catch (e) {
|
|
503
503
|
if (e?.code !== `ENOENT`) throw u && u.set(l, e), e;
|
|
504
504
|
}
|
|
505
|
-
let d =
|
|
505
|
+
let d = r?.conditions ? new Set(r.conditions) : ke, f = a || s.href, p = Pe(r?.from), m = r?.suffixes || [``], h = r?.extensions ? [``, ...r.extensions] : [``], g;
|
|
506
506
|
for (let e of p) {
|
|
507
507
|
for (let t of m) {
|
|
508
508
|
let n = Re(f, t);
|
|
@@ -513,17 +513,17 @@ function Q(e, t) {
|
|
|
513
513
|
if (g) break;
|
|
514
514
|
}
|
|
515
515
|
if (!g) {
|
|
516
|
-
let
|
|
517
|
-
if (
|
|
518
|
-
throw
|
|
516
|
+
let t = Error(`Cannot resolve module "${e}" (from: ${p.map((e) => Ie(e)).join(`, `)})`);
|
|
517
|
+
if (t.code = `ERR_MODULE_NOT_FOUND`, u && u.set(l, t), r?.try) return;
|
|
518
|
+
throw t;
|
|
519
519
|
}
|
|
520
520
|
return u && u.set(l, g.href), g.href;
|
|
521
521
|
}
|
|
522
|
-
function Me(e,
|
|
523
|
-
let
|
|
524
|
-
if (!
|
|
525
|
-
let
|
|
526
|
-
return Ae ? ze(
|
|
522
|
+
function Me(e, t) {
|
|
523
|
+
let n = Q(e, t);
|
|
524
|
+
if (!n || !n.startsWith(`file://`) && t?.try) return;
|
|
525
|
+
let r = a(n);
|
|
526
|
+
return Ae ? ze(r) : r;
|
|
527
527
|
}
|
|
528
528
|
function Ne(e, t, n) {
|
|
529
529
|
try {
|
|
@@ -532,7 +532,7 @@ function Ne(e, t, n) {
|
|
|
532
532
|
}
|
|
533
533
|
function Pe(e) {
|
|
534
534
|
let t = (Array.isArray(e) ? e : [e]).flatMap((e) => Fe(e));
|
|
535
|
-
return t.length === 0 ? [
|
|
535
|
+
return t.length === 0 ? [o(`./`)] : t;
|
|
536
536
|
}
|
|
537
537
|
function Fe(e) {
|
|
538
538
|
if (!e) return [];
|
|
@@ -540,14 +540,14 @@ function Fe(e) {
|
|
|
540
540
|
if (typeof e != `string`) return [];
|
|
541
541
|
if (/^(?:node|data|http|https|file):/.test(e)) return new URL(e);
|
|
542
542
|
try {
|
|
543
|
-
return e.endsWith(`/`) ||
|
|
543
|
+
return e.endsWith(`/`) || r(e).isDirectory() ? o(e + `/`) : o(e);
|
|
544
544
|
} catch {
|
|
545
|
-
return [
|
|
545
|
+
return [o(e + `/`), o(e)];
|
|
546
546
|
}
|
|
547
547
|
}
|
|
548
548
|
function Ie(e) {
|
|
549
549
|
try {
|
|
550
|
-
return
|
|
550
|
+
return a(e);
|
|
551
551
|
} catch {
|
|
552
552
|
return e;
|
|
553
553
|
}
|
|
@@ -573,20 +573,20 @@ function $(e) {
|
|
|
573
573
|
function Be(e) {
|
|
574
574
|
if (typeof e == `string`) {
|
|
575
575
|
if (e.startsWith(`file:`)) {
|
|
576
|
-
let
|
|
576
|
+
let t = new URL(e);
|
|
577
577
|
return {
|
|
578
|
-
url:
|
|
579
|
-
absolutePath: t
|
|
578
|
+
url: t,
|
|
579
|
+
absolutePath: a(t)
|
|
580
580
|
};
|
|
581
581
|
}
|
|
582
582
|
return c(e) ? {
|
|
583
|
-
url:
|
|
583
|
+
url: o(e),
|
|
584
584
|
absolutePath: e
|
|
585
585
|
} : /^(?:node|data|http|https):/.test(e) ? { external: e } : m.includes(e) && !e.includes(`:`) ? { external: `node:${e}` } : { specifier: e };
|
|
586
586
|
}
|
|
587
587
|
if ($(e)) return e.protocol === `file:` ? {
|
|
588
588
|
url: e,
|
|
589
|
-
absolutePath:
|
|
589
|
+
absolutePath: a(e)
|
|
590
590
|
} : { external: e.href };
|
|
591
591
|
throw TypeError("id must be a `string` or `URL`");
|
|
592
592
|
}
|