resolvewithplus
Advanced tools
Comparing version 2.1.4 to 2.1.5
{ | ||
"name": "resolvewithplus", | ||
"version": "2.1.4", | ||
"version": "2.1.5", | ||
"description": "resolvewith with extra power", | ||
@@ -5,0 +5,0 @@ "readmeFilename": "README.md", |
@@ -22,3 +22,3 @@ resolvewithplus | ||
`resolvewithplus` resolves module paths à la [node.js' import.meta.resolve function][33] and the [import-meta-resolve npm package.][35] It exists mostly to be small and to resolve module paths for `esmock`. [It's size is ~7kB][36] compared to [import-meta-resolve's ~76kB size.][37] For more details, [see the wiki.](https://github.com/iambumblehead/resolvewithplus/wiki) | ||
`resolvewithplus` resolves module paths à la [node.js' import.meta.resolve function][33] and the [import-meta-resolve npm package.][35] It exists mostly to be small and to resolve module paths for `esmock`. [It's size is ~8kB][36] compared to [import-meta-resolve's ~75kB size.][37] For more details, [see the wiki.](https://github.com/iambumblehead/resolvewithplus/wiki) | ||
@@ -25,0 +25,0 @@ ![scrounge](https://github.com/iambumblehead/scroungejs/raw/main/img/hand.png) |
@@ -1,1 +0,1 @@ | ||
import E from"fs";import P from"url";import i from"path";import F from"module";const O=F.createRequire(import.meta.url),A=E.realpathSync.native,q=new RegExp("^(?:node:)?("+F.builtinModules.join("|").replace("/","/")+")$"),T=/^\.?\.?([a-zA-Z]:)?(\/|\\)/,j=/^.\.?(?=\/|\\)/,U=/\\/g,ot=/index.[tj]sx?$/,rt=/[\\/]resolvewithplus[\\/]/,L=/\.js$/,it=/\.ts$/,ct=/(^@[^/]*\/[^/]*|^[^/]*)\/?(.*)$/,y=/^#/,N=/(\*)/g,K=/([./])/g,lt=/^node:/,ut=/^file:/,M=[".js",".mjs",".ts",".tsx",".json",".node"],at=M.map(t=>`index${t}`),V="node_modules",p="package.json",W="node",m="default",ft="browser",z="import",d=":spectype",B="module",C="import",D="commonjs",pt="require",R=".",b=t=>t&&typeof t=="object",x={},w=t=>({[B]:C,[D]:pt})[t]||null,mt=t=>lt.test(t)?t:`node:${t}`,gt=t=>t&&P.pathToFileURL(t).href,ht=t=>q.test(t),jt=t=>ut.test(t)?P.fileURLToPath(t):t,yt=t=>i.resolve(i.extname(t)?i.dirname(t):t)+i.sep,S=t=>U.test(t)?t.replace(U,i.posix.sep):t,a=(t,n)=>{try{n=E.statSync(t)}catch{n=!1}return n&&(n.isFile()||n.isFIFO())},G=(t,n)=>n.packagejsonmap&&n.packagejsonmap[t]||a(t)&&O(t),dt=(t,n)=>{const e=n.find(s=>a(t+s))||null;return e&&t+e},Rt=(t,n)=>{const e=n.find(s=>a(i.join(t,s)))||null;return e&&i.join(t,e)},J=(t,n=t.split(i.sep))=>{const e=(s,o=[[],[]])=>{if(!s.length)return o[1];if(s[0]===V&&rt.test(t))return e(s.slice(1),o);const r=o[0].length?i.join(o[0].slice(-1)[0],s[0]):s[0]||i.sep;return o[0].push(r),o[1].push(i.resolve(i.join(r,V))),e(s.slice(1),o)};return e(n)},bt=t=>{const n=t.split(i.sep).slice(1).reduce((e,s,o)=>(e.push(i.resolve(i.join(o?e[o-1]:i.sep,s))),e),[]).reverse().find(e=>a(i.join(e,p)));return n&&i.join(n,p)},xt=t=>(String(t).match(ct)||[]).slice(1),Z=(t,n)=>new RegExp(t.replace(K,"\\$1").replace(N,".*")).test(n),H=(t,n,e)=>{const s=new RegExp(t.replace(K,"\\$1").replace(N,"(.*)")),o=(e.match(s)||[])[1];return o&&n.replace("*",o)},Q=(t,n,e,s,o=!1)=>{if(Z(t,e))if(String(n).includes("*"))Z(n,e)?o=e:t.includes("*")&&t!==n&&(o=H(t,n,e));else{if(b(n)&&t.includes("*")){const r=e,c=i.posix.join(e,t),f=Object.keys(n).reduce((u,h)=>{const nt=n[h].split(/\.?\//).find(st=>st);return u[h]=H(c,i.posix.join(nt,c),i.posix.join(r,n[h].split("*")[1])),u},{});return l(f,e,s)}o=o||n}return o},X=(t,n,e,s,o=t[0])=>t.length?(y.test(e)?y.test(o):j.test(o))&&(typeof n[o]=="string"||b(n[o]))&&Q(o,n[o],e,s)||X(t.slice(1),n,e,s):null,l=(t,n,e={})=>{const s=e.priority||[W,m];let o=!1;return typeof t=="string"?t:(!o&&Array.isArray(t)&&(o=t.reduce((r,c)=>r||l(c,n,e),null)),!o&&b(t)&&(typeof t[n]=="string"&&(o=t[n]),o||(o=s.reduce((r,c)=>r||(c=c===d?w(e.packagejsontype):c,l(t[c],n,e)),!1)),!o&&t[m]&&(o=l(t[m],n)),!o&&t[n]&&(o=l(t[n],n,e)),o||(o=X(Object.keys(t),t,n,e)),!o&&t[R]&&(s.includes(n)?o=s.reduce((r,c)=>r||(c=c===d?w(e.packagejsontype):c,l(t[R],c,e)),!1):o=l(t[R],n,e))),o)},g=(t,n={})=>{var e=null,s=n.istypescript&&L.test(t)&&t.replace(L,".ts");return a(s)?e=s:a(t)?e=t:e=dt(t,M),e},_=t=>t.type||"exports"in t&&B||D,$=(t,n={},e="")=>{const s=e?i.join(e,t):t;return g(s,n)||!ot.test(t)&&g(i.join(s,"index"))},Y=(t,n={},e="",s=!1)=>{const o=_(t);return n.isspectype!==!1&&(s=t[o]||t[w(o)],s=s&&$(s,n,e)),!s&&(n.priority||[]).includes(C)&&t.module&&(s=$(t.module,n,e)),!s&&t.main&&(s=$(t.main,n,e)),s||null},k=(t,n={},e="",s)=>{const o=_(t),r=Object.assign({packagejsontype:o},n);return n.isbrowser&&t.browser&&(s=l(t.browser,z,r),s=s&&!T.test(s)?i.join(e,s):s),s||(s=Y(t,r,e)),s},I=(t,n)=>{const e=i.join(t,p),s=G(e,n),o=s?k(s,n,t):!1;return o||Rt(t,at)},v=(t,n,e)=>{const s=j.test(t)?i.join(n,t):t;return g(s,e)||I(s,e)},wt=(t,n,e,s)=>{const o=e&&e.imports,r=l(o,n,s);return r&&(j.test(r)?i.join(t,r):et(r,t,{isposixpath:!0}))},St=(t,n,e,s,o)=>{const r=l(s&&s.exports,e?"./"+e:z,o);return r&&i.join(t,n,r)},_t=(t,n,e,s)=>{const o=i.join(t,n,p),r=G(o,s),c=r&&_(r);return r&&St(t,n,e,r,Object.assign({packagejsontype:c},s))},$t=(t,n,e)=>{const s=bt(n),o=i.dirname(s);return s&&wt(o,t,O(s),e)},Et=(t,n,e)=>{const[s,o]=xt(t);if(y.test(s))return $t(t,n,e);const r=J(n);return function c(f,u){return u--?_t(i.join(f[u]),s,o,e)||v(i.join(f[u],t),null,e)||c(r,u):null}(r,r.length)},Pt=(t,n,e)=>{var s=null;return n=typeof n=="string"?yt(jt(decodeURI(n))):process.cwd(),q.test(t)?s=mt(t):(s=T.test(t)?v(S(t),n,e):Et(t,n,e),s=s&&(e.isposixpath?A(s):gt(S(A(s))))),s},tt=(t,n,e)=>{const s=(o,r)=>typeof o=="boolean"?o:r;return e=e||{},e.istypescript=s(e.istypescript,it.test(n)),e.isbrowser=s(e.isbrowser,!1),e.isspectype=s(e.isspectype,!0),e.packagejsonmap=e.packagejsonmap||null,Array.isArray(e.priority)||(e.priority=e.isbrowser?[ft]:[],e.priority.push(d),e.priority.push(W),e.priority.push(m)),e},et=(t,n,e)=>{let s=x[t+n];return s||(e=tt(t,n,e),s=Pt(t,n,e),x[t+n]=s)};export default Object.assign(et,{pathToPosix:S,getasnode_module_paths:J,getesmkeyvalmatch:Q,getasfilesync:g,getasdirsync:I,gettargetindex:k,iscoremodule:ht,createopts:tt,esmparse:l,cache:x});export{Y as gettargetindextop}; | ||
import P from"fs";import $ from"url";import c from"path";import E from"module";const F=E.createRequire(import.meta.url),O=P.realpathSync.native,A=new RegExp("^(?:node:)?("+E.builtinModules.join("|").replace("/","/")+")$"),q=/^\.?\.?([a-zA-Z]:)?(\/|\\)/,g=/^.\.?(?=\/|\\)/,T=/\\/g,nt=/index.[tj]sx?$/,st=/[\\/]resolvewithplus[\\/]/,U=/\.js$/,rt=/\.ts$/,ot=/(^@[^/]*\/[^/]*|^[^/]*)\/?(.*)$/,j=/^#/,W=/(\*)/g,L=/([./])/g,ct=/^node:/,it=/^file:/,N=[".js",".mjs",".ts",".tsx",".json",".node"],lt=N.map(t=>`index${t}`),B="node_modules",p="package.json",K="node",h="default",at="browser",M="import",d=":spectype",V="module",k="import",z="commonjs",ut="require",y=".",R=t=>t&&typeof t=="object",b={},w=t=>({[V]:k,[z]:ut})[t]||null,ft=t=>ct.test(t)?t:`node:${t}`,pt=t=>t&&$.pathToFileURL(t).href,ht=t=>A.test(t),mt=t=>it.test(t)?$.fileURLToPath(t):t,gt=t=>c.resolve(c.extname(t)?c.dirname(t):t)+c.sep,x=t=>T.test(t)?t.replace(T,c.posix.sep):t,a=(t,n)=>{try{n=P.statSync(t)}catch{n=!1}return n&&(n.isFile()||n.isFIFO())},C=(t,n)=>n.packagejsonmap&&n.packagejsonmap[t]||a(t)&&F(t),jt=(t,n)=>{const e=n.find(s=>a(t+s))||null;return e&&t+e},dt=(t,n)=>{const e=n.find(s=>a(c.join(t,s)))||null;return e&&c.join(t,e)},D=(t,n=t.split(c.sep))=>{const e=(s,r=[[],[]])=>{if(!s.length)return r[1];if(s[0]===B&&st.test(t))return e(s.slice(1),r);const o=r[0].length?c.join(r[0].slice(-1)[0],s[0]):s[0]||c.sep;return r[0].push(o),r[1].push(c.resolve(c.join(o,B))),e(s.slice(1),r)};return e(n)},yt=t=>{const n=t.split(c.sep).slice(1).reduce((e,s,r)=>(e.push(c.resolve(c.join(r?e[r-1]:c.sep,s))),e),[]).reverse().find(e=>a(c.join(e,p)));return n&&c.join(n,p)},Rt=t=>(String(t).match(ot)||[]).slice(1),G=(t,n)=>new RegExp(t.replace(L,"\\$1").replace(W,".*")).test(n),J=(t,n,e)=>{const s=new RegExp(t.replace(L,"\\$1").replace(W,"(.*)")),r=(e.match(s)||[])[1];return r&&n.replace("*",r)},Z=(t,n,e)=>{const s=n.indexOf("*")||0,r=n.slice(0,s),o=n.slice(s+1);if(!(t.startsWith(r)&&t.endsWith(o)))return null;const i=t.slice(-o.length).slice(r.length);return e.replace("*",i)},H=(t,n,e,s,r=!1)=>{if(G(t,e))if(String(n).includes("*"))G(n,e)?r=e:t.includes("*")&&t!==n&&(r=J(t,n,e));else{if(R(n)&&t.includes("*")){const o=Object.keys(n).reduce((i,u)=>(i[u]=Z(e,t,n[u]),i),{});return l(o,e,s)}r=r||n}return r},Q=(t,n,e,s,r=t[0])=>t.length?(j.test(e)?j.test(r):g.test(r))&&(typeof n[r]=="string"||R(n[r]))&&H(r,n[r],e,s)||Q(t.slice(1),n,e,s):null,l=(t,n,e={})=>{const s=e.priority||[K,h];let r=!1;return typeof t=="string"?t:(!r&&Array.isArray(t)&&(r=t.reduce((o,i)=>o||l(i,n,e),null)),!r&&R(t)&&(typeof t[n]=="string"&&(r=t[n]),r||(r=s.reduce((o,i)=>o||(i=i===d?w(e.packagejsontype):i,l(t[i],n,e)),!1)),!r&&t[h]&&(r=l(t[h],n)),!r&&t[n]&&(r=l(t[n],n,e)),r||(r=Q(Object.keys(t),t,n,e)),!r&&t[y]&&(s.includes(n)?r=s.reduce((o,i)=>o||(i=i===d?w(e.packagejsontype):i,l(t[y],i,e)),!1):r=l(t[y],n,e))),r)},m=(t,n={})=>{var e=null,s=n.istypescript&&U.test(t)&&t.replace(U,".ts");return a(s)?e=s:a(t)?e=t:e=jt(t,N),e},S=t=>t.type||"exports"in t&&V||z,_=(t,n={},e="")=>{const s=e?c.join(e,t):t;return m(s,n)||!nt.test(t)&&m(c.join(s,"index"))},X=(t,n={},e="",s=!1)=>{const r=S(t);return n.isspectype!==!1&&(s=t[r]||t[w(r)],s=s&&_(s,n,e)),!s&&(n.priority||[]).includes(k)&&t.module&&(s=_(t.module,n,e)),!s&&t.main&&(s=_(t.main,n,e)),s||null},Y=(t,n={},e="",s)=>{const r=S(t),o=Object.assign({packagejsontype:r},n);return n.isbrowser&&t.browser&&(s=l(t.browser,M,o),s=s&&!q.test(s)?c.join(e,s):s),s||(s=X(t,o,e)),s},I=(t,n)=>{const e=c.join(t,p),s=C(e,n),r=s?Y(s,n,t):!1;return r||dt(t,lt)},v=(t,n,e)=>{const s=g.test(t)?c.join(n,t):t;return m(s,e)||I(s,e)},bt=(t,n,e,s)=>{const r=e&&e.imports,o=l(r,n,s);return o&&(g.test(o)?c.join(t,o):et(o,t,{isposixpath:!0}))},wt=(t,n,e,s,r)=>{const o=l(s&&s.exports,e?"./"+e:M,r);return o&&c.join(t,n,o)},xt=(t,n,e,s)=>{const r=c.join(t,n,p),o=C(r,s),i=o&&S(o);return o&&wt(t,n,e,o,Object.assign({packagejsontype:i},s))},St=(t,n,e)=>{const s=yt(n),r=c.dirname(s);return s&&bt(r,t,F(s),e)},_t=(t,n,e)=>{const[s,r]=Rt(t);if(j.test(s))return St(t,n,e);const o=D(n);return function i(u,f){return f--?xt(c.join(u[f]),s,r,e)||v(c.join(u[f],t),null,e)||i(o,f):null}(o,o.length)},Pt=(t,n,e)=>{var s=null;return n=typeof n=="string"?gt(mt(decodeURI(n))):process.cwd(),A.test(t)?s=ft(t):(s=q.test(t)?v(x(t),n,e):_t(t,n,e),s=s&&(e.isposixpath?O(s):pt(x(O(s))))),s},tt=(t,n,e)=>{const s=(r,o)=>typeof r=="boolean"?r:o;return e=e||{},e.istypescript=s(e.istypescript,rt.test(n)),e.isbrowser=s(e.isbrowser,!1),e.isspectype=s(e.isspectype,!0),e.packagejsonmap=e.packagejsonmap||null,Array.isArray(e.priority)||(e.priority=e.isbrowser?[at]:[],e.priority.push(d),e.priority.push(K),e.priority.push(h)),e},et=(t,n,e)=>{let s=b[t+n];return s||(e=tt(t,n,e),s=Pt(t,n,e),b[t+n]=s)};export default Object.assign(et,{pathToPosix:x,getasnode_module_paths:D,getesmkeyvalmatch:H,getasfilesync:m,getasdirsync:I,gettargetindex:Y,iscoremodule:ht,createopts:tt,esmparse:l,cache:b});export{X as gettargetindextop,J as getesmkeyvalglobreplaced,Z as getesmkeyidpathrefpathexpanded}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7895
20