@visulima/packem 1.0.0 → 1.0.2

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,15 @@
1
+ ## @visulima/packem [1.0.2](https://github.com/visulima/packem/compare/@visulima/packem@1.0.1...@visulima/packem@1.0.2) (2024-09-24)
2
+
3
+ ### Bug Fixes
4
+
5
+ * **deps:** update patch updates ([a6a649d](https://github.com/visulima/packem/commit/a6a649d1457fd39a03c5d4f6c40bf34155c176ae))
6
+
7
+ ## @visulima/packem [1.0.1](https://github.com/visulima/packem/compare/@visulima/packem@1.0.0...@visulima/packem@1.0.1) (2024-09-23)
8
+
9
+ ### Bug Fixes
10
+
11
+ * hardcoded cache dir to "@visulima/packem" ([b256aa7](https://github.com/visulima/packem/commit/b256aa7e2d22f07f011d5584d16c668bee782e55))
12
+
1
13
  ## @visulima/packem 1.0.0 (2024-09-23)
2
14
 
3
15
  ### Features
package/dist/cli.mjs CHANGED
@@ -5,7 +5,7 @@ import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
5
5
  const __filename = __cjs_url__.fileURLToPath(import.meta.url);
6
6
  const __dirname = __cjs_path__.dirname(__filename);
7
7
  const require = __cjs_mod__.createRequire(import.meta.url);
8
- const Qo="@visulima/packem",Zo="1.0.0-alpha.133",_e=[".mjs",".js",".json",".node",".cjs",".ts",".cts",".mts",".tsx",".jsx"],C="production",Q="development",kt=new Set(["react-server","react-native","edge-light"]),pe=new Set([Q,C,...kt]),V=/node_modules/,J=/(?:\.d\.[mc]?tsx?|\.\w+)$/,er="packem_chunks",tr="packem_shared",H=/\.(?:m|c)?(?:j|t)sx?$/;var or=Object.defineProperty,rr=m((e,t)=>or(e,"name",{value:t,configurable:!0}),"a$h");const De=rr((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var nr=Object.defineProperty,ir=m((e,t)=>nr(e,"name",{value:t,configurable:!0}),"a$g");const X=ir(e=>e==null?[]:Array.isArray(e)?e:[e],"arrayify");var sr=Object.defineProperty,ar=m((e,t)=>sr(e,"name",{value:t,configurable:!0}),"a$f");const xt=ar((e="")=>{const t=e.split("/");return t[0].startsWith("@")?t[0]+"/"+t[1]:t[0]},"getPackageName");var lr=Object.defineProperty,Et=m((e,t)=>lr(e,"name",{value:t,configurable:!0}),"s$g");const cr=Et((e,t,o)=>{const r=o??new Map;return(...n)=>{const i=t?typeof t=="function"?t(...n):t:JSON.stringify({args:n}),s=r.get(i);if(s!==void 0)return s;const a=e(...n);return r.set(i,a),a}},"memoize"),pr=Et(e=>{const t=new Map;return o=>cr(e,o,t)},"memoizeByKey");var ur=Object.defineProperty,Z=m((e,t)=>ur(e,"name",{value:t,configurable:!0}),"r$f");const dr=Z(function*(e){switch(e.declaration?.type){case"ClassDeclaration":case"FunctionDeclaration":{const{id:t}=e.declaration;ce(t,"Expected class/function to have a name"),yield t.name;break}case"VariableDeclaration":{for(const t of e.declaration.declarations)for(const o of Io(t.id))yield o;break}}},"exportName"),mr=Z(function*(e){if(e.declaration)for(const t of dr(e))yield{exportedName:t,from:"self",type:"named"};else if(e.source)yield{bindings:e.specifiers.map(t=>({exportedName:t.exported.name,importedName:t.local.name})),from:"other",source:e.source.value,type:"named"};else for(const t of e.specifiers)yield{exportedName:t.exported.name,from:"self",type:"named"}},"parseExportNamed"),fr=Z(function*(e){e.exported?yield{exportedName:e.exported.name,from:"self",type:"named"}:yield{from:"other",source:e.source.value,type:"barrel"}},"parseExportAll"),gr=Z(function*(){yield{exportedName:"default",from:"self",type:"named"}},"parseExportDefault"),yr=Z(function*(e,t){ce(t.code!=null,`Module ${t.id} doesn't have associated code`);const o=e.parse(t.code);for(const r of o.body)switch(r.type){case"ExportAllDeclaration":{yield*fr(r);break}case"ExportDefaultDeclaration":{yield*gr();break}case"ExportNamedDeclaration":{yield*mr(r);break}}},"parseExports");var hr=Object.defineProperty,ee=m((e,t)=>hr(e,"name",{value:t,configurable:!0}),"n$9");const Dt=ee(async function(e,t,o){const r=await e.resolve(t,o.id);if(ce(r,`Rollup can't resolve ${t} from ${o.id}`),r.external)return null;const n=await e.load(r);return ce(n,`Rollup doesn't have a module for id ${r.id}`),n},"getImportedModule"),vr=ee(async function*(e,t,o){const r=await Dt(e,t.source,o);r&&(yield*Te(e,r))},"gatherBarrelReExports"),br=ee(async function*(e,t,o){const r=await Dt(e,t.source,o);if(!r)return;const n=new Map(t.bindings.map(i=>[i.importedName,i]));for await(const i of Te(e,r)){const s=n.get(i.exportedName);s&&(yield{...i,exportedName:s.exportedName})}},"gatherNamedReExports"),wr=ee(async function*(e,t){yield{exportedName:t.exportedName,id:e.id,sourceName:t.exportedName}},"gatherNamedSelfExports"),Te=ee(async function*(e,t){for(const o of yr(e,t))o.from==="self"?yield*wr(t,o):o.type==="barrel"?yield*vr(e,o,t):yield*br(e,o,t)},"gatherExports");var $r=Object.defineProperty,jr=m((e,t)=>$r(e,"name",{value:t,configurable:!0}),"r$e");const kr=jr(()=>({moduleParsed:{async handler(e){if(e.isEntry)for await(const t of Te(this,e))t.id!==e.id&&this.emitFile({id:t.id,name:t.exportedName,preserveSignature:"exports-only",type:"chunk"})},order:"post"},name:"packem:chunk-splitter"}),"chunkSplitter");var xr=Object.defineProperty,Er=m((e,t)=>xr(e,"name",{value:t,configurable:!0}),"r$d");const Dr=Er((e,t)=>{const o=e,r=[];let n;for(;(n=o.exec(t))!==null;)n.index===o.lastIndex&&o.lastIndex++,n.forEach(i=>{r.push(i)});return r.filter(Boolean)},"getRegexMatches");var Sr=Object.defineProperty,Or=m((e,t)=>Sr(e,"name",{value:t,configurable:!0}),"a$e");const St=Or(e=>{const t=Dr(/export\s(\{\s(.*)\s\}|default\s.*);/g,e);if(t.length===0)return null;const o=t.at(-1).split(", ");let r="";for(const n of o)if(!n.includes("type")&&(n.includes("default ")&&(r=n.split("default ")[1]),n.includes("as"))){const[i,s]=n.split(" as ");s==="default"&&(r=i)}if(r!==""){const n=new F(e);return n.replace(new RegExp(`(,s)?${r} as default(,)?`),""),n.replace(new RegExp(`export default ${r};
8
+ const Qo="@visulima/packem",Zo="1.0.1",_e=[".mjs",".js",".json",".node",".cjs",".ts",".cts",".mts",".tsx",".jsx"],C="production",Q="development",kt=new Set(["react-server","react-native","edge-light"]),pe=new Set([Q,C,...kt]),V=/node_modules/,J=/(?:\.d\.[mc]?tsx?|\.\w+)$/,er="packem_chunks",tr="packem_shared",H=/\.(?:m|c)?(?:j|t)sx?$/;var or=Object.defineProperty,rr=m((e,t)=>or(e,"name",{value:t,configurable:!0}),"a$h");const De=rr((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var nr=Object.defineProperty,ir=m((e,t)=>nr(e,"name",{value:t,configurable:!0}),"a$g");const X=ir(e=>e==null?[]:Array.isArray(e)?e:[e],"arrayify");var sr=Object.defineProperty,ar=m((e,t)=>sr(e,"name",{value:t,configurable:!0}),"a$f");const xt=ar((e="")=>{const t=e.split("/");return t[0].startsWith("@")?t[0]+"/"+t[1]:t[0]},"getPackageName");var lr=Object.defineProperty,Et=m((e,t)=>lr(e,"name",{value:t,configurable:!0}),"s$g");const cr=Et((e,t,o)=>{const r=o??new Map;return(...n)=>{const i=t?typeof t=="function"?t(...n):t:JSON.stringify({args:n}),s=r.get(i);if(s!==void 0)return s;const a=e(...n);return r.set(i,a),a}},"memoize"),pr=Et(e=>{const t=new Map;return o=>cr(e,o,t)},"memoizeByKey");var ur=Object.defineProperty,Z=m((e,t)=>ur(e,"name",{value:t,configurable:!0}),"r$f");const dr=Z(function*(e){switch(e.declaration?.type){case"ClassDeclaration":case"FunctionDeclaration":{const{id:t}=e.declaration;ce(t,"Expected class/function to have a name"),yield t.name;break}case"VariableDeclaration":{for(const t of e.declaration.declarations)for(const o of Io(t.id))yield o;break}}},"exportName"),mr=Z(function*(e){if(e.declaration)for(const t of dr(e))yield{exportedName:t,from:"self",type:"named"};else if(e.source)yield{bindings:e.specifiers.map(t=>({exportedName:t.exported.name,importedName:t.local.name})),from:"other",source:e.source.value,type:"named"};else for(const t of e.specifiers)yield{exportedName:t.exported.name,from:"self",type:"named"}},"parseExportNamed"),fr=Z(function*(e){e.exported?yield{exportedName:e.exported.name,from:"self",type:"named"}:yield{from:"other",source:e.source.value,type:"barrel"}},"parseExportAll"),gr=Z(function*(){yield{exportedName:"default",from:"self",type:"named"}},"parseExportDefault"),yr=Z(function*(e,t){ce(t.code!=null,`Module ${t.id} doesn't have associated code`);const o=e.parse(t.code);for(const r of o.body)switch(r.type){case"ExportAllDeclaration":{yield*fr(r);break}case"ExportDefaultDeclaration":{yield*gr();break}case"ExportNamedDeclaration":{yield*mr(r);break}}},"parseExports");var hr=Object.defineProperty,ee=m((e,t)=>hr(e,"name",{value:t,configurable:!0}),"n$9");const Dt=ee(async function(e,t,o){const r=await e.resolve(t,o.id);if(ce(r,`Rollup can't resolve ${t} from ${o.id}`),r.external)return null;const n=await e.load(r);return ce(n,`Rollup doesn't have a module for id ${r.id}`),n},"getImportedModule"),vr=ee(async function*(e,t,o){const r=await Dt(e,t.source,o);r&&(yield*Te(e,r))},"gatherBarrelReExports"),br=ee(async function*(e,t,o){const r=await Dt(e,t.source,o);if(!r)return;const n=new Map(t.bindings.map(i=>[i.importedName,i]));for await(const i of Te(e,r)){const s=n.get(i.exportedName);s&&(yield{...i,exportedName:s.exportedName})}},"gatherNamedReExports"),wr=ee(async function*(e,t){yield{exportedName:t.exportedName,id:e.id,sourceName:t.exportedName}},"gatherNamedSelfExports"),Te=ee(async function*(e,t){for(const o of yr(e,t))o.from==="self"?yield*wr(t,o):o.type==="barrel"?yield*vr(e,o,t):yield*br(e,o,t)},"gatherExports");var $r=Object.defineProperty,jr=m((e,t)=>$r(e,"name",{value:t,configurable:!0}),"r$e");const kr=jr(()=>({moduleParsed:{async handler(e){if(e.isEntry)for await(const t of Te(this,e))t.id!==e.id&&this.emitFile({id:t.id,name:t.exportedName,preserveSignature:"exports-only",type:"chunk"})},order:"post"},name:"packem:chunk-splitter"}),"chunkSplitter");var xr=Object.defineProperty,Er=m((e,t)=>xr(e,"name",{value:t,configurable:!0}),"r$d");const Dr=Er((e,t)=>{const o=e,r=[];let n;for(;(n=o.exec(t))!==null;)n.index===o.lastIndex&&o.lastIndex++,n.forEach(i=>{r.push(i)});return r.filter(Boolean)},"getRegexMatches");var Sr=Object.defineProperty,Or=m((e,t)=>Sr(e,"name",{value:t,configurable:!0}),"a$e");const St=Or(e=>{const t=Dr(/export\s(\{\s(.*)\s\}|default\s.*);/g,e);if(t.length===0)return null;const o=t.at(-1).split(", ");let r="";for(const n of o)if(!n.includes("type")&&(n.includes("default ")&&(r=n.split("default ")[1]),n.includes("as"))){const[i,s]=n.split(" as ");s==="default"&&(r=i)}if(r!==""){const n=new F(e);return n.replace(new RegExp(`(,s)?${r} as default(,)?`),""),n.replace(new RegExp(`export default ${r};
9
9
  ?`),""),n.append(`
10
10
 
11
11
  export = `+r+";"),{code:n.toString().replace(/export\s\{\s\s\};/,""),map:n.generateMap({hires:!0})}}return null},"patchCjsDefaultExport");var Nr=Object.defineProperty,Ue=m((e,t)=>Nr(e,"name",{value:t,configurable:!0}),"i$b");const Ot=Ue(({addDefaultProperty:e=!1,logger:t,type:o})=>({name:"packem:cjs-interop",renderChunk:Ue(async(r,n,i)=>{if(n.type!=="chunk"||!n.isEntry)return null;if(i.format==="cjs"&&i.exports==="auto"){const s=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(r);if(s===null||s.length<3)return null;const a=new F(r);a.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),a.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&a.append(`
@@ -105,7 +105,7 @@ The published ${g} artifact additionally contains code with the following licens
105
105
  Because none of the third-party transpiler, packem uses under the hood is type-aware, some techniques or features often used in TypeScript are not properly checked and can cause mis-compilation or even runtime errors.
106
106
  To mitigate this, you should set the isolatedModules option to true in tsconfig and let your IDE warn you when such incompatible constructs are used.`),await us(u),u},"createContext"),Is=P(async e=>{const t=[];if(e.options.clean)for(const o of new Set(e.options.entries.map(r=>r.outDir).filter(Boolean).sort()))o===e.options.rootDir||o===e.options.sourceDir||e.options.rootDir.startsWith(o.endsWith("/")?o:`${o}/`)||t.some(r=>o.startsWith(r))||(t.push(o),e.logger.info(`Cleaning dist directory: \`./${O(e.options.rootDir,o)}\``),await bo(o))},"cleanDistributionDirectories"),Ms=P(async(e,t,o)=>{if(e&&S(b(e,"keystore1.json"))){const r=Pe(b(e,"keystore.json")),n=Ne(e,{withFileTypes:!0}).filter(s=>s.isDirectory());let i=o;for await(const s of n)r[s.name]||(await po(b(e,s.name),{force:!0,recursive:!0}),i&&t.raw(`
107
107
 
108
- `),t.info({message:"Removing "+s.name+" file cache, the cache key is not used anymore.",prefix:"file-cache"}),i=!1)}},"removeOldCacheFolders"),As=P(e=>{switch(e){case"jit":return"Stubbing";case"watch":return"Watching";case"tsdoc":return"Generating TSDoc";default:return"Building"}},"getMode"),Rs=P(async(e,t,o,r,n={})=>{const{configPath:i,debug:s,tsconfigPath:a,...l}=n;r.wrapAll(),e=$(ao(),e),r.debug("Root directory:",e);const{packageJson:c,packageJsonPath:d}=eo(e);r.debug("Using package.json found at",d);let p;if(a){const y=b(e,a);if(!await wo(y))throw new Error("tsconfig.json not found at "+y);p={config:jo(y),path:y},r.info("Using tsconfig settings at",y)}else if(c.dependencies?.typescript||c.devDependencies?.typescript)try{p=await ko(e),r.debug("Using tsconfig settings found at",p.path)}catch{r.info("No tsconfig.json or jsconfig.json found.")}const u=go(c.name,{cwd:e});let g=!1;try{let y=i??"";if(!y){const q=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"];for(const L of q)if(S(b(e,L))){y="./"+L;break}}const f=gt(e,{debug:s,interopDefault:!0});if(!/\.(?:js|mjs|cjs|ts|cts|mts)$/.test(y))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");let h=await f.import(y,{try:!0})||{};typeof h=="function"&&(h=await h(o,t)),r.debug("Using packem config found at",b(e,y));const w=M(JSON.stringify({version:c.version,...c.dependencies,...c.devDependencies,...c.peerDependencies,...c.peerDependenciesMeta,browser:c.browser,eNode:c.engines?.node,exports:c.exports,main:c.main,module:c.module,type:c.type,types:c.types}))+M(JSON.stringify(h));u&&it(w,u,r);const x=new os(e,u,w,r),v=await Ts(r,e,t,o,s??!1,l,h,c,p,f);x.isEnabled=v.options.fileCache,v.logger.info(k(As(t)+" "+v.options.name)),v.logger.debug({context:v.options.entries,message:`${N("Root dir:")} ${v.options.rootDir}
108
+ `),t.info({message:"Removing "+s.name+" file cache, the cache key is not used anymore.",prefix:"file-cache"}),i=!1)}},"removeOldCacheFolders"),As=P(e=>{switch(e){case"jit":return"Stubbing";case"watch":return"Watching";case"tsdoc":return"Generating TSDoc";default:return"Building"}},"getMode"),Rs=P(async(e,t,o,r,n={})=>{const{configPath:i,debug:s,tsconfigPath:a,...l}=n;r.wrapAll(),e=$(ao(),e),r.debug("Root directory:",e);const{packageJson:c,packageJsonPath:d}=eo(e);r.debug("Using package.json found at",d);let p;if(a){const y=b(e,a);if(!await wo(y))throw new Error("tsconfig.json not found at "+y);p={config:jo(y),path:y},r.info("Using tsconfig settings at",y)}else if(c.dependencies?.typescript||c.devDependencies?.typescript)try{p=await ko(e),r.debug("Using tsconfig settings found at",p.path)}catch{r.info("No tsconfig.json or jsconfig.json found.")}const u=go("@visulima/packem",{cwd:e});let g=!1;try{let y=i??"";if(!y){const q=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"];for(const L of q)if(S(b(e,L))){y="./"+L;break}}const f=gt(e,{debug:s,interopDefault:!0});if(!/\.(?:js|mjs|cjs|ts|cts|mts)$/.test(y))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");let h=await f.import(y,{try:!0})||{};typeof h=="function"&&(h=await h(o,t)),r.debug("Using packem config found at",b(e,y));const w=M(JSON.stringify({version:c.version,...c.dependencies,...c.devDependencies,...c.peerDependencies,...c.peerDependenciesMeta,browser:c.browser,eNode:c.engines?.node,exports:c.exports,main:c.main,module:c.module,type:c.type,types:c.types}))+M(JSON.stringify(h));u&&it(w,u,r);const x=new os(e,u,w,r),v=await Ts(r,e,t,o,s??!1,l,h,c,p,f);x.isEnabled=v.options.fileCache,v.logger.info(k(As(t)+" "+v.options.name)),v.logger.debug({context:v.options.entries,message:`${N("Root dir:")} ${v.options.rootDir}
109
109
  ${N("Entries:")}}`}),await Is(v);const _=Date.now(),te=P(()=>$o(Math.floor(Date.now()-_)),"getDuration");if(t==="watch"){if(v.options.rollup.watch===!1)throw new Error("Rollup watch is disabled. You should check your packem.config file.");await Hi(v,x),st(v,!1);return}if(t==="jit"?(await Vi(v),await v.hooks.callHook("build:done",v)):(g=await ji(v,x),await v.hooks.callHook("validate:before",v),Es(v),await v.hooks.callHook("validate:done",v),st(v,g)),v.options.typedoc&&v.options.typedoc.format!==void 0){let q="unknown";c.dependencies?.typedoc?q=c.dependencies.typedoc:c.devDependencies?.typedoc&&(q=c.devDependencies.typedoc),u&&it("typedoc",u,r,!0),g&&v.logger.raw(`
110
110
  `),v.logger.info({message:"Using "+k("typedoc")+" "+q+" to generate reference documentation",prefix:"typedoc"}),await v.hooks.callHook("typedoc:before",v);let L=b(v.options.rootDir,"api-docs");v.options.typedoc.format==="inline"&&u&&(L=b(u,"typedoc")),v.options.typedoc.output&&(L=v.options.typedoc.output),await Yi(v.options.typedoc,v.options.entries,L,v.logger),await v.hooks.callHook("typedoc:done",v)}r.raw(`
111
111
  ⚡️ Build run in `+te()),r.restoreAll()}catch(y){throw r.raw(`
@@ -98,7 +98,7 @@ The published ${y} artifact additionally contains code with the following licens
98
98
  Because none of the third-party transpiler, packem uses under the hood is type-aware, some techniques or features often used in TypeScript are not properly checked and can cause mis-compilation or even runtime errors.
99
99
  To mitigate this, you should set the isolatedModules option to true in tsconfig and let your IDE warn you when such incompatible constructs are used.`),await $i(u),u},"createContext"),Vi=N(async e=>{const t=[];if(e.options.clean)for(const o of new Set(e.options.entries.map(n=>n.outDir).filter(Boolean).sort()))o===e.options.rootDir||o===e.options.sourceDir||e.options.rootDir.startsWith(o.endsWith("/")?o:`${o}/`)||t.some(n=>o.startsWith(n))||(t.push(o),e.logger.info(`Cleaning dist directory: \`./${f.relative(e.options.rootDir,o)}\``),await w.emptyDir(o))},"cleanDistributionDirectories"),zi=N(async(e,t,o)=>{if(e&&w.isAccessibleSync(f.join(e,"keystore1.json"))){const n=w.readJsonSync(f.join(e,"keystore.json")),r=V.readdirSync(e,{withFileTypes:!0}).filter(s=>s.isDirectory());let i=o;for await(const s of r)n[s.name]||(await ie.rm(f.join(e,s.name),{force:!0,recursive:!0}),i&&t.raw(`
100
100
 
101
- `),t.info({message:"Removing "+s.name+" file cache, the cache key is not used anymore.",prefix:"file-cache"}),i=!1)}},"removeOldCacheFolders"),Gi=N(e=>{switch(e){case"jit":return"Stubbing";case"watch":return"Watching";case"tsdoc":return"Generating TSDoc";default:return"Building"}},"getMode"),Ki=N(async(e,t,o,n,r={})=>{const{configPath:i,debug:s,tsconfigPath:a,...l}=r;n.wrapAll(),e=f.resolve(he.cwd(),e),n.debug("Root directory:",e);const{packageJson:c,packageJsonPath:d}=xt(e);n.debug("Using package.json found at",d);let p;if(a){const h=f.join(e,a);if(!await w.isAccessible(h))throw new Error("tsconfig.json not found at "+h);p={config:$e.readTsConfig(h),path:h},n.info("Using tsconfig settings at",h)}else if(c.dependencies?.typescript||c.devDependencies?.typescript)try{p=await $e.findTsConfig(e),n.debug("Using tsconfig settings found at",p.path)}catch{n.info("No tsconfig.json or jsconfig.json found.")}const u=Tt.findCacheDirSync(c.name,{cwd:e});let y=!1;try{let h=i??"";if(!h){const L=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"];for(const F of L)if(w.isAccessibleSync(f.join(e,F))){h="./"+F;break}}const g=Ue.createJiti(e,{debug:s,interopDefault:!0});if(!/\.(?:js|mjs|cjs|ts|cts|mts)$/.test(h))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");let v=await g.import(h,{try:!0})||{};typeof v=="function"&&(v=await v(o,t)),n.debug("Using packem config found at",f.join(e,h));const k=A(JSON.stringify({version:c.version,...c.dependencies,...c.devDependencies,...c.peerDependencies,...c.peerDependenciesMeta,browser:c.browser,eNode:c.engines?.node,exports:c.exports,main:c.main,module:c.module,type:c.type,types:c.types}))+A(JSON.stringify(v));u&&Je(k,u,n);const x=new fi(e,u,k,n),b=await Ui(n,e,t,o,s??!1,l,v,c,p,g);x.isEnabled=b.options.fileCache,b.logger.info(j.cyan(Gi(t)+" "+b.options.name)),b.logger.debug({context:b.options.entries,message:`${j.bold("Root dir:")} ${b.options.rootDir}
101
+ `),t.info({message:"Removing "+s.name+" file cache, the cache key is not used anymore.",prefix:"file-cache"}),i=!1)}},"removeOldCacheFolders"),Gi=N(e=>{switch(e){case"jit":return"Stubbing";case"watch":return"Watching";case"tsdoc":return"Generating TSDoc";default:return"Building"}},"getMode"),Ki=N(async(e,t,o,n,r={})=>{const{configPath:i,debug:s,tsconfigPath:a,...l}=r;n.wrapAll(),e=f.resolve(he.cwd(),e),n.debug("Root directory:",e);const{packageJson:c,packageJsonPath:d}=xt(e);n.debug("Using package.json found at",d);let p;if(a){const h=f.join(e,a);if(!await w.isAccessible(h))throw new Error("tsconfig.json not found at "+h);p={config:$e.readTsConfig(h),path:h},n.info("Using tsconfig settings at",h)}else if(c.dependencies?.typescript||c.devDependencies?.typescript)try{p=await $e.findTsConfig(e),n.debug("Using tsconfig settings found at",p.path)}catch{n.info("No tsconfig.json or jsconfig.json found.")}const u=Tt.findCacheDirSync("@visulima/packem",{cwd:e});let y=!1;try{let h=i??"";if(!h){const L=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"];for(const F of L)if(w.isAccessibleSync(f.join(e,F))){h="./"+F;break}}const g=Ue.createJiti(e,{debug:s,interopDefault:!0});if(!/\.(?:js|mjs|cjs|ts|cts|mts)$/.test(h))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");let v=await g.import(h,{try:!0})||{};typeof v=="function"&&(v=await v(o,t)),n.debug("Using packem config found at",f.join(e,h));const k=A(JSON.stringify({version:c.version,...c.dependencies,...c.devDependencies,...c.peerDependencies,...c.peerDependenciesMeta,browser:c.browser,eNode:c.engines?.node,exports:c.exports,main:c.main,module:c.module,type:c.type,types:c.types}))+A(JSON.stringify(v));u&&Je(k,u,n);const x=new fi(e,u,k,n),b=await Ui(n,e,t,o,s??!1,l,v,c,p,g);x.isEnabled=b.options.fileCache,b.logger.info(j.cyan(Gi(t)+" "+b.options.name)),b.logger.debug({context:b.options.entries,message:`${j.bold("Root dir:")} ${b.options.rootDir}
102
102
  ${j.bold("Entries:")}}`}),await Vi(b);const R=Date.now(),K=N(()=>P.duration(Math.floor(Date.now()-R)),"getDuration");if(t==="watch"){if(b.options.rollup.watch===!1)throw new Error("Rollup watch is disabled. You should check your packem.config file.");await ii(b,x),Le(b,!1);return}if(t==="jit"?(await ei(b),await b.hooks.callHook("build:done",b)):(y=await Rr(b,x),await b.hooks.callHook("validate:before",b),Ii(b),await b.hooks.callHook("validate:done",b),Le(b,y)),b.options.typedoc&&b.options.typedoc.format!==void 0){let L="unknown";c.dependencies?.typedoc?L=c.dependencies.typedoc:c.devDependencies?.typedoc&&(L=c.devDependencies.typedoc),u&&Je("typedoc",u,n,!0),y&&b.logger.raw(`
103
103
  `),b.logger.info({message:"Using "+j.cyan("typedoc")+" "+L+" to generate reference documentation",prefix:"typedoc"}),await b.hooks.callHook("typedoc:before",b);let F=f.join(b.options.rootDir,"api-docs");b.options.typedoc.format==="inline"&&u&&(F=f.join(u,"typedoc")),b.options.typedoc.output&&(F=b.options.typedoc.output),await li(b.options.typedoc,b.options.entries,F,b.logger),await b.hooks.callHook("typedoc:done",b)}n.raw(`
104
104
  ⚡️ Build run in `+K()),n.restoreAll()}catch(h){throw n.raw(`
@@ -104,7 +104,7 @@ The published ${g} artifact additionally contains code with the following licens
104
104
  Because none of the third-party transpiler, packem uses under the hood is type-aware, some techniques or features often used in TypeScript are not properly checked and can cause mis-compilation or even runtime errors.
105
105
  To mitigate this, you should set the isolatedModules option to true in tsconfig and let your IDE warn you when such incompatible constructs are used.`),await Gi(u),u},"createContext"),vs=N(async e=>{const t=[];if(e.options.clean)for(const o of new Set(e.options.entries.map(r=>r.outDir).filter(Boolean).sort()))o===e.options.rootDir||o===e.options.sourceDir||e.options.rootDir.startsWith(o.endsWith("/")?o:`${o}/`)||t.some(r=>o.startsWith(r))||(t.push(o),e.logger.info(`Cleaning dist directory: \`./${O(e.options.rootDir,o)}\``),await io(o))},"cleanDistributionDirectories"),bs=N(async(e,t,o)=>{if(e&&P(w(e,"keystore1.json"))){const r=ke(w(e,"keystore.json")),n=$e(e,{withFileTypes:!0}).filter(s=>s.isDirectory());let i=o;for await(const s of n)r[s.name]||(await Ht(w(e,s.name),{force:!0,recursive:!0}),i&&t.raw(`
106
106
 
107
- `),t.info({message:"Removing "+s.name+" file cache, the cache key is not used anymore.",prefix:"file-cache"}),i=!1)}},"removeOldCacheFolders"),ws=N(e=>{switch(e){case"jit":return"Stubbing";case"watch":return"Watching";case"tsdoc":return"Generating TSDoc";default:return"Building"}},"getMode"),ua=N(async(e,t,o,r,n={})=>{const{configPath:i,debug:s,tsconfigPath:a,...l}=n;r.wrapAll(),e=$(Xt(),e),r.debug("Root directory:",e);const{packageJson:c,packageJsonPath:d}=Ut(e);r.debug("Using package.json found at",d);let p;if(a){const h=w(e,a);if(!await so(h))throw new Error("tsconfig.json not found at "+h);p={config:lo(h),path:h},r.info("Using tsconfig settings at",h)}else if(c.dependencies?.typescript||c.devDependencies?.typescript)try{p=await co(e),r.debug("Using tsconfig settings found at",p.path)}catch{r.info("No tsconfig.json or jsconfig.json found.")}const u=to(c.name,{cwd:e});let g=!1;try{let h=i??"";if(!h){const z=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"];for(const L of z)if(P(w(e,L))){h="./"+L;break}}const f=st(e,{debug:s,interopDefault:!0});if(!/\.(?:js|mjs|cjs|ts|cts|mts)$/.test(h))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");let y=await f.import(h,{try:!0})||{};typeof y=="function"&&(y=await y(o,t)),r.debug("Using packem config found at",w(e,h));const b=M(JSON.stringify({version:c.version,...c.dependencies,...c.devDependencies,...c.peerDependencies,...c.peerDependenciesMeta,browser:c.browser,eNode:c.engines?.node,exports:c.exports,main:c.main,module:c.module,type:c.type,types:c.types}))+M(JSON.stringify(y));u&&Ye(b,u,r);const x=new Li(e,u,b,r),v=await ys(r,e,t,o,s??!1,l,y,c,p,f);x.isEnabled=v.options.fileCache,v.logger.info(k(ws(t)+" "+v.options.name)),v.logger.debug({context:v.options.entries,message:`${D("Root dir:")} ${v.options.rootDir}
107
+ `),t.info({message:"Removing "+s.name+" file cache, the cache key is not used anymore.",prefix:"file-cache"}),i=!1)}},"removeOldCacheFolders"),ws=N(e=>{switch(e){case"jit":return"Stubbing";case"watch":return"Watching";case"tsdoc":return"Generating TSDoc";default:return"Building"}},"getMode"),ua=N(async(e,t,o,r,n={})=>{const{configPath:i,debug:s,tsconfigPath:a,...l}=n;r.wrapAll(),e=$(Xt(),e),r.debug("Root directory:",e);const{packageJson:c,packageJsonPath:d}=Ut(e);r.debug("Using package.json found at",d);let p;if(a){const h=w(e,a);if(!await so(h))throw new Error("tsconfig.json not found at "+h);p={config:lo(h),path:h},r.info("Using tsconfig settings at",h)}else if(c.dependencies?.typescript||c.devDependencies?.typescript)try{p=await co(e),r.debug("Using tsconfig settings found at",p.path)}catch{r.info("No tsconfig.json or jsconfig.json found.")}const u=to("@visulima/packem",{cwd:e});let g=!1;try{let h=i??"";if(!h){const z=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"];for(const L of z)if(P(w(e,L))){h="./"+L;break}}const f=st(e,{debug:s,interopDefault:!0});if(!/\.(?:js|mjs|cjs|ts|cts|mts)$/.test(h))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");let y=await f.import(h,{try:!0})||{};typeof y=="function"&&(y=await y(o,t)),r.debug("Using packem config found at",w(e,h));const b=M(JSON.stringify({version:c.version,...c.dependencies,...c.devDependencies,...c.peerDependencies,...c.peerDependenciesMeta,browser:c.browser,eNode:c.engines?.node,exports:c.exports,main:c.main,module:c.module,type:c.type,types:c.types}))+M(JSON.stringify(y));u&&Ye(b,u,r);const x=new Li(e,u,b,r),v=await ys(r,e,t,o,s??!1,l,y,c,p,f);x.isEnabled=v.options.fileCache,v.logger.info(k(ws(t)+" "+v.options.name)),v.logger.debug({context:v.options.entries,message:`${D("Root dir:")} ${v.options.rootDir}
108
108
  ${D("Entries:")}}`}),await vs(v);const _=Date.now(),Q=N(()=>ao(Math.floor(Date.now()-_)),"getDuration");if(t==="watch"){if(v.options.rollup.watch===!1)throw new Error("Rollup watch is disabled. You should check your packem.config file.");await Ci(v,x),Xe(v,!1);return}if(t==="jit"?(await Oi(v),await v.hooks.callHook("build:done",v)):(g=await si(v,x),await v.hooks.callHook("validate:before",v),cs(v),await v.hooks.callHook("validate:done",v),Xe(v,g)),v.options.typedoc&&v.options.typedoc.format!==void 0){let z="unknown";c.dependencies?.typedoc?z=c.dependencies.typedoc:c.devDependencies?.typedoc&&(z=c.devDependencies.typedoc),u&&Ye("typedoc",u,r,!0),g&&v.logger.raw(`
109
109
  `),v.logger.info({message:"Using "+k("typedoc")+" "+z+" to generate reference documentation",prefix:"typedoc"}),await v.hooks.callHook("typedoc:before",v);let L=w(v.options.rootDir,"api-docs");v.options.typedoc.format==="inline"&&u&&(L=w(u,"typedoc")),v.options.typedoc.output&&(L=v.options.typedoc.output),await Ti(v.options.typedoc,v.options.entries,L,v.logger),await v.hooks.callHook("typedoc:done",v)}r.raw(`
110
110
  ⚡️ Build run in `+Q()),r.restoreAll()}catch(h){throw r.raw(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/packem",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "A fast and modern bundler for Node.js and TypeScript.",
5
5
  "keywords": [
6
6
  "anolilab",
@@ -185,43 +185,43 @@
185
185
  "@babel/parser": "7.25.6",
186
186
  "@ckeditor/typedoc-plugins": "43.0.0",
187
187
  "@clack/prompts": "0.7.0",
188
- "@rollup/plugin-alias": "5.1.0",
189
- "@rollup/plugin-commonjs": "26.0.1",
190
- "@rollup/plugin-dynamic-import-vars": "2.1.2",
188
+ "@rollup/plugin-alias": "5.1.1",
189
+ "@rollup/plugin-commonjs": "26.0.3",
190
+ "@rollup/plugin-dynamic-import-vars": "2.1.3",
191
191
  "@rollup/plugin-inject": "5.0.5",
192
192
  "@rollup/plugin-json": "6.1.0",
193
- "@rollup/plugin-node-resolve": "15.2.3",
193
+ "@rollup/plugin-node-resolve": "15.2.4",
194
194
  "@rollup/plugin-replace": "5.0.7",
195
195
  "@rollup/plugin-wasm": "6.2.2",
196
- "@rollup/pluginutils": "5.1.0",
197
- "@visulima/cerebro": "1.1.20",
198
- "@visulima/colorize": "1.4.9",
199
- "@visulima/find-cache-dir": "1.0.10",
200
- "@visulima/fs": "2.1.17",
201
- "@visulima/humanizer": "1.0.11",
202
- "@visulima/package": "3.1.0",
203
- "@visulima/pail": "2.1.8",
204
- "@visulima/path": "1.0.8",
205
- "@visulima/tsconfig": "1.0.12",
196
+ "@rollup/pluginutils": "5.1.2",
197
+ "@visulima/cerebro": "1.1.21",
198
+ "@visulima/colorize": "1.4.10",
199
+ "@visulima/find-cache-dir": "1.0.11",
200
+ "@visulima/fs": "2.1.18",
201
+ "@visulima/humanizer": "1.0.12",
202
+ "@visulima/package": "3.1.1",
203
+ "@visulima/pail": "2.1.9",
204
+ "@visulima/path": "1.0.9",
205
+ "@visulima/tsconfig": "1.0.13",
206
206
  "defu": "6.1.4",
207
207
  "es-module-lexer": "1.5.4",
208
208
  "fastest-levenshtein": "1.0.16",
209
209
  "glob-parent": "6.0.2",
210
210
  "hookable": "5.5.3",
211
211
  "is-glob": "4.0.3",
212
- "jiti": "2.0.0-beta.3",
212
+ "jiti": "2.0.0-rc.1",
213
213
  "magic-string": "0.30.11",
214
214
  "mlly": "1.7.1",
215
215
  "oxc-parser": "0.29.0",
216
216
  "rollup": "4.22.2",
217
217
  "rollup-plugin-dts": "6.1.1",
218
- "rollup-plugin-license": "3.5.2",
218
+ "rollup-plugin-license": "3.5.3",
219
219
  "rollup-plugin-polyfill-node": "0.13.0",
220
220
  "rollup-plugin-visualizer": "5.12.0",
221
221
  "semver": "7.6.3",
222
222
  "tinyglobby": "0.2.6",
223
223
  "typedoc": "0.26.7",
224
- "typedoc-plugin-markdown": "4.2.7",
224
+ "typedoc-plugin-markdown": "4.2.8",
225
225
  "typedoc-plugin-rename-defaults": "0.7.1"
226
226
  },
227
227
  "devDependencies": {
@@ -240,7 +240,7 @@
240
240
  "@types/glob": "^8.1.0",
241
241
  "@types/glob-parent": "^5.1.3",
242
242
  "@types/is-glob": "^4.0.4",
243
- "@types/node": "18.19.39",
243
+ "@types/node": "18.19.50",
244
244
  "@types/react": "^18.3.8",
245
245
  "@types/react-dom": "^18.3.0",
246
246
  "@types/semver": "^7.5.8",
@@ -259,7 +259,7 @@
259
259
  "eslint-plugin-vitest-globals": "^1.5.0",
260
260
  "estree-walker": "^3.0.3",
261
261
  "execa": "^9.4.0",
262
- "oxc-transform": "^0.30.0",
262
+ "oxc-transform": "^0.30.1",
263
263
  "prettier": "^3.3.3",
264
264
  "react": "^18.3.1",
265
265
  "react-dom": "^18.3.1",