nf3 0.3.14 → 0.3.15
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 +42 -5
- package/dist/db.d.mts +9 -1
- package/dist/db.mjs +28 -10
- 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/package.json +10 -10
package/dist/_chunks/trace.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
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";
|
|
@@ -163,22 +164,46 @@ async function traceNodeModules(input, opts) {
|
|
|
163
164
|
};
|
|
164
165
|
tracedPackage.versions[pkgJSON.version || "0.0.0"] = tracedPackageVersion;
|
|
165
166
|
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, {
|
|
167
|
+
if (fullTraceEntry) if (fullTraceEntry.glob) {
|
|
168
|
+
if (!fsp.glob) throw new Error("`fullTraceInclude` glob requires Node.js >= 22.0.0 (fs.promises.glob)");
|
|
169
|
+
for await (const file of fsp.glob(fullTraceEntry.glob, {
|
|
170
170
|
cwd: tracedFile.pkgPath,
|
|
171
171
|
exclude: (name) => name === "node_modules"
|
|
172
172
|
})) {
|
|
173
173
|
const fullPath = join(tracedFile.pkgPath, file);
|
|
174
174
|
if (await isFile(fullPath)) tracedPackageVersion.files.push(fullPath);
|
|
175
175
|
}
|
|
176
|
-
}
|
|
176
|
+
} else tracedPackageVersion.files.push(...await listPkgFiles(tracedFile.pkgPath));
|
|
177
177
|
}
|
|
178
178
|
tracedPackageVersion.files.push(tracedFile.path);
|
|
179
179
|
tracedFile.pkgName = pkgName;
|
|
180
180
|
if (pkgJSON.version) tracedFile.pkgVersion = pkgJSON.version;
|
|
181
181
|
}
|
|
182
|
+
for (const tracedPackage of Object.values(tracedPackages)) for (const versionEntry of Object.values(tracedPackage.versions)) {
|
|
183
|
+
const optionalDeps = versionEntry.pkgJSON.optionalDependencies;
|
|
184
|
+
if (!optionalDeps) continue;
|
|
185
|
+
for (const depName of Object.keys(optionalDeps)) {
|
|
186
|
+
if (tracedPackages[depName]) continue;
|
|
187
|
+
const resolved = resolveModulePath(depName + "/package.json", {
|
|
188
|
+
try: true,
|
|
189
|
+
from: versionEntry.path
|
|
190
|
+
});
|
|
191
|
+
if (!resolved) continue;
|
|
192
|
+
const depPath = dirname(resolved);
|
|
193
|
+
const depPkgJSON = await readJSON(resolved).catch(() => null);
|
|
194
|
+
if (!depPkgJSON) continue;
|
|
195
|
+
const depVersion = depPkgJSON.version || "0.0.0";
|
|
196
|
+
const files = await listPkgFiles(depPath);
|
|
197
|
+
tracedPackages[depName] = {
|
|
198
|
+
name: depName,
|
|
199
|
+
versions: { [depVersion]: {
|
|
200
|
+
path: depPath,
|
|
201
|
+
files,
|
|
202
|
+
pkgJSON: depPkgJSON
|
|
203
|
+
} }
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
}
|
|
182
207
|
await opts?.hooks?.tracedPackages?.(tracedPackages);
|
|
183
208
|
const usedAliases = {};
|
|
184
209
|
const outDir = resolve(rootDir, opts.outDir || "dist", "node_modules");
|
|
@@ -290,6 +315,18 @@ function resolveFullTraceEntry(entries, pkgName) {
|
|
|
290
315
|
if (entry === pkgName) return {};
|
|
291
316
|
} else if (entry[0] === pkgName) return entry[1];
|
|
292
317
|
}
|
|
318
|
+
async function listPkgFiles(dir) {
|
|
319
|
+
const files = [];
|
|
320
|
+
for (const entry of await fsp.readdir(dir, {
|
|
321
|
+
recursive: true,
|
|
322
|
+
withFileTypes: true
|
|
323
|
+
})) {
|
|
324
|
+
const fullPath = join(entry.parentPath, entry.name);
|
|
325
|
+
if (fullPath.slice(dir.length).split("/").includes("node_modules")) continue;
|
|
326
|
+
if (entry.isFile() || entry.isSymbolicLink() && await isFile(fullPath)) files.push(fullPath);
|
|
327
|
+
}
|
|
328
|
+
return files;
|
|
329
|
+
}
|
|
293
330
|
async function isFile(file) {
|
|
294
331
|
try {
|
|
295
332
|
return (await fsp.stat(file)).isFile();
|
package/dist/db.d.mts
CHANGED
|
@@ -5,10 +5,18 @@
|
|
|
5
5
|
* These packages cannot be bundled and should be traced as external dependencies most of the time.
|
|
6
6
|
*/
|
|
7
7
|
declare const NodeNativePackages: readonly string[];
|
|
8
|
+
/**
|
|
9
|
+
* Packages that should be fully traced (all files copied, not just NFT-detected ones).
|
|
10
|
+
*
|
|
11
|
+
* These packages use dynamic requires, runtime asset loading, or other patterns
|
|
12
|
+
* that prevent static analysis from detecting all required files.
|
|
13
|
+
* Can be passed to the plugin's `traceInclude` option to ensure they are always traced.
|
|
14
|
+
*/
|
|
15
|
+
declare const FullTracePackages: readonly ["usb", "sodium-native", "aws-crt", "youch"];
|
|
8
16
|
/**
|
|
9
17
|
* Packages that must be externalized (traced as dependencies) rather than bundled,
|
|
10
18
|
* due to bundler compatibility issues with their module format or dynamic imports.
|
|
11
19
|
*/
|
|
12
20
|
declare const NonBundleablePackages: string[];
|
|
13
21
|
//#endregion
|
|
14
|
-
export { NodeNativePackages, NonBundleablePackages };
|
|
22
|
+
export { FullTracePackages, NodeNativePackages, NonBundleablePackages };
|
package/dist/db.mjs
CHANGED
|
@@ -37,15 +37,13 @@ const NodeNativePackages = Object.freeze([
|
|
|
37
37
|
"zlib-sync",
|
|
38
38
|
"snappy",
|
|
39
39
|
"@napi-rs/snappy",
|
|
40
|
-
"
|
|
40
|
+
"lz4-napi",
|
|
41
41
|
"msgpackr-extract",
|
|
42
42
|
"@mongodb-js/zstd",
|
|
43
43
|
"deasync",
|
|
44
|
-
"node-gyp",
|
|
45
44
|
"node-sass",
|
|
46
45
|
"@parcel/watcher",
|
|
47
46
|
"@parcel/source-map",
|
|
48
|
-
"@mapbox/node-pre-gyp",
|
|
49
47
|
"@swc/core",
|
|
50
48
|
"esbuild",
|
|
51
49
|
"lightningcss",
|
|
@@ -73,33 +71,47 @@ const NodeNativePackages = Object.freeze([
|
|
|
73
71
|
"zeromq",
|
|
74
72
|
"unix-dgram",
|
|
75
73
|
"ssh2",
|
|
74
|
+
"aws-crt",
|
|
76
75
|
"libxmljs2",
|
|
77
76
|
"node-expat",
|
|
78
77
|
"@xenova/transformers",
|
|
79
|
-
"@llama-node/llama-cpp",
|
|
80
78
|
"bufferutil",
|
|
81
79
|
"utf-8-validate",
|
|
82
80
|
"keytar",
|
|
83
81
|
"iconv",
|
|
84
82
|
"nodegit",
|
|
85
83
|
"@sentry/profiling-node",
|
|
86
|
-
"turbo-crc32",
|
|
87
84
|
"@napi-rs/clipboard",
|
|
88
85
|
"better-sqlite3-multiple-ciphers",
|
|
89
|
-
"pdfium.js",
|
|
90
86
|
"cbor-extract",
|
|
91
87
|
"diskusage",
|
|
92
88
|
"nsfw",
|
|
93
89
|
"native-reg",
|
|
94
90
|
"integer",
|
|
95
|
-
"
|
|
96
|
-
"
|
|
91
|
+
"md4x/napi",
|
|
92
|
+
"node-web-audio-api",
|
|
93
|
+
"@appsignal/nodejs",
|
|
94
|
+
"@statsig/statsig-node-core"
|
|
97
95
|
]);
|
|
98
96
|
/**
|
|
97
|
+
* Packages that should be fully traced (all files copied, not just NFT-detected ones).
|
|
98
|
+
*
|
|
99
|
+
* These packages use dynamic requires, runtime asset loading, or other patterns
|
|
100
|
+
* that prevent static analysis from detecting all required files.
|
|
101
|
+
* Can be passed to the plugin's `traceInclude` option to ensure they are always traced.
|
|
102
|
+
*/
|
|
103
|
+
const FullTracePackages = [
|
|
104
|
+
"usb",
|
|
105
|
+
"sodium-native",
|
|
106
|
+
"aws-crt",
|
|
107
|
+
"youch"
|
|
108
|
+
];
|
|
109
|
+
/**
|
|
99
110
|
* Packages that must be externalized (traced as dependencies) rather than bundled,
|
|
100
111
|
* due to bundler compatibility issues with their module format or dynamic imports.
|
|
101
112
|
*/
|
|
102
113
|
const NonBundleablePackages = [
|
|
114
|
+
"youch",
|
|
103
115
|
"pg-native",
|
|
104
116
|
"typeorm",
|
|
105
117
|
"prisma",
|
|
@@ -111,7 +123,13 @@ const NonBundleablePackages = [
|
|
|
111
123
|
"@vercel/node",
|
|
112
124
|
"puppeteer",
|
|
113
125
|
"playwright",
|
|
114
|
-
"
|
|
126
|
+
"playwright-core",
|
|
127
|
+
"puppeteer-core",
|
|
128
|
+
"vscode-oniguruma",
|
|
129
|
+
"tslib",
|
|
130
|
+
"@highlight-run/node",
|
|
131
|
+
"import-in-the-middle",
|
|
132
|
+
"require-in-the-middle"
|
|
115
133
|
];
|
|
116
134
|
//#endregion
|
|
117
|
-
export { NodeNativePackages, NonBundleablePackages };
|
|
135
|
+
export { FullTracePackages, NodeNativePackages, NonBundleablePackages };
|