nf3 0.3.5 → 0.3.6

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 CHANGED
@@ -90,14 +90,20 @@ rollupNodeFileTrace({
90
90
  });
91
91
  ```
92
92
 
93
- ## Native packages DB
93
+ ## Packages DB
94
94
 
95
- nf3 exports a list of known packages that include native code and require platform-specific builds.
95
+ NF3 exports a list of known packages that include native code and require platform-specific builds.
96
96
 
97
97
  These packages cannot be bundled and should be traced as external dependencies most of the time and often need tracing.
98
98
 
99
99
  ```js
100
- import { nodeNativePackages } from "nf3/db";
100
+ import { NodeNativePackages } from "nf3/db";
101
+ ```
102
+
103
+ 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.
104
+
105
+ ```js
106
+ import { NonBundleablePackages } from "nf3/db";
101
107
  ```
102
108
 
103
109
  ## Development
@@ -0,0 +1 @@
1
+ interface PackageJson{name?:string;version?:string;description?:string;keywords?:string[];homepage?:string;bugs?:string|{url?:string;email?:string;};license?:string;repository?:string|{type:string;url:string;directory?:string;};scripts?:PackageJsonScripts;private?:boolean;author?:PackageJsonPerson;contributors?:PackageJsonPerson[];funding?:PackageJsonFunding|PackageJsonFunding[];files?:string[];main?:string;browser?:string|Record<string,string|false>;unpkg?:string;bin?:string|Record<string,string>;man?:string|string[];dependencies?:Record<string,string>;devDependencies?:Record<string,string>;optionalDependencies?:Record<string,string>;peerDependencies?:Record<string,string>;types?:string;typings?:string;module?:string;type?:`module`|`commonjs`;exports?:PackageJsonExports;imports?:Record<string,string|Record<string,string>>;workspaces?:string[]|{packages?:string[];nohoist?:string[];};typesVersions?:Record<string,Record<string,string[]>>;os?:string[];cpu?:string[];publishConfig?:{registry?:string;tag?:string;access?:`public`|`restricted`;executableFiles?:string[];directory?:string;linkDirectory?:boolean;}&Pick<PackageJson,`bin`|`main`|`exports`|`types`|`typings`|`module`|`browser`|`unpkg`|`typesVersions`|`os`|`cpu`>;packageManager?:string;[key:string]:any;}type PackageJsonScriptWithPreAndPost<e extends string>=e|`${`pre`|`post`}${e}`;type PackageJsonNpmLifeCycleScripts=`dependencies`|`prepublishOnly`|PackageJsonScriptWithPreAndPost<`install`|`pack`|`prepare`|`publish`|`restart`|`start`|`stop`|`test`|`version`>;type PackageJsonPnpmLifeCycleScripts=`pnpm:devPreinstall`;type PackageJsonCommonScripts=`build`|`coverage`|`deploy`|`dev`|`format`|`lint`|`preview`|`release`|`typecheck`|`watch`;type PackageJsonScriptName=PackageJsonCommonScripts|PackageJsonNpmLifeCycleScripts|PackageJsonPnpmLifeCycleScripts|(string&{});type PackageJsonScripts={[e in PackageJsonScriptName]?:string};type PackageJsonPerson=string|{name:string;email?:string;url?:string;};type PackageJsonFunding=string|{url:string;type?:string;};type PackageJsonExportKey=`.`|`import`|`require`|`types`|`node`|`browser`|`default`|(string&{});type PackageJsonExportsObject={[e in PackageJsonExportKey]?:string|PackageJsonExportsObject|Array<string|PackageJsonExportsObject>};type PackageJsonExports=string|PackageJsonExportsObject|Array<string|PackageJsonExportsObject>;export{PackageJson as t};
@@ -27,7 +27,7 @@ function guessSubpath(path, conditions) {
27
27
  if (!conditions.includes(e.condition || "default")) continue;
28
28
  if (e.fsPath === subpath) return join(name, e.subpath);
29
29
  if (e.fsPath.includes("*")) {
30
- const fsPathRe = /* @__PURE__ */ new RegExp("^" + escapeRegExp(e.fsPath).replace(String.raw`\*`, "(.+?)") + "$");
30
+ const fsPathRe = new RegExp("^" + escapeRegExp(e.fsPath).replace(String.raw`\*`, "(.+?)") + "$");
31
31
  if (fsPathRe.test(subpath)) {
32
32
  const matched = fsPathRe.exec(subpath)?.[1];
33
33
  if (matched) return join(name, e.subpath.replace("*", matched));
@@ -99,7 +99,7 @@ async function traceNodeModules(input, opts) {
99
99
  ...opts.nft
100
100
  });
101
101
  await opts?.hooks?.traceResult?.(traceResult);
102
- const _resolveTracedPath = (p) => promises.realpath(resolve(opts.nft?.base || "/", p)).then((p$1) => normalize(p$1));
102
+ const _resolveTracedPath = (p) => promises.realpath(resolve(opts.nft?.base || "/", p)).then((p) => normalize(p));
103
103
  const tracedFiles = Object.fromEntries(await Promise.all([...traceResult.reasons.entries()].map(async ([_path, reasons]) => {
104
104
  if (reasons.ignored) return;
105
105
  const path = await _resolveTracedPath(_path);
@@ -4,69 +4,69 @@ import { NodeFileTraceOptions, NodeFileTraceResult } from "@vercel/nft";
4
4
  //#region src/types.d.ts
5
5
  interface ExternalsPluginOptions {
6
6
  /**
7
- * The root directory to use when resolving files. Defaults to `process.cwd()`.
8
- */
7
+ * The root directory to use when resolving files. Defaults to `process.cwd()`.
8
+ */
9
9
  rootDir?: string;
10
10
  /**
11
- * Patterns to trace or externalize.
12
- */
11
+ * Patterns to trace or externalize.
12
+ */
13
13
  include?: (string | RegExp)[];
14
14
  /**
15
- * Patterns to exclude from tracing or externalizing (makes them to be bundled).
16
- */
15
+ * Patterns to exclude from tracing or externalizing (makes them to be bundled).
16
+ */
17
17
  exclude?: (string | RegExp)[];
18
18
  /**
19
- *
20
- * Tracing options.
21
- *
22
- * If `false`, disables automatic tracing of `node_modules` dependencies and keeps them as absolute external paths.
23
- */
19
+ *
20
+ * Tracing options.
21
+ *
22
+ * If `false`, disables automatic tracing of `node_modules` dependencies and keeps them as absolute external paths.
23
+ */
24
24
  trace?: boolean | ExternalsTraceOptions;
25
25
  /**
26
- * Patterns to force trace even if not resolved.
27
- */
26
+ * Patterns to force trace even if not resolved.
27
+ */
28
28
  traceInclude?: string[];
29
29
  /**
30
- * Resolve conditions to use when resolving packages. Defaults to `["node", "import", "default"]`
31
- */
30
+ * Resolve conditions to use when resolving packages. Defaults to `["node", "import", "default"]`
31
+ */
32
32
  conditions?: string[];
33
33
  }
34
34
  interface ExternalsTraceOptions {
35
35
  /**
36
- * The root directory to use when resolving files. Defaults to `process.cwd()`.
37
- */
36
+ * The root directory to use when resolving files. Defaults to `process.cwd()`.
37
+ */
38
38
  rootDir?: string;
39
39
  /**
40
- * The output directory where traced files will be copied. Defaults to `dist`.
41
- */
40
+ * The output directory where traced files will be copied. Defaults to `dist`.
41
+ */
42
42
  outDir?: string;
43
43
  /**
44
- * Options to pass to `@vercel/nft` for file tracing.
45
- *
46
- * @see https://github.com/vercel/nft#options
47
- */
44
+ * Options to pass to `@vercel/nft` for file tracing.
45
+ *
46
+ * @see https://github.com/vercel/nft#options
47
+ */
48
48
  nft?: NodeFileTraceOptions;
49
49
  /**
50
- * Module resolution conditions to use when resolving packages.
51
- *
52
- * Defaults to `["node", "import", "default"]`
53
- */
50
+ * Module resolution conditions to use when resolving packages.
51
+ *
52
+ * Defaults to `["node", "import", "default"]`
53
+ */
54
54
  conditions?: string[];
55
55
  /**
56
- * Alias for module paths when tracing files.
57
- */
56
+ * Alias for module paths when tracing files.
57
+ */
58
58
  traceAlias?: Record<string, string>;
59
59
  /**
60
- * Preserve file permissions when copying files. If set to `true`, original file permissions are preserved. If set to a number, that value is used as the permission mode (e.g., `0o755`).
61
- */
60
+ * Preserve file permissions when copying files. If set to `true`, original file permissions are preserved. If set to a number, that value is used as the permission mode (e.g., `0o755`).
61
+ */
62
62
  chmod?: boolean | number;
63
63
  /**
64
- * If `true`, writes a `package.json` file to the output directory (parent) with the traced files as dependencies.
65
- */
64
+ * If `true`, writes a `package.json` file to the output directory (parent) with the traced files as dependencies.
65
+ */
66
66
  writePackageJson?: boolean;
67
67
  /**
68
- * Hook functions for allow extending tracing behavior.
69
- */
68
+ * Hook functions for allow extending tracing behavior.
69
+ */
70
70
  hooks?: TraceHooks;
71
71
  /** Transform traced files */
72
72
  transform?: Transformer[];
package/dist/db.d.mts CHANGED
@@ -5,5 +5,10 @@
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 must be externalized (traced as dependencies) rather than bundled,
10
+ * due to bundler compatibility issues with their module format or dynamic imports.
11
+ */
12
+ declare const NonBundleablePackages: string[];
8
13
  //#endregion
9
- export { NodeNativePackages };
14
+ export { NodeNativePackages, NonBundleablePackages };
package/dist/db.mjs CHANGED
@@ -18,6 +18,7 @@ const NodeNativePackages = Object.freeze([
18
18
  "lmdb",
19
19
  "sqlite3",
20
20
  "lz4",
21
+ "zlib-sync",
21
22
  "deasync",
22
23
  "node-gyp",
23
24
  "node-sass",
@@ -37,6 +38,11 @@ const NodeNativePackages = Object.freeze([
37
38
  "utf-8-validate",
38
39
  "keytar"
39
40
  ]);
41
+ /**
42
+ * Packages that must be externalized (traced as dependencies) rather than bundled,
43
+ * due to bundler compatibility issues with their module format or dynamic imports.
44
+ */
45
+ const NonBundleablePackages = ["pg", "sequelize"];
40
46
 
41
47
  //#endregion
42
- export { NodeNativePackages };
48
+ export { NodeNativePackages, NonBundleablePackages };
@@ -1 +1 @@
1
- "use strict";var __createBinding=this&&this.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),__importStar=this&&this.__importStar||(function(){var n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},n(e)};return function(r){if(r&&r.__esModule)return r;var i={};if(r!=null)for(var a=n(r),o=0;o<a.length;o++)a[o]!==`default`&&__createBinding(i,r,a[o]);return __setModuleDefault(i,r),i}})(),__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,`__esModule`,{value:!0}),exports.Job=void 0,exports.nodeFileTrace=nodeFileTrace;const path_1=require(`path`),analyze_1=__importDefault(require(`./analyze`)),resolve_dependency_1=__importStar(require(`./resolve-dependency`)),picomatch_1=require(`picomatch`),sharedlib_emit_1=require(`./utils/sharedlib-emit`),fs_1=require(`./fs`);function inPath(e,t){let n=(0,path_1.join)(t,path_1.sep);return e.startsWith(n)&&e!==n}async function nodeFileTrace(e,t={}){let n=new Job(t);return t.readFile&&(n.readFile=t.readFile),t.stat&&(n.stat=t.stat),t.readlink&&(n.readlink=t.readlink),t.resolve&&(n.resolve=t.resolve),n.ts=!0,await Promise.all(e.map(async e=>{let t=(0,path_1.resolve)(e);return await n.emitFile(t,`initial`),n.emitDependency(t)})),{fileList:n.fileList,esmFileList:n.esmFileList,reasons:n.reasons,warnings:n.warnings}}class Job{ts;base;cwd;conditions;exportsOnly;paths;ignoreFn;log;mixedModules;analysis;analysisCache;fileList;esmFileList;processed;warnings;reasons=new Map;cachedFileSystem;remappings=new Map;constructor({base:e=process.cwd(),processCwd:t,exports:n,conditions:r=n||[`node`],exportsOnly:a=!1,paths:o={},ignore:c,log:u=!1,mixedModules:d=!1,ts:f=!0,analysis:p={},cache:m,fileIOConcurrency:h=1024}){if(this.ts=f,e=(0,path_1.resolve)(e),this.ignoreFn=e=>!!e.startsWith(`..`+path_1.sep),typeof c==`string`&&(c=[c]),typeof c==`function`){let e=c;this.ignoreFn=t=>!!(t.startsWith(`..`+path_1.sep)||e(t))}else if(Array.isArray(c)){let t=c.map(t=>(0,path_1.relative)(e,(0,path_1.resolve)(e||process.cwd(),t)));this.ignoreFn=e=>!!(e.startsWith(`..`+path_1.sep)||(0,picomatch_1.isMatch)(e,t))}this.base=e,this.cwd=(0,path_1.resolve)(t||e),this.conditions=r,this.exportsOnly=a;let g={};for(let t of Object.keys(o)){let n=o[t].endsWith(`/`);g[t]=(0,path_1.resolve)(e,o[t])+(n?`/`:``)}this.paths=g,this.log=u,this.mixedModules=d,this.cachedFileSystem=new fs_1.CachedFileSystem({cache:m,fileIOConcurrency:h}),this.analysis={},p!==!1&&Object.assign(this.analysis,{emitGlobs:!0,computeFileReferences:!0,evaluatePureExpressions:!0},p===!0?{}:p),this.analysisCache=m&&m.analysisCache||new Map,m&&(m.analysisCache=this.analysisCache),this.fileList=new Set,this.esmFileList=new Set,this.processed=new Set,this.warnings=new Set}addRemapping(e,t){if(e===t)return;let n=this.remappings.get(e);n||(n=new Set,this.remappings.set(e,n)),n.add(t)}async readlink(e){return this.cachedFileSystem.readlink(e)}async isFile(e){let t=await this.stat(e);return t?t.isFile():!1}async isDir(e){let t=await this.stat(e);return t?t.isDirectory():!1}async stat(e){return this.cachedFileSystem.stat(e)}maybeEmitDep=async(e,t,n)=>{let r=``,i;try{r=await this.resolve(e,t,this,n)}catch(a){i=a;try{if(this.ts&&e.endsWith(`.js`)&&a instanceof resolve_dependency_1.NotFoundError){let a=e.slice(0,-3)+`.ts`;r=await this.resolve(a,t,this,n),i=void 0}}catch(e){i=e}}if(i){this.warnings.add(Error(`Failed to resolve dependency "${e}":\n${i?.message}`));return}if(Array.isArray(r))for(let e of r){if(e.startsWith(`node:`))return;await this.emitDependency(e,t)}else{if(r.startsWith(`node:`))return;await this.emitDependency(r,t)}};async resolve(e,t,n,r){return(0,resolve_dependency_1.default)(e,t,n,r)}async readFile(e){return this.cachedFileSystem.readFile(e)}async realpath(e,t,n=new Set){if(n.has(e))throw Error(`Recursive symlink detected resolving `+e);n.add(e);let r=await this.readlink(e);if(r){let a=(0,path_1.dirname)(e),o=(0,path_1.resolve)(a,r);return inPath(e,await this.realpath(a,t))&&await this.emitFile(e,`resolve`,t,!0),this.realpath(o,t,n)}return inPath(e,this.base)?(0,path_1.join)(await this.realpath((0,path_1.dirname)(e),t,n),(0,path_1.basename)(e)):e}async emitFile(e,t,n,r=!1){r||(e=await this.realpath(e,n)),e=(0,path_1.relative)(this.base,e),n&&=(0,path_1.relative)(this.base,n);let a=this.reasons.get(e);return a?a.type.includes(t)||a.type.push(t):(a={type:[t],ignored:!1,parents:new Set},this.reasons.set(e,a)),n&&this.ignoreFn(e,n)?(!this.fileList.has(e)&&a&&(a.ignored=!0),!1):(n&&a.parents.add(n),this.fileList.add(e),!0)}async getPjsonBoundary(e){let t=e.indexOf(path_1.sep),n;for(;(n=e.lastIndexOf(path_1.sep))>t;)if(e=e.slice(0,n),await this.isFile(e+path_1.sep+`package.json`))return e}async emitDependency(e,t){if(this.processed.has(e)){t&&await this.emitFile(e,`dependency`,t);return}this.processed.add(e);let n=this.remappings.get(e);if(n&&await Promise.all([...n].map(async t=>this.emitDependency(t,e))),!await this.emitFile(e,`dependency`,t)||e.endsWith(`.json`))return;if(e.endsWith(`.node`))return await(0,sharedlib_emit_1.sharedLibEmit)(e,this);if(e.endsWith(`.js`)||e.endsWith(`.ts`)){let t=await this.getPjsonBoundary(e);t&&await this.emitFile(t+path_1.sep+`package.json`,`resolve`,e)}let r,o=this.analysisCache.get(e);if(o)r=o;else{let t=await this.readFile(e);if(t===null)throw Error(`File `+e+` does not exist.`);r=await(0,analyze_1.default)(e,t.toString(),this),this.analysisCache.set(e,r)}let{deps:s,imports:l,assets:u,isESM:d}=r;d&&this.esmFileList.add((0,path_1.relative)(this.base,e)),await Promise.all([...[...u].map(async t=>{let n=(0,path_1.extname)(t);n===`.js`||n===`.mjs`||n===`.node`||n===``||this.ts&&(n===`.ts`||n===`.tsx`)&&t.startsWith(this.base)&&t.slice(this.base.length).indexOf(path_1.sep+`node_modules`+path_1.sep)===-1?await this.emitDependency(t,e):await this.emitFile(t,`asset`,e)}),...[...s].map(async t=>this.maybeEmitDep(t,e,!d)),...[...l].map(async t=>this.maybeEmitDep(t,e,!1))])}}exports.Job=Job;
1
+ "use strict";var __createBinding=this&&this.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),__importStar=this&&this.__importStar||(function(){var n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},n(e)};return function(r){if(r&&r.__esModule)return r;var i={};if(r!=null)for(var a=n(r),o=0;o<a.length;o++)a[o]!==`default`&&__createBinding(i,r,a[o]);return __setModuleDefault(i,r),i}})(),__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,`__esModule`,{value:!0}),exports.Job=void 0,exports.nodeFileTrace=nodeFileTrace;const path_1=require(`path`),analyze_1=__importDefault(require(`./analyze`)),resolve_dependency_1=__importStar(require(`./resolve-dependency`)),picomatch_1=require(`picomatch`),sharedlib_emit_1=require(`./utils/sharedlib-emit`),fs_1=require(`./fs`);function inPath(e,t){let n=(0,path_1.join)(t,path_1.sep);return e.startsWith(n)&&e!==n}async function nodeFileTrace(e,t={}){let n=new Job(t);return t.readFile&&(n.readFile=t.readFile),t.stat&&(n.stat=t.stat),t.readlink&&(n.readlink=t.readlink),t.resolve&&(n.resolve=t.resolve),n.ts=!0,await Promise.all(e.map(async e=>{let t=(0,path_1.resolve)(e);return await n.emitFile(t,`initial`),n.emitDependency(t)})),{fileList:n.fileList,esmFileList:n.esmFileList,reasons:n.reasons,warnings:n.warnings}}class Job{ts;base;cwd;conditions;exportsOnly;paths;ignoreFn;log;depth;mixedModules;analysis;analysisCache;fileList;esmFileList;processed;warnings;reasons=new Map;cachedFileSystem;remappings=new Map;constructor({base:e=process.cwd(),processCwd:t,exports:n,conditions:r=n||[`node`],exportsOnly:a=!1,paths:o={},ignore:c,log:u=!1,mixedModules:d=!1,ts:f=!0,analysis:p={},cache:m,fileIOConcurrency:h=1024,depth:g=1/0}){if(this.ts=f,e=(0,path_1.resolve)(e),this.ignoreFn=e=>!!e.startsWith(`..`+path_1.sep),typeof c==`string`&&(c=[c]),typeof c==`function`){let e=c;this.ignoreFn=t=>!!(t.startsWith(`..`+path_1.sep)||e(t))}else if(Array.isArray(c)){let t=c.map(t=>(0,path_1.relative)(e,(0,path_1.resolve)(e||process.cwd(),t)));this.ignoreFn=e=>!!(e.startsWith(`..`+path_1.sep)||(0,picomatch_1.isMatch)(e,t))}this.base=e,this.cwd=(0,path_1.resolve)(t||e),this.conditions=r,this.exportsOnly=a;let _={};for(let t of Object.keys(o)){let n=o[t].endsWith(`/`);_[t]=(0,path_1.resolve)(e,o[t])+(n?`/`:``)}this.paths=_,this.log=u,this.depth=g,this.mixedModules=d,this.cachedFileSystem=new fs_1.CachedFileSystem({cache:m,fileIOConcurrency:h}),this.analysis={},p!==!1&&Object.assign(this.analysis,{emitGlobs:!0,computeFileReferences:!0,evaluatePureExpressions:!0},p===!0?{}:p),this.analysisCache=m&&m.analysisCache||new Map,m&&(m.analysisCache=this.analysisCache),this.fileList=new Set,this.esmFileList=new Set,this.processed=new Set,this.warnings=new Set}addRemapping(e,t){if(e===t)return;let n=this.remappings.get(e);n||(n=new Set,this.remappings.set(e,n)),n.add(t)}async readlink(e){return this.cachedFileSystem.readlink(e)}async isFile(e){let t=await this.stat(e);return t?t.isFile():!1}async isDir(e){let t=await this.stat(e);return t?t.isDirectory():!1}async stat(e){return this.cachedFileSystem.stat(e)}maybeEmitDep=async(e,t,n,r)=>{let i=``,a;try{i=await this.resolve(e,t,this,n)}catch(r){a=r;try{if(this.ts&&e.endsWith(`.js`)&&r instanceof resolve_dependency_1.NotFoundError){let r=e.slice(0,-3)+`.ts`;i=await this.resolve(r,t,this,n),a=void 0}}catch(e){a=e}}if(a){this.warnings.add(Error(`Failed to resolve dependency "${e}":\n${a?.message}`));return}if(Array.isArray(i))for(let e of i){if(e.startsWith(`node:`))return;await this.emitDependency(e,t,r)}else{if(i.startsWith(`node:`))return;await this.emitDependency(i,t,r)}};async resolve(e,t,n,r){return(0,resolve_dependency_1.default)(e,t,n,r)}async readFile(e){return this.cachedFileSystem.readFile(e)}async realpath(e,t,n=new Set){if(n.has(e))throw Error(`Recursive symlink detected resolving `+e);n.add(e);let r=await this.readlink(e);if(r){let a=(0,path_1.dirname)(e),o=(0,path_1.resolve)(a,r);return inPath(e,await this.realpath(a,t))&&await this.emitFile(e,`resolve`,t,!0),this.realpath(o,t,n)}return inPath(e,this.base)?(0,path_1.join)(await this.realpath((0,path_1.dirname)(e),t,n),(0,path_1.basename)(e)):e}async emitFile(e,t,n,r=!1){r||(e=await this.realpath(e,n)),e=(0,path_1.relative)(this.base,e),n&&=(0,path_1.relative)(this.base,n);let a=this.reasons.get(e);return a?a.type.includes(t)||a.type.push(t):(a={type:[t],ignored:!1,parents:new Set},this.reasons.set(e,a)),n&&this.ignoreFn(e,n)?(!this.fileList.has(e)&&a&&(a.ignored=!0),!1):(n&&a.parents.add(n),this.fileList.add(e),!0)}async getPjsonBoundary(e){let t=e.indexOf(path_1.sep),n;for(;(n=e.lastIndexOf(path_1.sep))>t;)if(e=e.slice(0,n),await this.isFile(e+path_1.sep+`package.json`))return e}async emitDependency(e,t,n=this.depth){if(n<0)throw Error(`invariant - depth option cannot be negative`);if(this.processed.has(e)){t&&await this.emitFile(e,`dependency`,t);return}this.processed.add(e);let r=this.remappings.get(e);if(r&&await Promise.all([...r].map(async t=>this.emitDependency(t,e,n))),!await this.emitFile(e,`dependency`,t)||e.endsWith(`.json`))return;if(e.endsWith(`.node`))return await(0,sharedlib_emit_1.sharedLibEmit)(e,this);if(e.endsWith(`.js`)||e.endsWith(`.ts`)){let t=await this.getPjsonBoundary(e);t&&await this.emitFile(t+path_1.sep+`package.json`,`resolve`,e)}if(n===0)return;let o,s=this.analysisCache.get(e);if(s)o=s;else{let t=await this.readFile(e);if(t===null)throw Error(`File `+e+` does not exist.`);o=await(0,analyze_1.default)(e,t.toString(),this),this.analysisCache.set(e,o)}let{deps:l,imports:u,assets:d,isESM:f}=o;f&&this.esmFileList.add((0,path_1.relative)(this.base,e)),await Promise.all([...[...d].map(async t=>{let r=(0,path_1.extname)(t);r===`.js`||r===`.mjs`||r===`.node`||r===``||this.ts&&(r===`.ts`||r===`.tsx`)&&t.startsWith(this.base)&&t.slice(this.base.length).indexOf(path_1.sep+`node_modules`+path_1.sep)===-1?await this.emitDependency(t,e,n-1):await this.emitFile(t,`asset`,e)}),...[...l].map(async t=>this.maybeEmitDep(t,e,!f,n-1)),...[...u].map(async t=>this.maybeEmitDep(t,e,!1,n-1))])}}exports.Job=Job;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@vercel/nft",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "main": "./out/index.js"
5
5
  }
package/dist/plugin.mjs CHANGED
@@ -11,7 +11,7 @@ function externals(opts) {
11
11
  const include = opts?.include ? opts.include.map((p) => toPathRegExp(p)) : void 0;
12
12
  const exclude = [
13
13
  /^(?:[\0#~.]|[a-z0-9]{2,}:)|\?/,
14
- /* @__PURE__ */ new RegExp("^" + pathRegExp(rootDir) + "(?!.*node_modules)"),
14
+ new RegExp("^" + pathRegExp(rootDir) + "(?!.*node_modules)"),
15
15
  ...(opts?.exclude || []).map((p) => toPathRegExp(p))
16
16
  ];
17
17
  const filter = (id) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nf3",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "description": "",
5
5
  "repository": "unjs/nf3",
6
6
  "license": "MIT",
@@ -27,27 +27,27 @@
27
27
  },
28
28
  "devDependencies": {
29
29
  "@rollup/plugin-node-resolve": "^16.0.3",
30
- "@types/node": "^25.0.9",
30
+ "@types/node": "^25.0.10",
31
31
  "@types/semver": "^7.7.1",
32
- "@typescript/native-preview": "7.0.0-dev.20260119.1",
33
- "@vercel/nft": "^1.2.0",
34
- "@vitest/coverage-v8": "^4.0.17",
32
+ "@typescript/native-preview": "^7.0.0-dev.20260122.3",
33
+ "@vercel/nft": "^1.3.0",
34
+ "@vitest/coverage-v8": "^4.0.18",
35
35
  "automd": "^0.4.2",
36
36
  "changelogen": "^0.6.2",
37
37
  "eslint": "^9.39.2",
38
38
  "eslint-config-unjs": "^0.6.2",
39
39
  "exsolve": "^1.0.8",
40
- "obuild": "^0.4.16",
40
+ "obuild": "^0.4.19",
41
41
  "oxc-minify": "^0.110.0",
42
42
  "pathe": "^2.0.3",
43
43
  "pkg-types": "^2.3.0",
44
- "prettier": "^3.8.0",
45
- "rolldown": "^1.0.0-beta.60",
46
- "rollup": "^4.55.2",
44
+ "prettier": "^3.8.1",
45
+ "rolldown": "^1.0.0-rc.1",
46
+ "rollup": "^4.56.0",
47
47
  "rollup-plugin-esbuild": "^6.2.1",
48
48
  "semver": "^7.7.3",
49
49
  "typescript": "^5.9.3",
50
- "vitest": "^4.0.17"
50
+ "vitest": "^4.0.18"
51
51
  },
52
52
  "packageManager": "pnpm@10.28.1"
53
53
  }
@@ -1 +0,0 @@
1
- var PackageJson=[23,()=>[PackageJsonScripts,PackageJsonPerson,PackageJsonPerson,PackageJsonFunding,PackageJsonFunding,Record,Record,Record,Record,Record,Record,PackageJsonExports,Record,Record,Record,Record,PackageJson,Pick]],PackageJsonScriptWithPreAndPost=[24,e=>[e,e]],PackageJsonNpmLifeCycleScripts=[25,()=>[PackageJsonScriptWithPreAndPost]],PackageJsonPnpmLifeCycleScripts=[26,()=>[]],PackageJsonCommonScripts=[27,()=>[]],PackageJsonScriptName=[28,()=>[PackageJsonCommonScripts,PackageJsonNpmLifeCycleScripts,PackageJsonPnpmLifeCycleScripts]],PackageJsonScripts=[29,()=>[PackageJsonScriptName]],PackageJsonPerson=[30,()=>[]],PackageJsonFunding=[31,()=>[]],PackageJsonExportKey=[32,()=>[]],PackageJsonExportsObject=[33,()=>[PackageJsonExportKey,PackageJsonExportsObject,PackageJsonExportsObject,Array]],PackageJsonExports=[34,()=>[PackageJsonExportsObject,PackageJsonExportsObject,Array]];export{PackageJson as t};