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/dist/_chunks/trace.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { a as relative, i as normalize, n as isAbsolute, o as resolve, r as join, t as dirname } from "./libs/pathe.mjs";
|
|
2
|
+
import { t as resolveModulePath } from "./libs/exsolve.mjs";
|
|
2
3
|
import { createRequire } from "node:module";
|
|
3
4
|
import * as fsp from "node:fs/promises";
|
|
4
5
|
import { readFile, writeFile } from "node:fs/promises";
|
|
5
6
|
import { nodeFileTrace } from "@vercel/nft";
|
|
6
7
|
import semver from "semver";
|
|
7
|
-
//#region \0rolldown/runtime.js
|
|
8
8
|
var __defProp = Object.defineProperty;
|
|
9
9
|
var __exportAll = (all, no_symbols) => {
|
|
10
10
|
let target = {};
|
|
@@ -15,8 +15,6 @@ var __exportAll = (all, no_symbols) => {
|
|
|
15
15
|
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
16
16
|
return target;
|
|
17
17
|
};
|
|
18
|
-
//#endregion
|
|
19
|
-
//#region src/_utils.ts
|
|
20
18
|
const isWindows = process.platform === "win32";
|
|
21
19
|
const NODE_MODULES_RE = /^(?<dir>.+[\\/]node_modules[\\/])(?<name>[^@\\/]+|@[^\\/]+[\\/][^\\/]+)(?:[\\/](?<subpath>.+))?$/;
|
|
22
20
|
function parseNodeModulePath(path) {
|
|
@@ -87,8 +85,6 @@ function toPathRegExp(input) {
|
|
|
87
85
|
if (typeof input === "string") return new RegExp(pathRegExp(input));
|
|
88
86
|
throw new TypeError("Expected a string or RegExp", { cause: input });
|
|
89
87
|
}
|
|
90
|
-
//#endregion
|
|
91
|
-
//#region src/trace.ts
|
|
92
88
|
var trace_exports = /* @__PURE__ */ __exportAll({
|
|
93
89
|
DEFAULT_CONDITIONS: () => DEFAULT_CONDITIONS,
|
|
94
90
|
applyProductionCondition: () => applyProductionCondition,
|
|
@@ -163,22 +159,64 @@ async function traceNodeModules(input, opts) {
|
|
|
163
159
|
};
|
|
164
160
|
tracedPackage.versions[pkgJSON.version || "0.0.0"] = tracedPackageVersion;
|
|
165
161
|
const fullTraceEntry = resolveFullTraceEntry(opts.fullTraceInclude, pkgName);
|
|
166
|
-
if (fullTraceEntry) {
|
|
167
|
-
if (!fsp.glob) throw new Error("`fullTraceInclude` requires Node.js >= 22.0.0 (fs.promises.glob)");
|
|
168
|
-
const
|
|
169
|
-
for await (const file of fsp.glob(globPattern, {
|
|
162
|
+
if (fullTraceEntry) if (fullTraceEntry.glob) {
|
|
163
|
+
if (!fsp.glob) throw new Error("`fullTraceInclude` glob requires Node.js >= 22.0.0 (fs.promises.glob)");
|
|
164
|
+
for await (const file of fsp.glob(fullTraceEntry.glob, {
|
|
170
165
|
cwd: tracedFile.pkgPath,
|
|
171
166
|
exclude: (name) => name === "node_modules"
|
|
172
167
|
})) {
|
|
173
168
|
const fullPath = join(tracedFile.pkgPath, file);
|
|
174
169
|
if (await isFile(fullPath)) tracedPackageVersion.files.push(fullPath);
|
|
175
170
|
}
|
|
176
|
-
}
|
|
171
|
+
} else tracedPackageVersion.files.push(...await listPkgFiles(tracedFile.pkgPath));
|
|
177
172
|
}
|
|
178
173
|
tracedPackageVersion.files.push(tracedFile.path);
|
|
179
174
|
tracedFile.pkgName = pkgName;
|
|
180
175
|
if (pkgJSON.version) tracedFile.pkgVersion = pkgJSON.version;
|
|
181
176
|
}
|
|
177
|
+
for (const tracedPackage of Object.values(tracedPackages)) for (const versionEntry of Object.values(tracedPackage.versions)) {
|
|
178
|
+
const optionalDeps = versionEntry.pkgJSON.optionalDependencies;
|
|
179
|
+
if (!optionalDeps) continue;
|
|
180
|
+
for (const depName of Object.keys(optionalDeps)) {
|
|
181
|
+
if (tracedPackages[depName]) continue;
|
|
182
|
+
const resolved = resolveModulePath(depName + "/package.json", {
|
|
183
|
+
try: true,
|
|
184
|
+
from: versionEntry.path
|
|
185
|
+
});
|
|
186
|
+
if (!resolved) continue;
|
|
187
|
+
const depPath = dirname(resolved);
|
|
188
|
+
const depPkgJSON = await readJSON(resolved).catch(() => null);
|
|
189
|
+
if (!depPkgJSON) continue;
|
|
190
|
+
const depVersion = depPkgJSON.version || "0.0.0";
|
|
191
|
+
const files = await listPkgFiles(depPath);
|
|
192
|
+
tracedPackages[depName] = {
|
|
193
|
+
name: depName,
|
|
194
|
+
versions: { [depVersion]: {
|
|
195
|
+
path: depPath,
|
|
196
|
+
files,
|
|
197
|
+
pkgJSON: depPkgJSON
|
|
198
|
+
} }
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
const nativeLoaderRE = /(?:^|\/)(node-gyp-build(?:-optional-packages)?|bindings|prebuild-install|node-pre-gyp)$/;
|
|
203
|
+
for (const tracedPackage of Object.values(tracedPackages)) for (const versionEntry of Object.values(tracedPackage.versions)) {
|
|
204
|
+
const deps = {
|
|
205
|
+
...versionEntry.pkgJSON.dependencies,
|
|
206
|
+
...versionEntry.pkgJSON.devDependencies
|
|
207
|
+
};
|
|
208
|
+
if (!Object.keys(deps).some((d) => nativeLoaderRE.test(d)) && !versionEntry.pkgJSON.gypfile) {
|
|
209
|
+
const install = versionEntry.pkgJSON.scripts?.install;
|
|
210
|
+
if (!install || !/node-gyp|pre-gyp|prebuild|napi/.test(install)) continue;
|
|
211
|
+
}
|
|
212
|
+
if (fsp.glob) for await (const file of fsp.glob("**/*.node", {
|
|
213
|
+
cwd: versionEntry.path,
|
|
214
|
+
exclude: (name) => name === "node_modules"
|
|
215
|
+
})) {
|
|
216
|
+
const fullPath = join(versionEntry.path, file);
|
|
217
|
+
if (!versionEntry.files.includes(fullPath) && await isFile(fullPath)) versionEntry.files.push(fullPath);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
182
220
|
await opts?.hooks?.tracedPackages?.(tracedPackages);
|
|
183
221
|
const usedAliases = {};
|
|
184
222
|
const outDir = resolve(rootDir, opts.outDir || "dist", "node_modules");
|
|
@@ -290,6 +328,18 @@ function resolveFullTraceEntry(entries, pkgName) {
|
|
|
290
328
|
if (entry === pkgName) return {};
|
|
291
329
|
} else if (entry[0] === pkgName) return entry[1];
|
|
292
330
|
}
|
|
331
|
+
async function listPkgFiles(dir) {
|
|
332
|
+
const files = [];
|
|
333
|
+
for (const entry of await fsp.readdir(dir, {
|
|
334
|
+
recursive: true,
|
|
335
|
+
withFileTypes: true
|
|
336
|
+
})) {
|
|
337
|
+
const fullPath = join(entry.parentPath, entry.name);
|
|
338
|
+
if (fullPath.slice(dir.length).split("/").includes("node_modules")) continue;
|
|
339
|
+
if (entry.isFile() || entry.isSymbolicLink() && await isFile(fullPath)) files.push(fullPath);
|
|
340
|
+
}
|
|
341
|
+
return files;
|
|
342
|
+
}
|
|
293
343
|
async function isFile(file) {
|
|
294
344
|
try {
|
|
295
345
|
return (await fsp.stat(file)).isFile();
|
|
@@ -298,5 +348,4 @@ async function isFile(file) {
|
|
|
298
348
|
throw error;
|
|
299
349
|
}
|
|
300
350
|
}
|
|
301
|
-
//#endregion
|
|
302
351
|
export { pathRegExp as a, guessSubpath as i, traceNodeModules as n, toImport as o, trace_exports as r, toPathRegExp as s, DEFAULT_CONDITIONS as t };
|
package/dist/_chunks/types.d.mts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { t as PackageJson } from "./libs/pkg-types.mjs";
|
|
2
2
|
import { NodeFileTraceOptions, NodeFileTraceResult } from "@vercel/nft";
|
|
3
|
-
|
|
4
|
-
//#region src/types.d.ts
|
|
5
3
|
interface ExternalsPluginOptions {
|
|
6
4
|
/**
|
|
7
5
|
* The root directory to use when resolving files. Defaults to `process.cwd()`.
|
|
@@ -115,5 +113,4 @@ interface TraceHooks {
|
|
|
115
113
|
tracedFiles?: (files: Record<string, TracedFile>) => void | Promise<void>;
|
|
116
114
|
tracedPackages?: (packages: Record<string, TracedPackage>) => void | Promise<void>;
|
|
117
115
|
}
|
|
118
|
-
//#endregion
|
|
119
116
|
export { ExternalsTraceOptions as n, ExternalsPluginOptions as t };
|
package/dist/db.d.mts
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
//#region src/db.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Known packages that include native code and require platform-specific builds.
|
|
4
3
|
*
|
|
5
4
|
* These packages cannot be bundled and should be traced as external dependencies most of the time.
|
|
6
5
|
*/
|
|
7
6
|
declare const NodeNativePackages: readonly string[];
|
|
7
|
+
/**
|
|
8
|
+
* Packages that should be fully traced (all files copied, not just NFT-detected ones).
|
|
9
|
+
*
|
|
10
|
+
* These packages use dynamic requires, runtime asset loading, or other patterns
|
|
11
|
+
* that prevent static analysis from detecting all required files.
|
|
12
|
+
* Can be passed to the plugin's `traceInclude` option to ensure they are always traced.
|
|
13
|
+
*/
|
|
14
|
+
declare const FullTracePackages: readonly ["usb", "sodium-native", "aws-crt", "youch"];
|
|
8
15
|
/**
|
|
9
16
|
* Packages that must be externalized (traced as dependencies) rather than bundled,
|
|
10
17
|
* due to bundler compatibility issues with their module format or dynamic imports.
|
|
11
18
|
*/
|
|
12
19
|
declare const NonBundleablePackages: string[];
|
|
13
|
-
|
|
14
|
-
export { NodeNativePackages, NonBundleablePackages };
|
|
20
|
+
export { FullTracePackages, NodeNativePackages, NonBundleablePackages };
|
package/dist/db.mjs
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
//#region src/db.ts
|
|
2
|
-
/**
|
|
3
|
-
* Known packages that include native code and require platform-specific builds.
|
|
4
|
-
*
|
|
5
|
-
* These packages cannot be bundled and should be traced as external dependencies most of the time.
|
|
6
|
-
*/
|
|
7
1
|
const NodeNativePackages = Object.freeze([
|
|
8
2
|
"canvas",
|
|
9
3
|
"sharp",
|
|
@@ -12,6 +6,7 @@ const NodeNativePackages = Object.freeze([
|
|
|
12
6
|
"@napi-rs/canvas",
|
|
13
7
|
"@napi-rs/image",
|
|
14
8
|
"@takumi-rs/core",
|
|
9
|
+
"@resvg/resvg-js",
|
|
15
10
|
"bcrypt",
|
|
16
11
|
"kerberos",
|
|
17
12
|
"scrypt",
|
|
@@ -20,40 +15,93 @@ const NodeNativePackages = Object.freeze([
|
|
|
20
15
|
"argon2",
|
|
21
16
|
"@node-rs/argon2",
|
|
22
17
|
"@node-rs/bcrypt",
|
|
18
|
+
"@node-rs/jsonwebtoken",
|
|
23
19
|
"cpu-features",
|
|
24
20
|
"farmhash",
|
|
25
21
|
"@node-rs/xxhash",
|
|
26
22
|
"@node-rs/crc32",
|
|
23
|
+
"bigint-buffer",
|
|
24
|
+
"keytar",
|
|
27
25
|
"better-sqlite3",
|
|
26
|
+
"better-sqlite3-multiple-ciphers",
|
|
27
|
+
"sqlite3",
|
|
28
28
|
"leveldown",
|
|
29
|
+
"classic-level",
|
|
29
30
|
"lmdb",
|
|
30
|
-
"sqlite3",
|
|
31
31
|
"libsql",
|
|
32
|
-
"node-rdkafka",
|
|
33
|
-
"couchbase",
|
|
34
32
|
"duckdb",
|
|
33
|
+
"rocksdb",
|
|
34
|
+
"level-rocksdb",
|
|
35
|
+
"pg-native",
|
|
36
|
+
"oracledb",
|
|
37
|
+
"mongodb-client-encryption",
|
|
38
|
+
"odbc",
|
|
39
|
+
"ibm_db",
|
|
40
|
+
"hiredis",
|
|
41
|
+
"couchbase",
|
|
35
42
|
"realm",
|
|
43
|
+
"node-rdkafka",
|
|
36
44
|
"lz4",
|
|
45
|
+
"lz4-napi",
|
|
37
46
|
"zlib-sync",
|
|
38
47
|
"snappy",
|
|
39
48
|
"@napi-rs/snappy",
|
|
40
|
-
"@napi-rs/
|
|
41
|
-
"msgpackr-extract",
|
|
49
|
+
"@napi-rs/lzma",
|
|
42
50
|
"@mongodb-js/zstd",
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"@parcel/watcher",
|
|
47
|
-
"@parcel/source-map",
|
|
48
|
-
"@mapbox/node-pre-gyp",
|
|
49
|
-
"@swc/core",
|
|
51
|
+
"msgpackr-extract",
|
|
52
|
+
"cbor-extract",
|
|
53
|
+
"@napi-rs/tar",
|
|
50
54
|
"esbuild",
|
|
55
|
+
"rolldown",
|
|
56
|
+
"vite",
|
|
57
|
+
"@rspack/core",
|
|
58
|
+
"@swc/core",
|
|
59
|
+
"@swc-node/register",
|
|
51
60
|
"lightningcss",
|
|
61
|
+
"@parcel/css",
|
|
62
|
+
"@parcel/watcher",
|
|
63
|
+
"@parcel/source-map",
|
|
52
64
|
"@biomejs/biome",
|
|
65
|
+
"oxfmt",
|
|
66
|
+
"oxlint",
|
|
67
|
+
"oxc-parser",
|
|
68
|
+
"oxc-transform",
|
|
69
|
+
"oxc-resolver",
|
|
70
|
+
"@ast-grep/napi",
|
|
71
|
+
"@napi-rs/cli",
|
|
72
|
+
"@node-rs/deno-lint",
|
|
73
|
+
"vize",
|
|
74
|
+
"node-sass",
|
|
53
75
|
"tree-sitter",
|
|
54
76
|
"re2",
|
|
77
|
+
"rollup",
|
|
78
|
+
"sass-embedded",
|
|
79
|
+
"@tailwindcss/oxide",
|
|
80
|
+
"turbo",
|
|
81
|
+
"deasync",
|
|
82
|
+
"@xenova/transformers",
|
|
83
|
+
"node-llama-cpp",
|
|
84
|
+
"llama-node",
|
|
55
85
|
"onnxruntime-node",
|
|
56
|
-
"
|
|
86
|
+
"@tensorflow/tfjs-node",
|
|
87
|
+
"@sentry/profiling-node",
|
|
88
|
+
"@datadog/native-metrics",
|
|
89
|
+
"@datadog/native-appsec",
|
|
90
|
+
"@datadog/native-iast-taint-tracking",
|
|
91
|
+
"@datadog/pprof",
|
|
92
|
+
"@newrelic/native-metrics",
|
|
93
|
+
"@appsignal/nodejs",
|
|
94
|
+
"@statsig/statsig-node-core",
|
|
95
|
+
"v8-profiler-next",
|
|
96
|
+
"heapdump",
|
|
97
|
+
"grpc",
|
|
98
|
+
"zeromq",
|
|
99
|
+
"unix-dgram",
|
|
100
|
+
"ssh2",
|
|
101
|
+
"aws-crt",
|
|
102
|
+
"node-libcurl",
|
|
103
|
+
"bufferutil",
|
|
104
|
+
"utf-8-validate",
|
|
57
105
|
"fsevents",
|
|
58
106
|
"node-pty",
|
|
59
107
|
"usb",
|
|
@@ -65,41 +113,36 @@ const NodeNativePackages = Object.freeze([
|
|
|
65
113
|
"microtime",
|
|
66
114
|
"node-datachannel",
|
|
67
115
|
"zigpty",
|
|
116
|
+
"edge-js",
|
|
117
|
+
"nsfw",
|
|
118
|
+
"native-reg",
|
|
119
|
+
"diskusage",
|
|
120
|
+
"@napi-rs/clipboard",
|
|
121
|
+
"@napi-rs/nice",
|
|
122
|
+
"@napi-rs/webcodecs",
|
|
123
|
+
"workerd",
|
|
124
|
+
"node-web-audio-api",
|
|
68
125
|
"ffi-napi",
|
|
69
126
|
"ref-napi",
|
|
70
127
|
"ref-struct-napi",
|
|
71
128
|
"ref-union-napi",
|
|
72
|
-
"
|
|
73
|
-
"zeromq",
|
|
74
|
-
"unix-dgram",
|
|
75
|
-
"ssh2",
|
|
129
|
+
"iconv",
|
|
76
130
|
"libxmljs2",
|
|
77
131
|
"node-expat",
|
|
78
|
-
"@
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"utf-8-validate",
|
|
82
|
-
"keytar",
|
|
83
|
-
"iconv",
|
|
132
|
+
"@node-rs/jieba",
|
|
133
|
+
"md4x/napi",
|
|
134
|
+
"@discordjs/opus",
|
|
84
135
|
"nodegit",
|
|
85
|
-
"
|
|
86
|
-
"turbo-crc32",
|
|
87
|
-
"@napi-rs/clipboard",
|
|
88
|
-
"better-sqlite3-multiple-ciphers",
|
|
89
|
-
"pdfium.js",
|
|
90
|
-
"cbor-extract",
|
|
91
|
-
"diskusage",
|
|
92
|
-
"nsfw",
|
|
93
|
-
"native-reg",
|
|
94
|
-
"integer",
|
|
95
|
-
"spawn-sync",
|
|
96
|
-
"md4x/napi"
|
|
136
|
+
"integer"
|
|
97
137
|
]);
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
138
|
+
const FullTracePackages = [
|
|
139
|
+
"usb",
|
|
140
|
+
"sodium-native",
|
|
141
|
+
"aws-crt",
|
|
142
|
+
"youch"
|
|
143
|
+
];
|
|
102
144
|
const NonBundleablePackages = [
|
|
145
|
+
"youch",
|
|
103
146
|
"pg-native",
|
|
104
147
|
"typeorm",
|
|
105
148
|
"prisma",
|
|
@@ -111,7 +154,12 @@ const NonBundleablePackages = [
|
|
|
111
154
|
"@vercel/node",
|
|
112
155
|
"puppeteer",
|
|
113
156
|
"playwright",
|
|
114
|
-
"
|
|
157
|
+
"playwright-core",
|
|
158
|
+
"puppeteer-core",
|
|
159
|
+
"vscode-oniguruma",
|
|
160
|
+
"tslib",
|
|
161
|
+
"@highlight-run/node",
|
|
162
|
+
"import-in-the-middle",
|
|
163
|
+
"require-in-the-middle"
|
|
115
164
|
];
|
|
116
|
-
|
|
117
|
-
export { NodeNativePackages, NonBundleablePackages };
|
|
165
|
+
export { FullTracePackages, NodeNativePackages, NonBundleablePackages };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { NodeNativePackages } from "./db.mjs";
|
|
2
2
|
import { n as ExternalsTraceOptions } from "./_chunks/types.mjs";
|
|
3
|
-
|
|
4
|
-
//#region src/trace.d.ts
|
|
5
3
|
declare function traceNodeModules(input: string[], opts: ExternalsTraceOptions): Promise<void>;
|
|
6
|
-
//#endregion
|
|
7
4
|
export { type ExternalsTraceOptions, NodeNativePackages, traceNodeModules };
|