bunup 0.5.9 → 0.5.10
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/dist/cli.js +2 -2
- package/dist/index.d.ts +427 -454
- package/dist/index.js +1 -1
- package/dist/plugins.d.ts +432 -458
- package/dist/plugins.js +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var Ir=Object.create;var{getPrototypeOf:Tr,defineProperty:Y,getOwnPropertyNames:
|
|
|
3
3
|
`);let i=t.labels[0],s=i?Gr(n,i.start):"",g=`${B(o)}${s}: ${Hr(t.message)}`;b[r?"warn":"error"](g),e=!0}if(e&&!r)throw console.log(`
|
|
4
4
|
`),console.log(A.default.gray(`See ${A.default.blue("https://bunup.dev/docs/troubleshooting/explicit-type-annotation-errors")} for details.`)),console.log(`
|
|
5
5
|
`),new R}function Gr(r,e){if(e===void 0)return"";let t=r.slice(0,e).split(`
|
|
6
|
-
`),n=t.length,o=t[t.length-1].length+1;return` (${n}:${o})`}function Hr(r){return r.replace(" with --isolatedDeclarations","").replace(" with --isolatedDeclaration","")}function Kr(r){return Z(r).map((e)=>new RegExp(`^${e}($|\\/|\\\\)`))}function er(r,e){return typeof e==="string"?e===r:e.test(r)}function _(r,e,t){let o=Kr(t).some((s)=>s.test(r))||e.external?.some((s)=>er(r,s)),i=e.noExternal?.some((s)=>er(r,s));return o&&!i}var tr=/\.(d\.ts|d\.mts|d\.cts|ts|mts|cts|tsx)$/,or=/[\\/]node_modules[\\/]/,nr=/\.(js|mjs|cjs|ts|mts|cts|tsx|jsx)$/;function L(r){return r.endsWith(".d.ts")||r.endsWith(".d.mts")||r.endsWith(".d.cts")}function I(r){return[".ts",".mts",".cts",".tsx"].some((e)=>r.endsWith(e))&&!L(r)}function T(r){if(L(r))return r;if(r.endsWith(".mts"))return`${r.slice(0,-4)}.d.mts`;if(r.endsWith(".cts"))return`${r.slice(0,-4)}.d.cts`;if(nr.test(r))return r.replace(nr,".d.ts");return`${r}.d.ts`}import{resolveTsImportPath as Xr}from"ts-import-resolver";var ir=(r,e,t)=>{let n=new Map;return{name:"bunup:virtual-dts",async resolveId(o,i){if(i===void 0)return n.set(o,r),o;let s=
|
|
6
|
+
`),n=t.length,o=t[t.length-1].length+1;return` (${n}:${o})`}function Hr(r){return r.replace(" with --isolatedDeclarations","").replace(" with --isolatedDeclaration","")}function Kr(r){return Z(r).map((e)=>new RegExp(`^${e}($|\\/|\\\\)`))}function er(r,e){return typeof e==="string"?e===r:e.test(r)}function _(r,e,t){let o=Kr(t).some((s)=>s.test(r))||e.external?.some((s)=>er(r,s)),i=e.noExternal?.some((s)=>er(r,s));return o&&!i}var tr=/\.(d\.ts|d\.mts|d\.cts|ts|mts|cts|tsx)$/,or=/[\\/]node_modules[\\/]/,nr=/\.(js|mjs|cjs|ts|mts|cts|tsx|jsx)$/;function L(r){return r.endsWith(".d.ts")||r.endsWith(".d.mts")||r.endsWith(".d.cts")}function I(r){return[".ts",".mts",".cts",".tsx"].some((e)=>r.endsWith(e))&&!L(r)}function T(r){if(L(r))return r;if(r.endsWith(".mts"))return`${r.slice(0,-4)}.d.mts`;if(r.endsWith(".cts"))return`${r.slice(0,-4)}.d.cts`;if(nr.test(r))return r.replace(nr,".d.ts");return`${r}.d.ts`}import{resolveTsImportPath as Xr}from"ts-import-resolver";var ir=(r,e,t)=>{let n=new Map;return{name:"bunup:virtual-dts",async resolveId(o,i){if(i===void 0)return n.set(o,r),o;let s=Xr({path:o,importer:i,tsconfig:e.tsconfig,rootDir:t});if(!s||!I(s))return null;let c=T(s);if(!c)return null;return n.set(c,s),c},load:{filter:{id:{include:[tr],exclude:[or]}},async handler(o){if(L(o)){let i=n.get(o);if(!i)return null;let s=await P(i);if(!s)return null;return{code:s,moduleSideEffects:!1}}return null}},buildEnd(){n.clear()}}};async function sr(r,e,t,n){let o=Qr.resolve(n,r),i=T(o),s=typeof e.dts==="object"&&"resolve"in e.dts?e.dts.resolve:void 0,{output:c}=await Nr({input:i,write:!1,...t.path&&{resolve:{tsconfigFilename:t.path}},onwarn(a,f){if(["UNRESOLVED_IMPORT","CIRCULAR_DEPENDENCY","EMPTY_BUNDLE"].includes(a.code??""))return;f(a)},plugins:[ir(o,t,n),qr({dtsInput:!0,emitDtsOnly:!0,resolve:s})]});rr(!!e.watch);let g=c[0]?.code;if(!g)return b.warn(`Generated empty declaration file for entry "${o}"`,{muted:!0}),"";return g}import{basename as Vr,dirname as Zr,extname as zr}from"path";function gr(r){let e=Vr(r),t=zr(e);return t?e.slice(0,-t.length):e}function v(r){if(typeof r==="string")return[{fullPath:r,outputBasePath:gr(r)}];if(typeof r==="object"&&!Array.isArray(r))return Object.entries(r).map(([n,o])=>({fullPath:o,outputBasePath:n}));let e=[],t=new Set;for(let n of r){let o=gr(n);if(!t.has(o)){e.push({fullPath:n,outputBasePath:o}),t.add(o);continue}let s=Zr(n).split("/").filter((g)=>g!=="."&&g!=="");if(s.length===0){let g=1,a;do a=`${o}_${g++}`;while(t.has(a));e.push({fullPath:n,outputBasePath:a}),t.add(a);continue}let c=!1;for(let g=1;g<=s.length&&!c;g++){let f=`${s.slice(-g).join("/")}/${o}`;if(!t.has(f))e.push({fullPath:n,outputBasePath:f}),t.add(f),c=!0}if(!c){let g=1,a;do a=`${s.join("/")}/${o}_${g++}`;while(t.has(a));e.push({fullPath:n,outputBasePath:a}),t.add(a)}}return e}function ar(r){return r.filter((e)=>I(e.fullPath))}function lr(r,e){return`[dir]/${r}${e}`}function ur(r){return`${r}-[hash].[ext]`}function cr(r){return`${r}-[name]-[hash].[ext]`}import{loadConfig as dr}from"coffi";async function mr(r){let{config:e,filepath:t}=await dr({name:"package",cwd:r,extensions:[".json"]});return{packageJson:e,path:t}}async function br(r,e){let{config:t,filepath:n}=await dr({name:"tsconfig",cwd:r,extensions:[".json"],preferredPath:e});return{tsconfig:t,path:n}}var Jr={entry:[],format:["cjs"],outDir:"dist",target:"node",clean:!0};function fr(r){return{...Jr,...r}}function pr(r){let{minify:e,minifyWhitespace:t,minifyIdentifiers:n,minifySyntax:o}=r,i=e===!0;return{whitespace:t??i,identifiers:n??i,syntax:o??i}}function xr(r,e){return e==="cjs"?r:void 0}function hr(r){if(r===!0)return"inline";return typeof r==="string"?r:void 0}function Cr(r,e,t,n){return{...typeof t==="object"&&Object.keys(t).reduce((o,i)=>{let s=JSON.stringify(t[i]);return o[`process.env.${i}`]=s,o[`import.meta.env.${i}`]=s,o},{}),...r,...n==="cjs"&&(e===!0||typeof e==="object"&&e.importMetaUrl)&&{"import.meta.url":"importMetaUrl"}}}function Br(r,e){return r===void 0?e==="esm":r}function wr(r){return typeof r==="string"?r:void 0}function Er(r,e){return{name:"bunup:external-plugin",setup(t){t.onResolve({filter:/.*/},(n)=>{let o=n.path;if(_(o,r,e))return{path:o,external:!0};return null})}}}var Pr=/\.(js|ts|jsx|tsx|mts|cts)$/,U={dirnameFilename:{appliesTo:(r,e)=>r==="esm"&&D(e),isNeededInFile:(r)=>/\b__dirname\b/.test(r)||/\b__filename\b/.test(r),generateCode:()=>`import { fileURLToPath } from 'url';
|
|
7
7
|
import { dirname } from 'path';
|
|
8
8
|
|
|
9
9
|
const __filename = fileURLToPath(import.meta.url);
|