@visulima/packem 1.0.0-alpha.16 → 1.0.0-alpha.17

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## @visulima/packem [1.0.0-alpha.17](https://github.com/visulima/packem/compare/@visulima/packem@1.0.0-alpha.16...@visulima/packem@1.0.0-alpha.17) (2024-05-28)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * working on better tests ([a6a569e](https://github.com/visulima/packem/commit/a6a569e88496ac30bfebebc05c0b0f967d8810b8))
7
+
1
8
  ## @visulima/packem [1.0.0-alpha.16](https://github.com/visulima/packem/compare/@visulima/packem@1.0.0-alpha.15...@visulima/packem@1.0.0-alpha.16) (2024-05-28)
2
9
 
3
10
 
package/dist/cli.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var v=Object.defineProperty;var s=(n,e)=>v(n,"name",{value:e,configurable:!0});const r=require("node:process"),k=require("@visulima/cerebro"),b=require("./create-bundler.cjs"),h=require("@antfu/install-pkg"),i=require("@clack/prompts"),c=require("@visulima/fs"),j=require("@visulima/package/package-json"),l=require("@visulima/path");function w(n){return n&&typeof n=="object"&&"default"in n?n.default:n}s(w,"_interopDefaultCompat");const x=w(k),C="@visulima/packem",P="1.0.0-alpha.15";var S=Object.defineProperty,p=s((n,e)=>S(n,"name",{value:e,configurable:!0}),"n");const q=p(n=>{n.addCommand({description:"Demonstrate options required",execute:p(async({options:e})=>{let t="build";e.watch?t="watch":e.jit&&(t="jit");const a={};if(e.env)for(const o of e.env)a[o.key]=o.value;await b(e.dir,t,{cjsInterop:e.cjsInterop,configPath:e.config??void 0,debug:e.debug,minify:e.minify,replace:{...a},rollup:{esbuild:{target:e.target},license:{path:e.license},metafile:e.metafile,...e.analyze?{visualizer:{}}:{visualizer:!1}},sourcemap:e.sourcemap,tsconfigPath:e.tsconfig??void 0})},"execute"),name:"build",options:[{defaultValue:".",description:"The directory to build",name:"dir",type:String},{alias:"t",description:"Environments to support. `target` in tsconfig.json is automatically added. Defaults to the current Node.js version.",name:"target"},{description:"Use a custom config file",name:"config",type:String},{description:"Path to the tsconfig.json file",name:"tsconfig",type:String},{description:"Minify the output",name:"minify",type:Boolean},{description:"Generate sourcemaps (experimental)",name:"sourcemap",type:Boolean},{description:"Watch for changes",name:"watch",type:Boolean},{description:"Stub the package for JIT compilation",name:"jit",type:Boolean},{description:"Compile-time environment variables (eg. --env.NODE_ENV=production)",multiple:!0,name:"env",type:p(e=>{const[t,a]=e.split("=");return{key:t,value:a}},"type")},{defaultValue:!1,description:"Generate meta file (experimental)",name:"metafile",type:Boolean},{description:"Path to the license file",name:"license",type:String},{conflicts:"watch",description:"Visualize and analyze the bundle",name:"analyze",type:Boolean},{description:"CJS interop mode, can export default and named export, (experimental).",name:"cjsInterop",type:Boolean}]})},"createBuildCommand");var z=Object.defineProperty,g=s((n,e)=>z(n,"name",{value:e,configurable:!0}),"i");const B=g(n=>{n.addCommand({description:"Initialize packem configuration",execute:g(async({logger:e,options:t})=>{if(i.intro("Welcome to packem setup"),c.isAccessibleSync(l.join(t.dir,"packem.config.ts")))return e.info("Packem project already initialized, you can use `packem build` to build your project"),r.exit(0);if(i.isCancel(t.transformer))return i.cancel("Operation cancelled"),r.exit(0);if(t.transformer===void 0){const u=l.join(t.dir,"package.json");if(!c.isAccessibleSync(u))return e.error("No package.json found in the directory"),r.exit(1);const d=j.parsePackageJson(u),y=[...Object.keys(d.dependencies??{}),...Object.keys(d.devDependencies??{})];if(t.transformer=await i.select({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"}]}),!y.includes(t.transformer)&&await i.confirm({message:"Do you want to install "+t.transformer+"?"})){const f=i.spinner();f.start("Installing "+t.transformer),await h.installPackage(t.transformer==="swc"?"@swc/core":t.transformer,{cwd:t.dir,dev:!0,silent:!0}),f.stop("")}}const a=`import { defineConfig } from "@visulima/packem/config";
2
+ "use strict";var v=Object.defineProperty;var s=(n,e)=>v(n,"name",{value:e,configurable:!0});const r=require("node:process"),k=require("@visulima/cerebro"),b=require("./create-bundler.cjs"),h=require("@antfu/install-pkg"),i=require("@clack/prompts"),c=require("@visulima/fs"),j=require("@visulima/package/package-json"),l=require("@visulima/path");function w(n){return n&&typeof n=="object"&&"default"in n?n.default:n}s(w,"_interopDefaultCompat");const x=w(k),C="@visulima/packem",P="1.0.0-alpha.16";var S=Object.defineProperty,p=s((n,e)=>S(n,"name",{value:e,configurable:!0}),"n");const q=p(n=>{n.addCommand({description:"Demonstrate options required",execute:p(async({options:e})=>{let t="build";e.watch?t="watch":e.jit&&(t="jit");const a={};if(e.env)for(const o of e.env)a[o.key]=o.value;await b(e.dir,t,{cjsInterop:e.cjsInterop,configPath:e.config??void 0,debug:e.debug,minify:e.minify,replace:{...a},rollup:{esbuild:{target:e.target},license:{path:e.license},metafile:e.metafile,...e.analyze?{visualizer:{}}:{visualizer:!1}},sourcemap:e.sourcemap,tsconfigPath:e.tsconfig??void 0})},"execute"),name:"build",options:[{defaultValue:".",description:"The directory to build",name:"dir",type:String},{alias:"t",description:"Environments to support. `target` in tsconfig.json is automatically added. Defaults to the current Node.js version.",name:"target"},{description:"Use a custom config file",name:"config",type:String},{description:"Path to the tsconfig.json file",name:"tsconfig",type:String},{description:"Minify the output",name:"minify",type:Boolean},{description:"Generate sourcemaps (experimental)",name:"sourcemap",type:Boolean},{description:"Watch for changes",name:"watch",type:Boolean},{description:"Stub the package for JIT compilation",name:"jit",type:Boolean},{description:"Compile-time environment variables (eg. --env.NODE_ENV=production)",multiple:!0,name:"env",type:p(e=>{const[t,a]=e.split("=");return{key:t,value:a}},"type")},{defaultValue:!1,description:"Generate meta file (experimental)",name:"metafile",type:Boolean},{description:"Path to the license file",name:"license",type:String},{conflicts:"watch",description:"Visualize and analyze the bundle",name:"analyze",type:Boolean},{description:"CJS interop mode, can export default and named export, (experimental).",name:"cjsInterop",type:Boolean}]})},"createBuildCommand");var z=Object.defineProperty,g=s((n,e)=>z(n,"name",{value:e,configurable:!0}),"i");const B=g(n=>{n.addCommand({description:"Initialize packem configuration",execute:g(async({logger:e,options:t})=>{if(i.intro("Welcome to packem setup"),c.isAccessibleSync(l.join(t.dir,"packem.config.ts")))return e.info("Packem project already initialized, you can use `packem build` to build your project"),r.exit(0);if(i.isCancel(t.transformer))return i.cancel("Operation cancelled"),r.exit(0);if(t.transformer===void 0){const u=l.join(t.dir,"package.json");if(!c.isAccessibleSync(u))return e.error("No package.json found in the directory"),r.exit(1);const d=j.parsePackageJson(u),y=[...Object.keys(d.dependencies??{}),...Object.keys(d.devDependencies??{})];if(t.transformer=await i.select({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"}]}),!y.includes(t.transformer)&&await i.confirm({message:"Do you want to install "+t.transformer+"?"})){const f=i.spinner();f.start("Installing "+t.transformer),await h.installPackage(t.transformer==="swc"?"@swc/core":t.transformer,{cwd:t.dir,dev:!0,silent:!0}),f.stop("")}}const a=`import { defineConfig } from "@visulima/packem/config";
3
3
  import transformer from "@visulima/packem/transformer/${t.transformer}";
4
4
 
5
5
  export default defineConfig({
package/dist/cli.mjs CHANGED
@@ -7,7 +7,7 @@ import __cjs_mod__ from "node:module";
7
7
  const __filename = __cjs_url__.fileURLToPath(import.meta.url);
8
8
  const __dirname = __cjs_path__.dirname(__filename);
9
9
  const require = __cjs_mod__.createRequire(import.meta.url);
10
- const I="@visulima/packem",N="1.0.0-alpha.15";var O=Object.defineProperty,s=r((i,e)=>O(i,"name",{value:e,configurable:!0}),"n");const V=s(i=>{i.addCommand({description:"Demonstrate options required",execute:s(async({options:e})=>{let t="build";e.watch?t="watch":e.jit&&(t="jit");const n={};if(e.env)for(const o of e.env)n[o.key]=o.value;await b(e.dir,t,{cjsInterop:e.cjsInterop,configPath:e.config??void 0,debug:e.debug,minify:e.minify,replace:{...n},rollup:{esbuild:{target:e.target},license:{path:e.license},metafile:e.metafile,...e.analyze?{visualizer:{}}:{visualizer:!1}},sourcemap:e.sourcemap,tsconfigPath:e.tsconfig??void 0})},"execute"),name:"build",options:[{defaultValue:".",description:"The directory to build",name:"dir",type:String},{alias:"t",description:"Environments to support. `target` in tsconfig.json is automatically added. Defaults to the current Node.js version.",name:"target"},{description:"Use a custom config file",name:"config",type:String},{description:"Path to the tsconfig.json file",name:"tsconfig",type:String},{description:"Minify the output",name:"minify",type:Boolean},{description:"Generate sourcemaps (experimental)",name:"sourcemap",type:Boolean},{description:"Watch for changes",name:"watch",type:Boolean},{description:"Stub the package for JIT compilation",name:"jit",type:Boolean},{description:"Compile-time environment variables (eg. --env.NODE_ENV=production)",multiple:!0,name:"env",type:s(e=>{const[t,n]=e.split("=");return{key:t,value:n}},"type")},{defaultValue:!1,description:"Generate meta file (experimental)",name:"metafile",type:Boolean},{description:"Path to the license file",name:"license",type:String},{conflicts:"watch",description:"Visualize and analyze the bundle",name:"analyze",type:Boolean},{description:"CJS interop mode, can export default and named export, (experimental).",name:"cjsInterop",type:Boolean}]})},"createBuildCommand");var D=Object.defineProperty,g=r((i,e)=>D(i,"name",{value:e,configurable:!0}),"i");const E=g(i=>{i.addCommand({description:"Initialize packem configuration",execute:g(async({logger:e,options:t})=>{if(j("Welcome to packem setup"),u(c(t.dir,"packem.config.ts")))return e.info("Packem project already initialized, you can use `packem build` to build your project"),a(0);if(w(t.transformer))return C("Operation cancelled"),a(0);if(t.transformer===void 0){const p=c(t.dir,"package.json");if(!u(p))return e.error("No package.json found in the directory"),a(1);const l=B(p),y=[...Object.keys(l.dependencies??{}),...Object.keys(l.devDependencies??{})];if(t.transformer=await x({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"}]}),!y.includes(t.transformer)&&await P({message:"Do you want to install "+t.transformer+"?"})){const d=f();d.start("Installing "+t.transformer),await h(t.transformer==="swc"?"@swc/core":t.transformer,{cwd:t.dir,dev:!0,silent:!0}),d.stop("")}}const n=`import { defineConfig } from "@visulima/packem/config";
10
+ const I="@visulima/packem",N="1.0.0-alpha.16";var O=Object.defineProperty,s=r((i,e)=>O(i,"name",{value:e,configurable:!0}),"n");const V=s(i=>{i.addCommand({description:"Demonstrate options required",execute:s(async({options:e})=>{let t="build";e.watch?t="watch":e.jit&&(t="jit");const n={};if(e.env)for(const o of e.env)n[o.key]=o.value;await b(e.dir,t,{cjsInterop:e.cjsInterop,configPath:e.config??void 0,debug:e.debug,minify:e.minify,replace:{...n},rollup:{esbuild:{target:e.target},license:{path:e.license},metafile:e.metafile,...e.analyze?{visualizer:{}}:{visualizer:!1}},sourcemap:e.sourcemap,tsconfigPath:e.tsconfig??void 0})},"execute"),name:"build",options:[{defaultValue:".",description:"The directory to build",name:"dir",type:String},{alias:"t",description:"Environments to support. `target` in tsconfig.json is automatically added. Defaults to the current Node.js version.",name:"target"},{description:"Use a custom config file",name:"config",type:String},{description:"Path to the tsconfig.json file",name:"tsconfig",type:String},{description:"Minify the output",name:"minify",type:Boolean},{description:"Generate sourcemaps (experimental)",name:"sourcemap",type:Boolean},{description:"Watch for changes",name:"watch",type:Boolean},{description:"Stub the package for JIT compilation",name:"jit",type:Boolean},{description:"Compile-time environment variables (eg. --env.NODE_ENV=production)",multiple:!0,name:"env",type:s(e=>{const[t,n]=e.split("=");return{key:t,value:n}},"type")},{defaultValue:!1,description:"Generate meta file (experimental)",name:"metafile",type:Boolean},{description:"Path to the license file",name:"license",type:String},{conflicts:"watch",description:"Visualize and analyze the bundle",name:"analyze",type:Boolean},{description:"CJS interop mode, can export default and named export, (experimental).",name:"cjsInterop",type:Boolean}]})},"createBuildCommand");var D=Object.defineProperty,g=r((i,e)=>D(i,"name",{value:e,configurable:!0}),"i");const E=g(i=>{i.addCommand({description:"Initialize packem configuration",execute:g(async({logger:e,options:t})=>{if(j("Welcome to packem setup"),u(c(t.dir,"packem.config.ts")))return e.info("Packem project already initialized, you can use `packem build` to build your project"),a(0);if(w(t.transformer))return C("Operation cancelled"),a(0);if(t.transformer===void 0){const p=c(t.dir,"package.json");if(!u(p))return e.error("No package.json found in the directory"),a(1);const l=B(p),y=[...Object.keys(l.dependencies??{}),...Object.keys(l.devDependencies??{})];if(t.transformer=await x({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"}]}),!y.includes(t.transformer)&&await P({message:"Do you want to install "+t.transformer+"?"})){const d=f();d.start("Installing "+t.transformer),await h(t.transformer==="swc"?"@swc/core":t.transformer,{cwd:t.dir,dev:!0,silent:!0}),d.stop("")}}const n=`import { defineConfig } from "@visulima/packem/config";
11
11
  import transformer from "@visulima/packem/transformer/${t.transformer}";
12
12
 
13
13
  export default defineConfig({
@@ -88,5 +88,5 @@ ${s.chunks.map(p=>{const a=t.buildEntries.find(u=>u.path===p)??{};return g.gray(
88
88
  `),r},"showSizeInformation"),fe=k(async(e,t,o,n,r,s,i,l,p)=>{const a=Cr(n,t),u=Vr(e,t,o,r,s,a,i,l);b.ensureDirSync(u.outDir);const c={buildEntries:[],dependencyGraphMap:new Map,hooks:tt.createHooks(),logger:e,mode:o,options:u,pkg:i,rootDir:t,tsconfig:l,usedImports:new Set,warnings:new Set};if(a.hooks&&c.hooks.addHooks(a.hooks),r.hooks&&c.hooks.addHooks(r.hooks),s.hooks&&c.hooks.addHooks(s.hooks),await c.hooks.callHook("build:prepare",c),c.options.emitESM===!1&&c.options.emitCJS===!1)throw new Error("Both emitESM and emitCJS are disabled. At least one of them must be enabled.");if(c.options.declaration&&l===void 0)throw new Error("Cannot build declaration files without a tsconfig.json");c.options.emitESM===void 0&&e.info("Emitting ESM bundles, is disabled."),c.options.emitCJS===void 0&&e.info("Emitting CJS bundles, is disabled."),c.options.declaration||e.info("Declaration files, are disabled."),await Xr(c,t),await c.hooks.callHook("build:before",c);let m="Building";if(o==="watch"?m="Watching":o==="jit"&&(m="Stubbing"),e.info(g.cyan(`${m} ${c.options.name}`)),e.debug(`${g.bold("Root dir:")} ${c.options.rootDir}
89
89
  ${g.bold("Entries:")}
90
90
  ${c.options.entries.map(h=>` ${ze(h)}`).join(`
91
- `)}`),c.options.clean)for(const h of new Set(c.options.entries.map($=>$.outDir).filter(Boolean).sort()))h!==c.options.rootDir&&(p.push(h),e.info(`Cleaning dist directory: \`./${f.relative(c.options.rootDir,h)}\``),await b.emptyDir(h));if(c.options.stub){await Ct(c),await c.hooks.callHook("build:done",c);return}if(o==="watch"){await lr(c),me(c,!1);return}await Promise.allSettled([nr(c),c.options.declaration&&ir(c)]),e.success(g.green(`Build succeeded for ${c.options.name}`));for await(const h of b.walk(c.options.outDir)){let $=c.buildEntries.find(y=>f.join(c.options.outDir,y.path)===h.path);if($||($={chunk:!0,path:h.path},c.buildEntries.push($)),!$.bytes){const y=await q.stat(f.resolve(c.options.outDir,h.path));$.bytes=y.size}}const v=Gr(e,c,i);qr(c),zr(i,c),await c.hooks.callHook("build:done",c),me(c,v)},"build"),Yr=k(async(e,t,o={})=>{const{configPath:n,debug:r,tsconfigPath:s,...i}=o,l=[new L.MessageFormatterProcessor,new L.ErrorProcessor];r&&l.push(new L.CallerProcessor);const p=Ze.createPail({logLevel:r?"debug":"informational",processors:l,scope:"packem"});p.wrapAll(),e=f.resolve(w.cwd(),e),p.debug("Root directory:",e);let a;if(s)await b.isAccessible(s)||(p.error("tsconfig.json not found at",s),w.exit(1)),a={config:te.readTsConfig(s),path:s},p.info("Using tsconfig settings found at",s);else try{a=await te.findTSConfig(e),p.info("Using tsconfig settings found at",a.path.replace(e,"."))}catch{p.info("No tsconfig.json or jsconfig.json found.")}try{const u=f.join(e,"package.json"),c=Qe.parsePackageJson(u);p.info("Using package.json found at",u.replace(e,"."));const m=Ve(n??"./packem.config",e,[]),v=(Array.isArray(m)?m:[m]).filter(Boolean),h=Date.now(),$=k(()=>Math.floor(Date.now()-h)+"ms","getDuration");let y=c.packem?.preset??o.preset??"auto";if(v.length===0)await fe(p,e,t,y,i,{},c,a,[]);else{const E=[];await Promise.allSettled(v.map(async _=>{_.preset&&(y=_.preset),await fe(p,e,t,y,i,_,c,a,E)}))}p.raw(`
91
+ `)}`),c.options.clean)for(const h of new Set(c.options.entries.map($=>$.outDir).filter(Boolean).sort()))h!==c.options.rootDir&&(p.push(h),e.info(`Cleaning dist directory: \`./${f.relative(c.options.rootDir,h)}\``),await b.emptyDir(h));if(c.options.stub){await Ct(c),await c.hooks.callHook("build:done",c);return}if(o==="watch"){await lr(c),me(c,!1);return}await Promise.allSettled([nr(c),c.options.declaration&&ir(c)]),e.success(g.green(`Build succeeded for ${c.options.name}`));for await(const h of b.walk(c.options.outDir)){let $=c.buildEntries.find(y=>f.join(c.options.outDir,y.path)===h.path);if($||($={chunk:!0,path:h.path},c.buildEntries.push($)),!$.bytes){const y=await q.stat(f.resolve(c.options.outDir,h.path));$.bytes=y.size}}const v=Gr(e,c,i);qr(c),zr(i,c),await c.hooks.callHook("build:done",c),me(c,v)},"build"),Yr=k(async(e,t,o={})=>{const{configPath:n,debug:r,tsconfigPath:s,...i}=o,l=[new L.MessageFormatterProcessor,new L.ErrorProcessor];r&&l.push(new L.CallerProcessor);const p=Ze.createPail({logLevel:r?"debug":"informational",processors:l,scope:"packem"});p.wrapAll(),e=f.resolve(w.cwd(),e),p.debug("Root directory:",e);let a;if(s)await b.isAccessible(s)||(p.error("tsconfig.json not found at",s),w.exit(1)),a={config:te.readTsConfig(s),path:s},p.info("Using tsconfig settings found at",s);else try{a=await te.findTSConfig(e),p.debug("Using tsconfig settings found at",a.path)}catch{p.info("No tsconfig.json or jsconfig.json found.")}try{const u=f.join(e,"package.json"),c=Qe.parsePackageJson(u);p.debug("Using package.json found at",u);const m=Ve(n??"./packem.config",e,[]),v=(Array.isArray(m)?m:[m]).filter(Boolean),h=Date.now(),$=k(()=>Math.floor(Date.now()-h)+"ms","getDuration");let y=c.packem?.preset??o.preset??"auto";if(v.length===0)await fe(p,e,t,y,i,{},c,a,[]);else{const E=[];await Promise.allSettled(v.map(async _=>{_.preset&&(y=_.preset),await fe(p,e,t,y,i,_,c,a,E)}))}p.raw(`
92
92
  ⚡️ Build run in ${$()}`),p.restoreAll(),w.exit(0)}catch(u){p.error("An error occurred while building",u),w.exit(1)}},"createBundler");module.exports=Yr;
@@ -96,5 +96,5 @@ ${s.chunks.map(c=>{const a=t.buildEntries.find(u=>u.path===c)??{};return N("
96
96
  `),r},"showSizeInformation"),$e=j(async(e,t,o,n,r,s,i,l,c)=>{const a=nn(n,t),u=hn(e,t,o,r,s,a,i,l);ht(u.outDir);const p={buildEntries:[],dependencyGraphMap:new Map,hooks:_t(),logger:e,mode:o,options:u,pkg:i,rootDir:t,tsconfig:l,usedImports:new Set,warnings:new Set};if(a.hooks&&p.hooks.addHooks(a.hooks),r.hooks&&p.hooks.addHooks(r.hooks),s.hooks&&p.hooks.addHooks(s.hooks),await p.hooks.callHook("build:prepare",p),p.options.emitESM===!1&&p.options.emitCJS===!1)throw new Error("Both emitESM and emitCJS are disabled. At least one of them must be enabled.");if(p.options.declaration&&l===void 0)throw new Error("Cannot build declaration files without a tsconfig.json");p.options.emitESM===void 0&&e.info("Emitting ESM bundles, is disabled."),p.options.emitCJS===void 0&&e.info("Emitting CJS bundles, is disabled."),p.options.declaration||e.info("Declaration files, are disabled."),await yn(p,t),await p.hooks.callHook("build:before",p);let d="Building";if(o==="watch"?d="Watching":o==="jit"&&(d="Stubbing"),e.info(v(`${d} ${p.options.name}`)),e.debug(`${x("Root dir:")} ${p.options.rootDir}
97
97
  ${x("Entries:")}
98
98
  ${p.options.entries.map(g=>` ${Ze(g)}`).join(`
99
- `)}`),p.options.clean)for(const g of new Set(p.options.entries.map(b=>b.outDir).filter(Boolean).sort()))g!==p.options.rootDir&&(c.push(g),e.info(`Cleaning dist directory: \`./${S(p.options.rootDir,g)}\``),await yt(g));if(p.options.stub){await no(p),await p.hooks.callHook("build:done",p);return}if(o==="watch"){await Nr(p),be(p,!1);return}await Promise.allSettled([Or(p),p.options.declaration&&Dr(p)]),e.success(ct(`Build succeeded for ${p.options.name}`));for await(const g of vt(p.options.outDir)){let b=p.buildEntries.find(h=>P(p.options.outDir,h.path)===g.path);if(b||(b={chunk:!0,path:g.path},p.buildEntries.push(b)),!b.bytes){const h=await je(f(p.options.outDir,g.path));b.bytes=h.size}}const y=vn(e,p,i);ln(p),dn(i,p),await p.hooks.callHook("build:done",p),be(p,y)},"build"),rs=j(async(e,t,o={})=>{const{configPath:n,debug:r,tsconfigPath:s,...i}=o,l=[new Et,new Ot];r&&l.push(new St);const c=xt({logLevel:r?"debug":"informational",processors:l,scope:"packem"});c.wrapAll(),e=f(lt(),e),c.debug("Root directory:",e);let a;if(s)await bt(s)||(c.error("tsconfig.json not found at",s),C(1)),a={config:jt(s),path:s},c.info("Using tsconfig settings found at",s);else try{a=await wt(e),c.info("Using tsconfig settings found at",a.path.replace(e,"."))}catch{c.info("No tsconfig.json or jsconfig.json found.")}try{const u=P(e,"package.json"),p=kt(u);c.info("Using package.json found at",u.replace(e,"."));const d=ot(n??"./packem.config",e,[]),y=(Array.isArray(d)?d:[d]).filter(Boolean),g=Date.now(),b=j(()=>Math.floor(Date.now()-g)+"ms","getDuration");let h=p.packem?.preset??o.preset??"auto";if(y.length===0)await $e(c,e,t,h,i,{},p,a,[]);else{const w=[];await Promise.allSettled(y.map(async k=>{k.preset&&(h=k.preset),await $e(c,e,t,h,i,k,p,a,w)}))}c.raw(`
99
+ `)}`),p.options.clean)for(const g of new Set(p.options.entries.map(b=>b.outDir).filter(Boolean).sort()))g!==p.options.rootDir&&(c.push(g),e.info(`Cleaning dist directory: \`./${S(p.options.rootDir,g)}\``),await yt(g));if(p.options.stub){await no(p),await p.hooks.callHook("build:done",p);return}if(o==="watch"){await Nr(p),be(p,!1);return}await Promise.allSettled([Or(p),p.options.declaration&&Dr(p)]),e.success(ct(`Build succeeded for ${p.options.name}`));for await(const g of vt(p.options.outDir)){let b=p.buildEntries.find(h=>P(p.options.outDir,h.path)===g.path);if(b||(b={chunk:!0,path:g.path},p.buildEntries.push(b)),!b.bytes){const h=await je(f(p.options.outDir,g.path));b.bytes=h.size}}const y=vn(e,p,i);ln(p),dn(i,p),await p.hooks.callHook("build:done",p),be(p,y)},"build"),rs=j(async(e,t,o={})=>{const{configPath:n,debug:r,tsconfigPath:s,...i}=o,l=[new Et,new Ot];r&&l.push(new St);const c=xt({logLevel:r?"debug":"informational",processors:l,scope:"packem"});c.wrapAll(),e=f(lt(),e),c.debug("Root directory:",e);let a;if(s)await bt(s)||(c.error("tsconfig.json not found at",s),C(1)),a={config:jt(s),path:s},c.info("Using tsconfig settings found at",s);else try{a=await wt(e),c.debug("Using tsconfig settings found at",a.path)}catch{c.info("No tsconfig.json or jsconfig.json found.")}try{const u=P(e,"package.json"),p=kt(u);c.debug("Using package.json found at",u);const d=ot(n??"./packem.config",e,[]),y=(Array.isArray(d)?d:[d]).filter(Boolean),g=Date.now(),b=j(()=>Math.floor(Date.now()-g)+"ms","getDuration");let h=p.packem?.preset??o.preset??"auto";if(y.length===0)await $e(c,e,t,h,i,{},p,a,[]);else{const w=[];await Promise.allSettled(y.map(async k=>{k.preset&&(h=k.preset),await $e(c,e,t,h,i,k,p,a,w)}))}c.raw(`
100
100
  ⚡️ Build run in ${b()}`),c.restoreAll(),C(0)}catch(u){c.error("An error occurred while building",u),C(1)}},"createBundler");export{rs as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/packem",
3
- "version": "1.0.0-alpha.16",
3
+ "version": "1.0.0-alpha.17",
4
4
  "description": "A fast and modern bundler for Node.js and TypeScript.",
5
5
  "keywords": [
6
6
  "anolilab",