nf3 0.3.2 → 0.3.4
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 +1 -1
- package/dist/db.d.mts +9 -0
- package/dist/db.mjs +42 -0
- package/dist/index.d.mts +1 -8
- package/dist/index.mjs +1 -41
- package/dist/node_modules/@vercel/nft/out/analyze.js +1 -1
- package/dist/node_modules/@vercel/nft/package.json +1 -1
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -97,7 +97,7 @@ nf3 exports a list of known packages that include native code and require platfo
|
|
|
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";
|
|
100
|
+
import { nodeNativePackages } from "nf3/db";
|
|
101
101
|
```
|
|
102
102
|
|
|
103
103
|
## Development
|
package/dist/db.d.mts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/db.d.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
|
+
declare const NodeNativePackages: readonly string[];
|
|
8
|
+
//#endregion
|
|
9
|
+
export { NodeNativePackages };
|
package/dist/db.mjs
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
const NodeNativePackages = Object.freeze([
|
|
8
|
+
"canvas",
|
|
9
|
+
"sharp",
|
|
10
|
+
"gl",
|
|
11
|
+
"bcrypt",
|
|
12
|
+
"kerberos",
|
|
13
|
+
"scrypt",
|
|
14
|
+
"blake-hash",
|
|
15
|
+
"sodium-native",
|
|
16
|
+
"better-sqlite3",
|
|
17
|
+
"leveldown",
|
|
18
|
+
"lmdb",
|
|
19
|
+
"sqlite3",
|
|
20
|
+
"lz4",
|
|
21
|
+
"deasync",
|
|
22
|
+
"node-gyp",
|
|
23
|
+
"node-sass",
|
|
24
|
+
"@parcel/watcher",
|
|
25
|
+
"@parcel/source-map",
|
|
26
|
+
"@mapbox/node-pre-gyp",
|
|
27
|
+
"edge-js",
|
|
28
|
+
"fsevents",
|
|
29
|
+
"node-pty",
|
|
30
|
+
"usb",
|
|
31
|
+
"ffi-napi",
|
|
32
|
+
"ref-napi",
|
|
33
|
+
"ref-struct-napi",
|
|
34
|
+
"ref-union-napi",
|
|
35
|
+
"grpc",
|
|
36
|
+
"bufferutil",
|
|
37
|
+
"utf-8-validate",
|
|
38
|
+
"keytar"
|
|
39
|
+
]);
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { NodeNativePackages };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
+
import { NodeNativePackages } from "./db.mjs";
|
|
1
2
|
import { n as ExternalsTraceOptions } from "./_chunks/types.mjs";
|
|
2
3
|
import { PackageJson } from "pkg-types";
|
|
3
4
|
|
|
4
5
|
//#region src/trace.d.ts
|
|
5
6
|
declare function traceNodeModules(input: string[], opts: ExternalsTraceOptions): Promise<void>;
|
|
6
7
|
//#endregion
|
|
7
|
-
//#region src/db.d.ts
|
|
8
|
-
/**
|
|
9
|
-
* Known packages that include native code and require platform-specific builds.
|
|
10
|
-
*
|
|
11
|
-
* These packages cannot be bundled and should be traced as external dependencies most of the time.
|
|
12
|
-
*/
|
|
13
|
-
declare const NodeNativePackages: readonly string[];
|
|
14
|
-
//#endregion
|
|
15
8
|
export { type ExternalsTraceOptions, NodeNativePackages, traceNodeModules };
|
package/dist/index.mjs
CHANGED
|
@@ -1,44 +1,4 @@
|
|
|
1
1
|
import { r as traceNodeModules } from "./_chunks/trace.mjs";
|
|
2
|
+
import { NodeNativePackages } from "./db.mjs";
|
|
2
3
|
|
|
3
|
-
//#region src/db.ts
|
|
4
|
-
/**
|
|
5
|
-
* Known packages that include native code and require platform-specific builds.
|
|
6
|
-
*
|
|
7
|
-
* These packages cannot be bundled and should be traced as external dependencies most of the time.
|
|
8
|
-
*/
|
|
9
|
-
const NodeNativePackages = Object.freeze([
|
|
10
|
-
"canvas",
|
|
11
|
-
"sharp",
|
|
12
|
-
"gl",
|
|
13
|
-
"bcrypt",
|
|
14
|
-
"kerberos",
|
|
15
|
-
"scrypt",
|
|
16
|
-
"blake-hash",
|
|
17
|
-
"sodium-native",
|
|
18
|
-
"better-sqlite3",
|
|
19
|
-
"leveldown",
|
|
20
|
-
"lmdb",
|
|
21
|
-
"sqlite3",
|
|
22
|
-
"lz4",
|
|
23
|
-
"deasync",
|
|
24
|
-
"node-gyp",
|
|
25
|
-
"node-sass",
|
|
26
|
-
"@parcel/watcher",
|
|
27
|
-
"@parcel/source-map",
|
|
28
|
-
"@mapbox/node-pre-gyp",
|
|
29
|
-
"edge-js",
|
|
30
|
-
"fsevents",
|
|
31
|
-
"node-pty",
|
|
32
|
-
"usb",
|
|
33
|
-
"ffi-napi",
|
|
34
|
-
"ref-napi",
|
|
35
|
-
"ref-struct-napi",
|
|
36
|
-
"ref-union-napi",
|
|
37
|
-
"grpc",
|
|
38
|
-
"bufferutil",
|
|
39
|
-
"utf-8-validate",
|
|
40
|
-
"keytar"
|
|
41
|
-
]);
|
|
42
|
-
|
|
43
|
-
//#endregion
|
|
44
4
|
export { NodeNativePackages, traceNodeModules };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,`__esModule`,{value:!0}),exports.default=analyze;const path_1=__importDefault(require(`path`)),estree_walker_1=require(`estree-walker`),pluginutils_1=require(`@rollup/pluginutils`),static_eval_1=require(`./utils/static-eval`),acorn_1=require(`acorn`),bindings_1=__importDefault(require(`bindings`)),ast_helpers_1=require(`./utils/ast-helpers`),glob_1=require(`glob`),get_package_base_1=require(`./utils/get-package-base`),binary_locators_1=require(`./utils/binary-locators`),interop_require_1=require(`./utils/interop-require`),special_cases_1=__importDefault(require(`./utils/special-cases`)),resolve_dependency_js_1=__importDefault(require(`./resolve-dependency.js`)),node_gyp_build_1=__importDefault(require(`node-gyp-build`)),node_pre_gyp_1=__importDefault(require(`@mapbox/node-pre-gyp`)),url_1=require(`url`),acorn=acorn_1.Parser.extend(require(`acorn-import-attributes`).importAttributesOrAssertions),os_1=__importDefault(require(`os`)),url_2=__importDefault(require(`url`)),wrappers_1=require(`./utils/wrappers`),resolve_from_1=__importDefault(require(`resolve-from`)),staticProcess={cwd:()=>cwd,env:{NODE_ENV:static_eval_1.UNKNOWN,[static_eval_1.UNKNOWN]:!0},[static_eval_1.UNKNOWN]:!0},EXPRESS_SET=Symbol(),EXPRESS_ENGINE=Symbol(),NBIND_INIT=Symbol(),SET_ROOT_DIR=Symbol(),PKG_INFO=Symbol(),FS_FN=Symbol(),FS_DIR_FN=Symbol(),BINDINGS=Symbol(),NODE_GYP_BUILD=Symbol(),fsSymbols={access:FS_FN,accessSync:FS_FN,createReadStream:FS_FN,exists:FS_FN,existsSync:FS_FN,fstat:FS_FN,fstatSync:FS_FN,lstat:FS_FN,lstatSync:FS_FN,open:FS_FN,readdir:FS_DIR_FN,readdirSync:FS_DIR_FN,readFile:FS_FN,readFileSync:FS_FN,stat:FS_FN,statSync:FS_FN},fsExtraSymbols={...fsSymbols,pathExists:FS_FN,pathExistsSync:FS_FN,readJson:FS_FN,readJSON:FS_FN,readJsonSync:FS_FN,readJSONSync:FS_FN},MODULE_FN=Symbol(),moduleSymbols={register:MODULE_FN},staticModules=Object.assign(Object.create(null),{bindings:{default:BINDINGS},express:{default:function(){return{[static_eval_1.UNKNOWN]:!0,set:EXPRESS_SET,engine:EXPRESS_ENGINE}}},fs:{default:fsSymbols,...fsSymbols},module:{default:moduleSymbols,...moduleSymbols},"fs-extra":{default:fsExtraSymbols,...fsExtraSymbols},"graceful-fs":{default:fsSymbols,...fsSymbols},process:{default:staticProcess,...staticProcess},path:{default:{}},os:{default:os_1.default,...os_1.default},url:{default:url_2.default,...url_2.default},"@mapbox/node-pre-gyp":{default:node_pre_gyp_1.default,...node_pre_gyp_1.default},"node-pre-gyp":binary_locators_1.pregyp,"node-pre-gyp/lib/pre-binding":binary_locators_1.pregyp,"node-pre-gyp/lib/pre-binding.js":binary_locators_1.pregyp,"node-gyp-build":{default:NODE_GYP_BUILD},"@aminya/node-gyp-build":{default:NODE_GYP_BUILD},nbind:{init:NBIND_INIT,default:{init:NBIND_INIT}},"resolve-from":{default:resolve_from_1.default},"strong-globalize":{default:{SetRootDir:SET_ROOT_DIR},SetRootDir:SET_ROOT_DIR},pkginfo:{default:PKG_INFO}}),globalBindings={_interopRequireDefault:interop_require_1.normalizeDefaultRequire,_interopRequireWildcard:interop_require_1.normalizeWildcardRequire,__importDefault:interop_require_1.normalizeDefaultRequire,__importStar:interop_require_1.normalizeWildcardRequire,MONGOOSE_DRIVER_PATH:void 0,URL:url_1.URL,Object:{assign:Object.assign}};globalBindings.global=globalBindings.GLOBAL=globalBindings.globalThis=globalBindings;const TRIGGER=Symbol();binary_locators_1.pregyp.find[TRIGGER]=!0;const staticPath=staticModules.path;Object.keys(path_1.default).forEach(e=>{let x=path_1.default[e];if(typeof x==`function`){let b=function e(){return x.apply(e,arguments)};b[TRIGGER]=!0,staticPath[e]=staticPath.default[e]=b}else staticPath[e]=staticPath.default[e]=x}),staticPath.resolve=staticPath.default.resolve=function(...e){return path_1.default.resolve.apply(this,[cwd,...e])},staticPath.resolve[TRIGGER]=!0;const excludeAssetExtensions=new Set([`.h`,`.cmake`,`.c`,`.cpp`]),excludeAssetFiles=new Set([`CHANGELOG.md`,`README.md`,`readme.md`,`changelog.md`]);let cwd;const absoluteRegEx=/^\/[^\/]+|^[a-z]:[\\/][^\\/]+/i;function isAbsolutePathOrUrl(e){if(e instanceof url_1.URL)return e.protocol===`file:`;if(typeof e==`string`){if(e.startsWith(`file:`))try{return new url_1.URL(e),!0}catch{return!1}return absoluteRegEx.test(e)}return!1}const BOUND_REQUIRE=Symbol(),repeatGlobRegEx=/([\/\\]\*\*[\/\\]\*)+/g;async function analyze(e,w,D){let O=new Set,k=new Set,A=new Set,j=path_1.default.dirname(e);cwd=D.cwd;let M=(0,get_package_base_1.getPackageBase)(e),N=e=>{if(!D.analysis.emitGlobs)return;e=e.replaceAll(path_1.default.sep,path_1.default.posix.sep);let x=e.indexOf(static_eval_1.WILDCARD),S=x===-1?e.length:e.lastIndexOf(path_1.default.posix.sep,x),w=e.substring(0,S),T=e.slice(S),E=T.replace(static_eval_1.wildcardRegEx,(e,x)=>T[x-1]===path_1.default.posix.sep?`**/*`:`*`).replace(repeatGlobRegEx,`/**/*`)||`/**/*`;D.ignoreFn(path_1.default.relative(D.base,w+E))||(P=P.then(async()=>{D.log&&console.log(`Globbing `+w+E),(await(0,glob_1.glob)(w+E,{mark:!0,ignore:w+`/**/node_modules/**/*`,dot:!0,nodir:!0})).filter(e=>!excludeAssetExtensions.has(path_1.default.extname(e))&&!excludeAssetFiles.has(path_1.default.basename(e))).forEach(e=>O.add(e))}))},P=Promise.resolve();w=w.replace(/^#![^\n\r]*[\r\n]/,``);let F,I=!1;try{F=acorn.parse(w,{ecmaVersion:`latest`,allowReturnOutsideFunction:!0}),I=!1}catch(b){b&&b.message&&b.message.includes(`sourceType: module`)||D.warnings.add(Error(`Failed to parse ${e} as script:\n${b&&b.message}`))}if(!F)try{F=acorn.parse(w,{ecmaVersion:`latest`,sourceType:`module`,allowAwaitOutsideFunction:!0}),I=!0}catch(b){return D.warnings.add(Error(`Failed to parse ${e} as module:\n${b&&b.message}`)),{assets:O,deps:k,imports:A,isESM:!1}}let L=(0,url_1.pathToFileURL)(e).href,R=Object.assign(Object.create(null),{__dirname:{shadowDepth:0,value:{value:path_1.default.resolve(e,`..`)}},__filename:{shadowDepth:0,value:{value:e}},process:{shadowDepth:0,value:{value:staticProcess}}});(!I||D.mixedModules)&&(R.require={shadowDepth:0,value:{value:{[static_eval_1.FUNCTION](e){return k.add(e),staticModules[e.startsWith(`node:`)?e.slice(5):e].default},resolve(b){return(0,resolve_dependency_js_1.default)(b,e,D)}}}},R.require.value.value.resolve[TRIGGER]=!0);function z(e,b){e!==`require`&&(R[e]={shadowDepth:0,value:b})}function B(e){let b=R[e];if(b&&b.shadowDepth===0)return b.value}function V(e){let b=R[e];return b&&b.shadowDepth===0}if((I||D.mixedModules)&&isAst(F))for(let e of F.body)if(e.type===`ImportDeclaration`){let b=String(e.source.value);k.add(b);let x=staticModules[b.startsWith(`node:`)?b.slice(5):b];if(x)for(let b of e.specifiers)b.type===`ImportNamespaceSpecifier`?z(b.local.name,{value:x}):b.type===`ImportDefaultSpecifier`&&`default`in x?z(b.local.name,{value:x.default}):b.type===`ImportSpecifier`&&b.imported.name in x&&z(b.local.name,{value:x[b.imported.name]})}else (e.type===`ExportNamedDeclaration`||e.type===`ExportAllDeclaration`)&&e.source&&k.add(String(e.source.value));async function H(e,b=!0){let x=Object.create(null);return Object.keys(globalBindings).forEach(e=>{x[e]={value:globalBindings[e]}}),Object.keys(R).forEach(e=>{x[e]=B(e)}),x[`import.meta`]={url:L},await(0,static_eval_1.evaluate)(e,x,b)}let U,W,G=!1;function K(e){if(!D.analysis.emitGlobs||!e.startsWith(`./`)&&!e.startsWith(`../`))return;e=path_1.default.resolve(j,e).replaceAll(path_1.default.sep,path_1.default.posix.sep);let x=e.indexOf(static_eval_1.WILDCARD),S=x===-1?e.length:e.lastIndexOf(path_1.default.posix.sep,x),w=e.substring(0,S),T=e.slice(S),E=T.replace(static_eval_1.wildcardRegEx,(e,x)=>T[x-1]===path_1.default.posix.sep?`**/*`:`*`)||`/**/*`;E.endsWith(`*`)||(E+=`?(`+(D.ts?`.ts|.tsx|`:``)+`.js|.json|.node)`),!D.ignoreFn(path_1.default.relative(D.base,w+E))&&(P=P.then(async()=>{D.log&&console.log(`Globbing `+w+E),(await(0,glob_1.glob)(w+E,{mark:!0,ignore:w+`/**/node_modules/**/*`,nodir:!0})).filter(e=>!excludeAssetExtensions.has(path_1.default.extname(e))&&!excludeAssetFiles.has(path_1.default.basename(e))).forEach(e=>k.add(e))}))}async function q(e,b=!1){if(e.type===`ConditionalExpression`){await q(e.consequent,b),await q(e.alternate,b);return}if(e.type===`LogicalExpression`){await q(e.left,b),await q(e.right,b);return}let x=await H(e,!0);if(!x)return;function S(e){(b?A:k).add(e)}`value`in x&&typeof x.value==`string`?x.wildcards?x.wildcards.length>=1&&K(x.value):S(x.value):(`ifTrue`in x&&typeof x.ifTrue==`string`&&S(x.ifTrue),`else`in x&&typeof x.else==`string`&&S(x.else))}let J=(0,pluginutils_1.attachScopes)(F,`scope`);isAst(F)&&((0,wrappers_1.handleWrappers)(F),await(0,special_cases_1.default)({id:e,ast:F,emitDependency:e=>k.add(e),emitAsset:e=>O.add(e),emitAssetDirectory:N,job:D}));async function Y(e,b){if(!U)throw Error(`Internal error: No staticChildNode for backtrack.`);let x=await H(e,!0);if(x&&(`value`in x&&typeof x.value!=`symbol`||`ifTrue`in x&&typeof x.ifTrue!=`symbol`&&typeof x.else!=`symbol`)){W=x,U=e,b&&b.skip();return}await $()}return await(0,estree_walker_1.asyncWalk)(F,{async enter(x,S){let C=x,w=S;if(C.scope)for(let e in J=C.scope,C.scope.declarations)e in R&&R[e].shadowDepth++;if(!U&&w){if(C.type===`Identifier`){if((0,ast_helpers_1.isIdentifierRead)(C,w)&&D.analysis.computeFileReferences){let e;(typeof(e=B(C.name)?.value)==`string`&&e.match(absoluteRegEx)||e&&(typeof e==`function`||typeof e==`object`)&&e[TRIGGER])&&(W={value:typeof e==`string`?e:void 0},U=C,await Y(w,this))}}else if(D.analysis.computeFileReferences&&C.type===`MemberExpression`&&C.object.type===`MetaProperty`&&C.object.meta.name===`import`&&C.object.property.name===`meta`&&(C.property.computed?C.property.value:C.property.name)===`url`)W={value:L},U=C,await Y(w,this);else if(C.type===`ImportExpression`){await q(C.source,!0);return}else if(C.type===`CallExpression`){if((!I||D.mixedModules)&&C.callee.type===`Identifier`&&C.arguments.length){if(C.callee.name===`require`&&R.require.shadowDepth===0){await q(C.arguments[0]);return}}else if((!I||D.mixedModules)&&C.callee.type===`MemberExpression`&&C.callee.object.type===`Identifier`&&C.callee.object.name===`module`&&!(`module`in R)&&C.callee.property.type===`Identifier`&&!C.callee.computed&&C.callee.property.name===`require`&&C.arguments.length){await q(C.arguments[0]);return}else if((!I||D.mixedModules)&&C.callee.type===`MemberExpression`&&C.callee.object.type===`Identifier`&&C.callee.object.name===`require`&&R.require.shadowDepth===0&&C.callee.property.type===`Identifier`&&!C.callee.computed&&C.callee.property.name===`resolve`&&C.arguments.length){await q(C.arguments[0]);return}let x=D.analysis.evaluatePureExpressions&&await H(C.callee,!1);if(x&&`value`in x&&typeof x.value==`function`&&x.value[TRIGGER]&&D.analysis.computeFileReferences)W=await H(C,!0),W&&w&&(U=C,await Y(w,this));else if(x&&`value`in x&&typeof x.value==`symbol`)switch(x.value){case BOUND_REQUIRE:C.arguments.length===1&&C.arguments[0].type===`Literal`&&C.callee.type===`Identifier`&&R.require.shadowDepth===0&&await q(C.arguments[0]);break;case BINDINGS:if(C.arguments.length){let e=await H(C.arguments[0],!1);if(e&&`value`in e&&e.value){let b;typeof e.value==`object`?b=e.value:typeof e.value==`string`&&(b={bindings:e.value}),b.path||=!0,b.module_root=M;let x;try{x=(0,bindings_1.default)(b)}catch{}x&&(W={value:x},U=C,await $())}}break;case NODE_GYP_BUILD:if(C.arguments.length){let e=await H(C.arguments[0],!1);if(e&&`value`in e&&e.value){let b=e.value,x;try{let e=C?.callee?.arguments?.[0]?.value||`node-gyp-build`,S=(0,resolve_from_1.default)(b,e);x=require(S).path(b)}catch{try{x=node_gyp_build_1.default.path(b)}catch{}}x&&(W={value:x},U=C,await $())}}break;case NBIND_INIT:if(C.arguments.length){let e=await H(C.arguments[0],!1);if(e&&`value`in e&&(typeof e.value==`string`||e.value===void 0)){let x=(0,binary_locators_1.nbind)(e.value);if(x&&x.path)return k.add(path_1.default.relative(j,x.path).replace(/\\/g,`/`)),this.skip()}}break;case EXPRESS_SET:if(C.arguments.length===2&&C.arguments[0].type===`Literal`&&C.arguments[0].value===`view engine`&&!G)return await q(C.arguments[1]),this.skip();break;case EXPRESS_ENGINE:G=!0;break;case FS_FN:case FS_DIR_FN:if(C.arguments[0]&&D.analysis.computeFileReferences&&(W=await H(C.arguments[0],!0),W))return U=C.arguments[0],x.value===FS_DIR_FN&&C.arguments[0].type===`Identifier`&&C.arguments[0].name===`__dirname`?N(j):await Y(w,this),this.skip();break;case SET_ROOT_DIR:if(C.arguments[0]){let e=await H(C.arguments[0],!1);return e&&`value`in e&&e.value&&N(e.value+`/intl`),this.skip()}break;case PKG_INFO:let S=path_1.default.resolve(e,`../package.json`),E=path_1.default.resolve(`/package.json`);for(;S!==E&&await D.stat(S)===null;)S=path_1.default.resolve(S,`../../package.json`);S!==E&&O.add(S);break;case MODULE_FN:if(C.arguments.length&&C.arguments[0].type===`Literal`){let e=C.arguments[0].value;if(e.startsWith(`.`)){let x=C.arguments.length>1?await H(C.arguments[1]):void 0;if(x&&`value`in x){let S=x.value instanceof url_1.URL?x.value.href:typeof x.value==`string`?x.value:x.value.parentURL,C=new url_1.URL(e,S).href,w=L.slice(0,L.lastIndexOf(`/`)),T=path_1.default.relative(w,C),E=T.startsWith(`.`)?T:`./`+T;A.add(E)}}else A.add(e)}break}}else if(C.type===`VariableDeclaration`&&w&&!(0,ast_helpers_1.isVarLoop)(w)&&D.analysis.evaluatePureExpressions)for(let e of C.declarations){if(!e.init)continue;let b=await H(e.init,!0);if(b){if(e.id.type===`Identifier`)z(e.id.name,b);else if(e.id.type===`ObjectPattern`&&`value`in b)for(let x of e.id.properties)x.type!==`Property`||x.key.type!==`Identifier`||x.value.type!==`Identifier`||typeof b.value!=`object`||b.value===null||!(x.key.name in b.value)||z(x.value.name,{value:b.value[x.key.name]});!(`value`in b)&&isAbsolutePathOrUrl(b.ifTrue)&&isAbsolutePathOrUrl(b.else)&&(W=b,U=e.init,await $())}}else if(C.type===`AssignmentExpression`&&w&&!(0,ast_helpers_1.isLoop)(w)&&D.analysis.evaluatePureExpressions){if(!V(C.left.name)){let e=await H(C.right,!1);if(e&&`value`in e){if(C.left.type===`Identifier`)z(C.left.name,e);else if(C.left.type===`ObjectPattern`)for(let b of C.left.properties)b.type!==`Property`||b.key.type!==`Identifier`||b.value.type!==`Identifier`||typeof e.value!=`object`||e.value===null||!(b.key.name in e.value)||z(b.value.name,{value:e.value[b.key.name]});isAbsolutePathOrUrl(e.value)&&(W=e,U=C.right,await $())}}}else if((!I||D.mixedModules)&&(C.type===`FunctionDeclaration`||C.type===`FunctionExpression`||C.type===`ArrowFunctionExpression`)&&(C.arguments||C.params)[0]&&(C.arguments||C.params)[0].type===`Identifier`){let e,b;if((C.type===`ArrowFunctionExpression`||C.type===`FunctionExpression`)&&w&&w.type===`VariableDeclarator`&&w.id.type===`Identifier`?(e=w.id,b=C.arguments||C.params):C.id&&(e=C.id,b=C.arguments||C.params),e&&C.body.body){let x,S=!1;for(let e=0;e<C.body.body.length;e++)if(C.body.body[e].type===`VariableDeclaration`&&!x&&(x=C.body.body[e].declarations.find(e=>e&&e.id&&e.id.type===`Identifier`&&e.init&&e.init.type===`CallExpression`&&e.init.callee.type===`Identifier`&&e.init.callee.name===`require`&&R.require.shadowDepth===0&&e.init.arguments[0]&&e.init.arguments[0].type===`Identifier`&&e.init.arguments[0].name===b[0].name)),x&&C.body.body[e].type===`ReturnStatement`&&C.body.body[e].argument&&C.body.body[e].argument.type===`Identifier`&&C.body.body[e].argument.name===x.id.name){S=!0;break}S&&z(e.name,{value:BOUND_REQUIRE})}}if(C.type===`CallExpression`&&C.callee.type===`MemberExpression`&&C.callee.object.type===`Identifier`&&C.callee.object.name===`module`&&C.callee.property.type===`Identifier`&&C.callee.property.name===`createRequire`&&w.type===`VariableDeclarator`){let e=w.id.name;z(e,{value:BOUND_REQUIRE})}}},async leave(e,b){let x=e,S=b;if(x.scope)for(let e in J.parent&&(J=J.parent),x.scope.declarations)e in R&&(R[e].shadowDepth>0?R[e].shadowDepth--:delete R[e]);U&&S&&await Y(S,this)}}),await P,{assets:O,deps:k,imports:A,isESM:I};async function X(e){let x=e.indexOf(static_eval_1.WILDCARD),S=x===-1?e.length:e.lastIndexOf(path_1.default.sep,x),w=e.substring(0,S);try{var T=await D.stat(w);if(T===null)throw Error(`file not found`)}catch{return}x!==-1&&T.isFile()||(T.isFile()?O.add(e):T.isDirectory()&&Z(e)&&N(e))}function Z(x){let S=``;if(x.endsWith(path_1.default.sep)?S=path_1.default.sep:x.endsWith(path_1.default.sep+static_eval_1.WILDCARD)?S=path_1.default.sep+static_eval_1.WILDCARD:x.endsWith(static_eval_1.WILDCARD)&&(S=static_eval_1.WILDCARD),x===j+S||x===cwd+S||x.endsWith(path_1.default.sep+`node_modules`+S)||j.startsWith(x.slice(0,x.length-S.length)+path_1.default.sep))return!1;if(M){let S=e.substring(0,e.indexOf(path_1.default.sep+`node_modules`))+path_1.default.sep+`node_modules`+path_1.default.sep;if(!x.startsWith(S))return D.log&&console.log(`Skipping asset emission of `+x.replace(static_eval_1.wildcardRegEx,`*`)+` for `+e+` as it is outside the package base `+M),!1}return!0}function Q(e){return e instanceof url_1.URL?(0,url_1.fileURLToPath)(e):e.startsWith(`file:`)?(0,url_1.fileURLToPath)(new url_1.URL(e)):path_1.default.resolve(e)}async function $(){if(W){if(`value`in W&&isAbsolutePathOrUrl(W.value))try{await X(Q(W.value))}catch{}else if(`ifTrue`in W&&`else`in W&&isAbsolutePathOrUrl(W.ifTrue)&&isAbsolutePathOrUrl(W.else)){let e;try{e=Q(W.ifTrue)}catch{}let b;try{b=Q(W.else)}catch{}e&&await X(e),b&&await X(b)}else if(U&&U.type===`ArrayExpression`&&`value`in W&&W.value instanceof Array)for(let e of W.value)try{await X(Q(e))}catch{}U=W=void 0}}}function isAst(e){return`body`in e}
|
|
1
|
+
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,`__esModule`,{value:!0}),exports.default=analyze;const path_1=__importDefault(require(`path`)),estree_walker_1=require(`estree-walker`),pluginutils_1=require(`@rollup/pluginutils`),static_eval_1=require(`./utils/static-eval`),acorn_1=require(`acorn`),bindings_1=__importDefault(require(`bindings`)),ast_helpers_1=require(`./utils/ast-helpers`),glob_1=require(`glob`),get_package_base_1=require(`./utils/get-package-base`),binary_locators_1=require(`./utils/binary-locators`),interop_require_1=require(`./utils/interop-require`),special_cases_1=__importDefault(require(`./utils/special-cases`)),resolve_dependency_js_1=__importDefault(require(`./resolve-dependency.js`)),node_gyp_build_1=__importDefault(require(`node-gyp-build`)),node_pre_gyp_1=__importDefault(require(`@mapbox/node-pre-gyp`)),url_1=require(`url`),acorn=acorn_1.Parser.extend(require(`acorn-import-attributes`).importAttributesOrAssertions),os_1=__importDefault(require(`os`)),url_2=__importDefault(require(`url`)),wrappers_1=require(`./utils/wrappers`),resolve_from_1=__importDefault(require(`resolve-from`)),staticProcess={cwd:()=>cwd,env:{NODE_ENV:static_eval_1.UNKNOWN,[static_eval_1.UNKNOWN]:!0},[static_eval_1.UNKNOWN]:!0},EXPRESS_SET=Symbol(),EXPRESS_ENGINE=Symbol(),NBIND_INIT=Symbol(),SET_ROOT_DIR=Symbol(),PKG_INFO=Symbol(),FS_FN=Symbol(),FS_DIR_FN=Symbol(),BINDINGS=Symbol(),NODE_GYP_BUILD=Symbol(),fsSymbols={access:FS_FN,accessSync:FS_FN,createReadStream:FS_FN,exists:FS_FN,existsSync:FS_FN,fstat:FS_FN,fstatSync:FS_FN,lstat:FS_FN,lstatSync:FS_FN,open:FS_FN,readdir:FS_DIR_FN,readdirSync:FS_DIR_FN,readFile:FS_FN,readFileSync:FS_FN,stat:FS_FN,statSync:FS_FN},fsExtraSymbols={...fsSymbols,pathExists:FS_FN,pathExistsSync:FS_FN,readJson:FS_FN,readJSON:FS_FN,readJsonSync:FS_FN,readJSONSync:FS_FN},MODULE_FN=Symbol(),CREATE_REQUIRE=Symbol(),moduleSymbols={register:MODULE_FN,createRequire:CREATE_REQUIRE},staticModules=Object.assign(Object.create(null),{bindings:{default:BINDINGS},express:{default:function(){return{[static_eval_1.UNKNOWN]:!0,set:EXPRESS_SET,engine:EXPRESS_ENGINE}}},fs:{default:fsSymbols,...fsSymbols},module:{default:moduleSymbols,...moduleSymbols},"fs-extra":{default:fsExtraSymbols,...fsExtraSymbols},"graceful-fs":{default:fsSymbols,...fsSymbols},process:{default:staticProcess,...staticProcess},path:{default:{}},os:{default:os_1.default,...os_1.default},url:{default:url_2.default,...url_2.default},"@mapbox/node-pre-gyp":{default:node_pre_gyp_1.default,...node_pre_gyp_1.default},"node-pre-gyp":binary_locators_1.pregyp,"node-pre-gyp/lib/pre-binding":binary_locators_1.pregyp,"node-pre-gyp/lib/pre-binding.js":binary_locators_1.pregyp,"node-gyp-build":{default:NODE_GYP_BUILD},"@aminya/node-gyp-build":{default:NODE_GYP_BUILD},nbind:{init:NBIND_INIT,default:{init:NBIND_INIT}},"resolve-from":{default:resolve_from_1.default},"strong-globalize":{default:{SetRootDir:SET_ROOT_DIR},SetRootDir:SET_ROOT_DIR},pkginfo:{default:PKG_INFO}}),globalBindings={_interopRequireDefault:interop_require_1.normalizeDefaultRequire,_interopRequireWildcard:interop_require_1.normalizeWildcardRequire,__importDefault:interop_require_1.normalizeDefaultRequire,__importStar:interop_require_1.normalizeWildcardRequire,MONGOOSE_DRIVER_PATH:void 0,URL:url_1.URL,Object:{assign:Object.assign}};globalBindings.global=globalBindings.GLOBAL=globalBindings.globalThis=globalBindings;const TRIGGER=Symbol();binary_locators_1.pregyp.find[TRIGGER]=!0;const staticPath=staticModules.path;Object.keys(path_1.default).forEach(e=>{let x=path_1.default[e];if(typeof x==`function`){let b=function e(){return x.apply(e,arguments)};b[TRIGGER]=!0,staticPath[e]=staticPath.default[e]=b}else staticPath[e]=staticPath.default[e]=x}),staticPath.resolve=staticPath.default.resolve=function(...e){return path_1.default.resolve.apply(this,[cwd,...e])},staticPath.resolve[TRIGGER]=!0;const excludeAssetExtensions=new Set([`.h`,`.cmake`,`.c`,`.cpp`]),excludeAssetFiles=new Set([`CHANGELOG.md`,`README.md`,`readme.md`,`changelog.md`]);let cwd;const absoluteRegEx=/^\/[^\/]+|^[a-z]:[\\/][^\\/]+/i;function isAbsolutePathOrUrl(e){if(e instanceof url_1.URL)return e.protocol===`file:`;if(typeof e==`string`){if(e.startsWith(`file:`))try{return new url_1.URL(e),!0}catch{return!1}return absoluteRegEx.test(e)}return!1}const BOUND_REQUIRE=Symbol(),repeatGlobRegEx=/([\/\\]\*\*[\/\\]\*)+/g;async function analyze(e,w,D){let O=new Set,k=new Set,A=new Set,j=path_1.default.dirname(e);cwd=D.cwd;let M=(0,get_package_base_1.getPackageBase)(e),N=e=>{if(!D.analysis.emitGlobs)return;e=e.replaceAll(path_1.default.sep,path_1.default.posix.sep);let x=e.indexOf(static_eval_1.WILDCARD),S=x===-1?e.length:e.lastIndexOf(path_1.default.posix.sep,x),w=e.substring(0,S),T=e.slice(S),E=T.replace(static_eval_1.wildcardRegEx,(e,x)=>T[x-1]===path_1.default.posix.sep?`**/*`:`*`).replace(repeatGlobRegEx,`/**/*`)||`/**/*`;D.ignoreFn(path_1.default.relative(D.base,w+E))||(P=P.then(async()=>{D.log&&console.log(`Globbing `+w+E),(await(0,glob_1.glob)(w+E,{mark:!0,ignore:w+`/**/node_modules/**/*`,dot:!0,nodir:!0})).filter(e=>!excludeAssetExtensions.has(path_1.default.extname(e))&&!excludeAssetFiles.has(path_1.default.basename(e))).forEach(e=>O.add(e))}))},P=Promise.resolve();w=w.replace(/^#![^\n\r]*[\r\n]/,``);let F,I=!1;try{F=acorn.parse(w,{ecmaVersion:`latest`,allowReturnOutsideFunction:!0}),I=!1}catch(b){b&&b.message&&b.message.includes(`sourceType: module`)||D.warnings.add(Error(`Failed to parse ${e} as script:\n${b&&b.message}`))}if(!F)try{F=acorn.parse(w,{ecmaVersion:`latest`,sourceType:`module`,allowAwaitOutsideFunction:!0}),I=!0}catch(b){return D.warnings.add(Error(`Failed to parse ${e} as module:\n${b&&b.message}`)),{assets:O,deps:k,imports:A,isESM:!1}}let L=(0,url_1.pathToFileURL)(e).href,R=Object.assign(Object.create(null),{__dirname:{shadowDepth:0,value:{value:path_1.default.resolve(e,`..`)}},__filename:{shadowDepth:0,value:{value:e}},process:{shadowDepth:0,value:{value:staticProcess}}});(!I||D.mixedModules)&&(R.require={shadowDepth:0,value:{value:{[static_eval_1.FUNCTION](e){return k.add(e),staticModules[e.startsWith(`node:`)?e.slice(5):e].default},resolve(b){return(0,resolve_dependency_js_1.default)(b,e,D)}}}},R.require.value.value.resolve[TRIGGER]=!0);function z(e,b){e===`require`&&`value`in b&&b.value!==BOUND_REQUIRE||(R[e]={shadowDepth:0,value:b})}function B(e){let b=R[e];if(b&&b.shadowDepth===0)return b.value}function V(e){let b=R[e];return b&&b.shadowDepth===0}if((I||D.mixedModules)&&isAst(F))for(let e of F.body)if(e.type===`ImportDeclaration`){let b=String(e.source.value);k.add(b);let x=staticModules[b.startsWith(`node:`)?b.slice(5):b];if(x)for(let b of e.specifiers)b.type===`ImportNamespaceSpecifier`?z(b.local.name,{value:x}):b.type===`ImportDefaultSpecifier`&&`default`in x?z(b.local.name,{value:x.default}):b.type===`ImportSpecifier`&&b.imported.name in x&&z(b.local.name,{value:x[b.imported.name]})}else (e.type===`ExportNamedDeclaration`||e.type===`ExportAllDeclaration`)&&e.source&&k.add(String(e.source.value));async function H(e,b=!0){let x=Object.create(null);return Object.keys(globalBindings).forEach(e=>{x[e]={value:globalBindings[e]}}),Object.keys(R).forEach(e=>{x[e]=B(e)}),x[`import.meta`]={url:L},await(0,static_eval_1.evaluate)(e,x,b)}let U,W,G=!1;function K(e){if(!D.analysis.emitGlobs||!e.startsWith(`./`)&&!e.startsWith(`../`))return;e=path_1.default.resolve(j,e).replaceAll(path_1.default.sep,path_1.default.posix.sep);let x=e.indexOf(static_eval_1.WILDCARD),S=x===-1?e.length:e.lastIndexOf(path_1.default.posix.sep,x),w=e.substring(0,S),T=e.slice(S),E=T.replace(static_eval_1.wildcardRegEx,(e,x)=>T[x-1]===path_1.default.posix.sep?`**/*`:`*`)||`/**/*`;E.endsWith(`*`)||(E+=`?(`+(D.ts?`.ts|.tsx|`:``)+`.js|.json|.node)`),!D.ignoreFn(path_1.default.relative(D.base,w+E))&&(P=P.then(async()=>{D.log&&console.log(`Globbing `+w+E),(await(0,glob_1.glob)(w+E,{mark:!0,ignore:w+`/**/node_modules/**/*`,nodir:!0})).filter(e=>!excludeAssetExtensions.has(path_1.default.extname(e))&&!excludeAssetFiles.has(path_1.default.basename(e))).forEach(e=>k.add(e))}))}async function q(e,b=!1){if(e.type===`ConditionalExpression`){await q(e.consequent,b),await q(e.alternate,b);return}if(e.type===`LogicalExpression`){await q(e.left,b),await q(e.right,b);return}let x=await H(e,!0);if(!x)return;function S(e){(b?A:k).add(e)}`value`in x&&typeof x.value==`string`?x.wildcards?x.wildcards.length>=1&&K(x.value):S(x.value):(`ifTrue`in x&&typeof x.ifTrue==`string`&&S(x.ifTrue),`else`in x&&typeof x.else==`string`&&S(x.else))}let J=(0,pluginutils_1.attachScopes)(F,`scope`);isAst(F)&&((0,wrappers_1.handleWrappers)(F),await(0,special_cases_1.default)({id:e,ast:F,emitDependency:e=>k.add(e),emitAsset:e=>O.add(e),emitAssetDirectory:N,job:D}));async function Y(e,b){if(!U)throw Error(`Internal error: No staticChildNode for backtrack.`);let x=await H(e,!0);if(x&&(`value`in x&&typeof x.value!=`symbol`||`ifTrue`in x&&typeof x.ifTrue!=`symbol`&&typeof x.else!=`symbol`)){W=x,U=e,b&&b.skip();return}await $()}return await(0,estree_walker_1.asyncWalk)(F,{async enter(x,S){let C=x,w=S;if(C.scope)for(let e in J=C.scope,C.scope.declarations)e in R&&R[e].shadowDepth++;if(!U&&w){if(C.type===`Identifier`){if((0,ast_helpers_1.isIdentifierRead)(C,w)&&D.analysis.computeFileReferences){let e;(typeof(e=B(C.name)?.value)==`string`&&e.match(absoluteRegEx)||e&&(typeof e==`function`||typeof e==`object`)&&e[TRIGGER])&&(W={value:typeof e==`string`?e:void 0},U=C,await Y(w,this))}}else if(D.analysis.computeFileReferences&&C.type===`MemberExpression`&&C.object.type===`MetaProperty`&&C.object.meta.name===`import`&&C.object.property.name===`meta`&&(C.property.computed?C.property.value:C.property.name)===`url`)W={value:L},U=C,await Y(w,this);else if(C.type===`ImportExpression`){await q(C.source,!0);return}else if(C.type===`CallExpression`){if((!I||D.mixedModules)&&C.callee.type===`Identifier`&&C.arguments.length){if(C.callee.name===`require`&&R.require&&R.require.shadowDepth===0){await q(C.arguments[0]);return}}else if((!I||D.mixedModules)&&C.callee.type===`MemberExpression`&&C.callee.object.type===`Identifier`&&C.callee.object.name===`module`&&!(`module`in R)&&C.callee.property.type===`Identifier`&&!C.callee.computed&&C.callee.property.name===`require`&&C.arguments.length){await q(C.arguments[0]);return}else if((!I||D.mixedModules)&&C.callee.type===`MemberExpression`&&C.callee.object.type===`Identifier`&&C.callee.object.name===`require`&&R.require&&R.require.shadowDepth===0&&C.callee.property.type===`Identifier`&&!C.callee.computed&&C.callee.property.name===`resolve`&&C.arguments.length){await q(C.arguments[0]);return}let x=D.analysis.evaluatePureExpressions&&await H(C.callee,!1);if(x&&`value`in x&&typeof x.value==`function`&&x.value[TRIGGER]&&D.analysis.computeFileReferences)W=await H(C,!0),W&&w&&(U=C,await Y(w,this));else if(x&&`value`in x&&typeof x.value==`symbol`)switch(x.value){case BOUND_REQUIRE:C.arguments.length===1&&C.arguments[0].type===`Literal`&&C.callee.type===`Identifier`&&(!R.require||R.require.shadowDepth===0)&&await q(C.arguments[0]);break;case BINDINGS:if(C.arguments.length){let e=await H(C.arguments[0],!1);if(e&&`value`in e&&e.value){let b;typeof e.value==`object`?b=e.value:typeof e.value==`string`&&(b={bindings:e.value}),b.path||=!0,b.module_root=M;let x;try{x=(0,bindings_1.default)(b)}catch{}x&&(W={value:x},U=C,await $())}}break;case NODE_GYP_BUILD:if(C.arguments.length){let e=await H(C.arguments[0],!1);if(e&&`value`in e&&e.value){let b=e.value,x;try{let e=C?.callee?.arguments?.[0]?.value||`node-gyp-build`,S=(0,resolve_from_1.default)(b,e);x=require(S).path(b)}catch{try{x=node_gyp_build_1.default.path(b)}catch{}}x&&(W={value:x},U=C,await $())}}break;case NBIND_INIT:if(C.arguments.length){let e=await H(C.arguments[0],!1);if(e&&`value`in e&&(typeof e.value==`string`||e.value===void 0)){let x=(0,binary_locators_1.nbind)(e.value);if(x&&x.path)return k.add(path_1.default.relative(j,x.path).replace(/\\/g,`/`)),this.skip()}}break;case EXPRESS_SET:if(C.arguments.length===2&&C.arguments[0].type===`Literal`&&C.arguments[0].value===`view engine`&&!G)return await q(C.arguments[1]),this.skip();break;case EXPRESS_ENGINE:G=!0;break;case FS_FN:case FS_DIR_FN:if(C.arguments[0]&&D.analysis.computeFileReferences&&(W=await H(C.arguments[0],!0),W))return U=C.arguments[0],x.value===FS_DIR_FN&&C.arguments[0].type===`Identifier`&&C.arguments[0].name===`__dirname`?N(j):await Y(w,this),this.skip();break;case SET_ROOT_DIR:if(C.arguments[0]){let e=await H(C.arguments[0],!1);return e&&`value`in e&&e.value&&N(e.value+`/intl`),this.skip()}break;case PKG_INFO:let S=path_1.default.resolve(e,`../package.json`),E=path_1.default.resolve(`/package.json`);for(;S!==E&&await D.stat(S)===null;)S=path_1.default.resolve(S,`../../package.json`);S!==E&&O.add(S);break;case MODULE_FN:if(C.arguments.length&&C.arguments[0].type===`Literal`){let e=C.arguments[0].value;if(e.startsWith(`.`)){let x=C.arguments.length>1?await H(C.arguments[1]):void 0;if(x&&`value`in x){let S=x.value instanceof url_1.URL?x.value.href:typeof x.value==`string`?x.value:x.value.parentURL,C=new url_1.URL(e,S).href,w=L.slice(0,L.lastIndexOf(`/`)),T=path_1.default.relative(w,C),E=T.startsWith(`.`)?T:`./`+T;A.add(E)}}else A.add(e)}break}}else if(C.type===`VariableDeclaration`&&w&&!(0,ast_helpers_1.isVarLoop)(w)&&D.analysis.evaluatePureExpressions)for(let e of C.declarations){if(!e.init)continue;let b=await H(e.init,!0);if(b){if(e.id.type===`Identifier`)z(e.id.name,b);else if(e.id.type===`ObjectPattern`&&`value`in b)for(let x of e.id.properties)x.type!==`Property`||x.key.type!==`Identifier`||x.value.type!==`Identifier`||typeof b.value!=`object`||b.value===null||!(x.key.name in b.value)||z(x.value.name,{value:b.value[x.key.name]});!(`value`in b)&&isAbsolutePathOrUrl(b.ifTrue)&&isAbsolutePathOrUrl(b.else)&&(W=b,U=e.init,await $())}}else if(C.type===`AssignmentExpression`&&w&&!(0,ast_helpers_1.isLoop)(w)&&D.analysis.evaluatePureExpressions){if(!V(C.left.name)){let e=await H(C.right,!1);if(e&&`value`in e){if(C.left.type===`Identifier`)z(C.left.name,e);else if(C.left.type===`ObjectPattern`)for(let b of C.left.properties)b.type!==`Property`||b.key.type!==`Identifier`||b.value.type!==`Identifier`||typeof e.value!=`object`||e.value===null||!(b.key.name in e.value)||z(b.value.name,{value:e.value[b.key.name]});isAbsolutePathOrUrl(e.value)&&(W=e,U=C.right,await $())}}}else if((!I||D.mixedModules)&&(C.type===`FunctionDeclaration`||C.type===`FunctionExpression`||C.type===`ArrowFunctionExpression`)&&(C.arguments||C.params)[0]&&(C.arguments||C.params)[0].type===`Identifier`){let e,b;if((C.type===`ArrowFunctionExpression`||C.type===`FunctionExpression`)&&w&&w.type===`VariableDeclarator`&&w.id.type===`Identifier`?(e=w.id,b=C.arguments||C.params):C.id&&(e=C.id,b=C.arguments||C.params),e&&C.body.body){let x,S=!1;for(let e=0;e<C.body.body.length;e++)if(C.body.body[e].type===`VariableDeclaration`&&!x&&(x=C.body.body[e].declarations.find(e=>e&&e.id&&e.id.type===`Identifier`&&e.init&&e.init.type===`CallExpression`&&e.init.callee.type===`Identifier`&&e.init.callee.name===`require`&&R.require.shadowDepth===0&&e.init.arguments[0]&&e.init.arguments[0].type===`Identifier`&&e.init.arguments[0].name===b[0].name)),x&&C.body.body[e].type===`ReturnStatement`&&C.body.body[e].argument&&C.body.body[e].argument.type===`Identifier`&&C.body.body[e].argument.name===x.id.name){S=!0;break}S&&z(e.name,{value:BOUND_REQUIRE})}}if(C.type===`CallExpression`&&C.callee.type===`MemberExpression`&&C.callee.object.type===`Identifier`&&C.callee.object.name===`module`&&C.callee.property.type===`Identifier`&&C.callee.property.name===`createRequire`&&w.type===`VariableDeclarator`&&w.id.type===`Identifier`){let e=w.id.name;z(e,{value:BOUND_REQUIRE})}if(C.type===`CallExpression`&&C.callee.type===`Identifier`&&C.callee.name===`createRequire`){let e=B(`createRequire`);if(e&&`value`in e&&e.value===CREATE_REQUIRE&&w.type===`VariableDeclarator`&&w.id.type===`Identifier`){let e=w.id.name;z(e,{value:BOUND_REQUIRE})}}}},async leave(e,b){let x=e,S=b;if(x.scope)for(let e in J.parent&&(J=J.parent),x.scope.declarations)e in R&&(R[e].shadowDepth>0?R[e].shadowDepth--:delete R[e]);U&&S&&await Y(S,this)}}),await P,{assets:O,deps:k,imports:A,isESM:I};async function X(e){let x=e.indexOf(static_eval_1.WILDCARD),S=x===-1?e.length:e.lastIndexOf(path_1.default.sep,x),w=e.substring(0,S);try{var T=await D.stat(w);if(T===null)throw Error(`file not found`)}catch{return}x!==-1&&T.isFile()||(T.isFile()?O.add(e):T.isDirectory()&&Z(e)&&N(e))}function Z(x){let S=``;if(x.endsWith(path_1.default.sep)?S=path_1.default.sep:x.endsWith(path_1.default.sep+static_eval_1.WILDCARD)?S=path_1.default.sep+static_eval_1.WILDCARD:x.endsWith(static_eval_1.WILDCARD)&&(S=static_eval_1.WILDCARD),x===j+S||x===cwd+S||x.endsWith(path_1.default.sep+`node_modules`+S)||j.startsWith(x.slice(0,x.length-S.length)+path_1.default.sep))return!1;if(M){let S=e.substring(0,e.indexOf(path_1.default.sep+`node_modules`))+path_1.default.sep+`node_modules`+path_1.default.sep;if(!x.startsWith(S))return D.log&&console.log(`Skipping asset emission of `+x.replace(static_eval_1.wildcardRegEx,`*`)+` for `+e+` as it is outside the package base `+M),!1}return!0}function Q(e){return e instanceof url_1.URL?(0,url_1.fileURLToPath)(e):e.startsWith(`file:`)?(0,url_1.fileURLToPath)(new url_1.URL(e)):path_1.default.resolve(e)}async function $(){if(W){if(`value`in W&&isAbsolutePathOrUrl(W.value))try{await X(Q(W.value))}catch{}else if(`ifTrue`in W&&`else`in W&&isAbsolutePathOrUrl(W.ifTrue)&&isAbsolutePathOrUrl(W.else)){let e;try{e=Q(W.ifTrue)}catch{}let b;try{b=Q(W.else)}catch{}e&&await X(e),b&&await X(b)}else if(U&&U.type===`ArrayExpression`&&`value`in W&&W.value instanceof Array)for(let e of W.value)try{await X(Q(e))}catch{}U=W=void 0}}}function isAst(e){return`body`in e}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nf3",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": "unjs/nf3",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"type": "module",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": "./dist/index.mjs",
|
|
11
|
+
"./db": "./dist/db.mjs",
|
|
11
12
|
"./plugin": "./dist/plugin.mjs"
|
|
12
13
|
},
|
|
13
14
|
"types": "./dist/index.d.mts",
|
|
@@ -28,19 +29,19 @@
|
|
|
28
29
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
29
30
|
"@types/node": "^25.0.3",
|
|
30
31
|
"@types/semver": "^7.7.1",
|
|
31
|
-
"@vercel/nft": "^1.
|
|
32
|
+
"@vercel/nft": "^1.2.0",
|
|
32
33
|
"@vitest/coverage-v8": "^4.0.16",
|
|
33
34
|
"automd": "^0.4.2",
|
|
34
35
|
"changelogen": "^0.6.2",
|
|
35
36
|
"eslint": "^9.39.2",
|
|
36
37
|
"eslint-config-unjs": "^0.6.2",
|
|
37
38
|
"exsolve": "^1.0.8",
|
|
38
|
-
"obuild": "^0.4.
|
|
39
|
+
"obuild": "^0.4.14",
|
|
39
40
|
"oxc-minify": "^0.107.0",
|
|
40
41
|
"pathe": "^2.0.3",
|
|
41
42
|
"pkg-types": "^2.3.0",
|
|
42
43
|
"prettier": "^3.7.4",
|
|
43
|
-
"rolldown": "^1.0.0-beta.
|
|
44
|
+
"rolldown": "^1.0.0-beta.59",
|
|
44
45
|
"rollup": "^4.55.1",
|
|
45
46
|
"rollup-plugin-esbuild": "^6.2.1",
|
|
46
47
|
"semver": "^7.7.3",
|