@visulima/packem 1.0.0-alpha.85 → 1.0.0-alpha.87

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/cli.cjs +7 -5
  3. package/dist/cli.mjs +8 -6
  4. package/dist/config.d.cts +5 -5
  5. package/dist/config.d.mts +5 -5
  6. package/dist/create-bundler.cjs +69 -68
  7. package/dist/create-bundler.d.cts +4 -4
  8. package/dist/create-bundler.d.mts +4 -4
  9. package/dist/create-bundler.mjs +56 -55
  10. package/dist/rollup/plugins/esbuild/index.cjs +1 -1
  11. package/dist/rollup/plugins/esbuild/index.d.cts +1 -1
  12. package/dist/rollup/plugins/esbuild/index.d.mts +1 -1
  13. package/dist/rollup/plugins/esbuild/index.mjs +1 -1
  14. package/dist/rollup/plugins/oxc/isolated-declarations-oxc-transformer.d.cts +4 -4
  15. package/dist/rollup/plugins/oxc/isolated-declarations-oxc-transformer.d.mts +4 -4
  16. package/dist/rollup/plugins/sucrase/index.cjs +1 -1
  17. package/dist/rollup/plugins/sucrase/index.d.cts +1 -1
  18. package/dist/rollup/plugins/sucrase/index.d.mts +1 -1
  19. package/dist/rollup/plugins/sucrase/index.mjs +1 -1
  20. package/dist/rollup/plugins/swc/isolated-declarations-swc-transformer.d.cts +4 -4
  21. package/dist/rollup/plugins/swc/isolated-declarations-swc-transformer.d.mts +4 -4
  22. package/dist/rollup/plugins/swc/swc-plugin.cjs +1 -1
  23. package/dist/rollup/plugins/swc/swc-plugin.d.cts +1 -1
  24. package/dist/rollup/plugins/swc/swc-plugin.d.mts +1 -1
  25. package/dist/rollup/plugins/swc/swc-plugin.mjs +1 -1
  26. package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.d.cts +4 -4
  27. package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.d.mts +4 -4
  28. package/dist/shared/{packem.D1jC0r53.d.mts → types-CqOiWvwZ.d.cts} +8 -3
  29. package/dist/shared/{packem.Cbc-R3fD.d.cts → types-DRxO9m8T.d.mts} +8 -3
  30. package/package.json +14 -10
  31. /package/dist/shared/{packem.DcRh98q_.mjs → constants-DcRh98q_.mjs} +0 -0
  32. /package/dist/shared/{packem.lwnJ_PjR.cjs → constants-lwnJ_PjR.cjs} +0 -0
  33. /package/dist/shared/{packem.BcJmI4Tm.mjs → resolve-file-BcJmI4Tm.mjs} +0 -0
  34. /package/dist/shared/{packem.DUZi_m4G.cjs → resolve-file-DUZi_m4G.cjs} +0 -0
  35. /package/dist/shared/{packem.CzGE8V_d.d.cts → types-CzGE8V_d.d.cts} +0 -0
  36. /package/dist/shared/{packem.CzGE8V_d.d.mts → types-CzGE8V_d.d.mts} +0 -0
  37. /package/dist/shared/{packem.Db-Z_7e-.d.cts → types-Db-Z_7e-.d.cts} +0 -0
  38. /package/dist/shared/{packem.Db-Z_7e-.d.mts → types-Db-Z_7e-.d.mts} +0 -0
  39. /package/dist/shared/{packem.DvWhOdt5.d.cts → types-DvWhOdt5.d.cts} +0 -0
  40. /package/dist/shared/{packem.DvWhOdt5.d.mts → types-DvWhOdt5.d.mts} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,27 @@
1
+ ## @visulima/packem [1.0.0-alpha.87](https://github.com/visulima/packem/compare/@visulima/packem@1.0.0-alpha.86...@visulima/packem@1.0.0-alpha.87) (2024-09-01)
2
+
3
+ ### Features
4
+
5
+ * added missing copyright header ([f4a8530](https://github.com/visulima/packem/commit/f4a8530d4b040ba7fb8986607344cd1018fc3ba9))
6
+ * added missing copyright header, added isolated transformer to init command, renamed exports ([ecb0a4e](https://github.com/visulima/packem/commit/ecb0a4e3cabf3117c571e00b00305c033dc57ae8))
7
+ * added working isolated declarations for swc, typescript and oxc ([30f9f38](https://github.com/visulima/packem/commit/30f9f38747256b433c4ef8b6d10aad6ad24bb479))
8
+
9
+ ### Bug Fixes
10
+
11
+ * fixed shebang output ([a88654a](https://github.com/visulima/packem/commit/a88654a1f29c6cb0bafc4fd0d8f9575a828a54e4))
12
+
13
+ ## @visulima/packem [1.0.0-alpha.86](https://github.com/visulima/packem/compare/@visulima/packem@1.0.0-alpha.85...@visulima/packem@1.0.0-alpha.86) (2024-08-30)
14
+
15
+ ### Bug Fixes
16
+
17
+ * added a better chunk splitter ([185ac52](https://github.com/visulima/packem/commit/185ac5287326feefc1bcc3f7acd6fef3c94b0c3b))
18
+ * fixed preserve and prepend of directives ([9191381](https://github.com/visulima/packem/commit/9191381697a965e84a9cf4500eb84850bd251532))
19
+ * updated tests ([56f6be1](https://github.com/visulima/packem/commit/56f6be1e7532924b0972ece2b56db415342f43a7))
20
+
21
+ ### Miscellaneous Chores
22
+
23
+ * deps update ([ef94d5c](https://github.com/visulima/packem/commit/ef94d5c2e99c033f2ccdbe0f14b51ee390b1dc5c))
24
+
1
25
  ## @visulima/packem [1.0.0-alpha.85](https://github.com/visulima/packem/compare/@visulima/packem@1.0.0-alpha.84...@visulima/packem@1.0.0-alpha.85) (2024-08-28)
2
26
 
3
27
  ### Bug Fixes
package/dist/cli.cjs CHANGED
@@ -1,14 +1,16 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var h=Object.defineProperty;var p=(n,o)=>h(n,"name",{value:o,configurable:!0});const k=require("@visulima/cerebro"),E=require("@visulima/pail/reporter"),d=require("node:process"),l=require("./shared/packem.lwnJ_PjR.cjs"),b=require("./create-bundler.cjs"),j=require("@antfu/install-pkg"),a=require("@clack/prompts"),m=require("@visulima/fs"),w=require("@visulima/package/package-json"),u=require("@visulima/path"),N=p(n=>n&&typeof n=="object"&&"default"in n?n.default:n,"_interopDefaultCompat"),C=N(k),V="@visulima/packem",O="1.0.0-alpha.84";var D=Object.defineProperty,g=p((n,o)=>D(n,"name",{value:o,configurable:!0}),"a");const P=g(n=>{n.addCommand({description:"Demonstrate options required",execute:g(async({logger:o,options:e})=>{let s="build";e.watch?s="watch":e.jit&&(s="jit");const r={};let t;if(d.env.NODE_ENV&&[l.DEVELOPMENT_ENV,l.PRODUCTION_ENV].includes(d.env.NODE_ENV)&&(t=d.env.NODE_ENV),e.env)for(const i of e.env)if(i.key==="NODE_ENV"){if(t)throw new Error("NODE_ENV was already set, this can't be overridden.");t=i.value}else r["process.env."+i.key]=JSON.stringify(i.value);t===void 0&&(e.production?t=l.PRODUCTION_ENV:e.development&&(t=l.DEVELOPMENT_ENV));try{await b(e.dir,s,t,o,{cjsInterop:e.cjsInterop,clean:e.clean,configPath:e.config??void 0,debug:e.debug,minify:e.minify===void 0?t===l.PRODUCTION_ENV:e.minify,replace:{...r},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})}catch(i){o.error(i),d.exit(1)}},"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},{conflicts:"jit",description:"Watch for changes",name:"watch",type:Boolean},{conflicts:"watch",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:g(o=>{const[e,s]=o.split("=");return{key:e,value:s}},"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},{conflicts:"development",description:"Run code in production environment",name:"production",type:Boolean},{conflicts:"production",description:"Run code in development environment",name:"development",type:Boolean},{description:"Do not clean the dist directory before building",name:"no-clean",type:Boolean}]})},"createBuildCommand");var S=Object.defineProperty,v=p((n,o)=>S(n,"name",{value:o,configurable:!0}),"m");const _=v(n=>{n.addCommand({description:"Initialize packem configuration",execute:v(async({logger:o,options:e})=>{if(a.intro("Welcome to packem setup"),m.isAccessibleSync(u.join(e.dir,"packem.config.ts"))){o.info("Packem project already initialized, you can use `packem build` to build your project");return}if(a.isCancel(e.transformer)){a.cancel("Operation cancelled");return}const s=u.join(e.dir,"package.json");if(!m.isAccessibleSync(s))throw new Error("No package.json found in the directory");const r=w.parsePackageJson(s),t=[];if(r.dependencies&&t.push(...Object.keys(r.dependencies)),r.devDependencies&&t.push(...Object.keys(r.devDependencies)),e.transformer===void 0&&(e.transformer=await a.select({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"}]}),!t.includes(e.transformer)&&await a.confirm({message:"Do you want to install "+e.transformer+"?"}))){const i=a.spinner();i.start("Installing "+e.transformer),await j.installPackage(e.transformer==="swc"?"@swc/core":e.transformer,{cwd:e.dir,dev:!0,silent:!0}),i.stop("")}if(t.includes("typescript")||r.type==="module"){const i=`import { defineConfig } from "@visulima/packem/config";
2
+ "use strict";var w=Object.defineProperty;var d=(r,i)=>w(r,"name",{value:i,configurable:!0});const h=require("@visulima/cerebro"),b=require("@visulima/pail/reporter"),p=require("node:process"),l=require("./shared/constants-lwnJ_PjR.cjs"),E=require("./create-bundler.cjs"),v=require("@antfu/install-pkg"),o=require("@clack/prompts"),m=require("@visulima/fs"),D=require("@visulima/package/package-json"),u=require("@visulima/path"),j=d(r=>r&&typeof r=="object"&&"default"in r?r.default:r,"_interopDefaultCompat"),N=j(h),C="@visulima/packem",O="1.0.0-alpha.86";var V=Object.defineProperty,g=d((r,i)=>V(r,"name",{value:i,configurable:!0}),"a");const P=g(r=>{r.addCommand({description:"Demonstrate options required",execute:g(async({logger:i,options:e})=>{let s="build";e.watch?s="watch":e.jit&&(s="jit");const a={};let n;if(p.env.NODE_ENV&&[l.DEVELOPMENT_ENV,l.PRODUCTION_ENV].includes(p.env.NODE_ENV)&&(n=p.env.NODE_ENV),e.env)for(const t of e.env)if(t.key==="NODE_ENV"){if(n)throw new Error("NODE_ENV was already set, this can't be overridden.");n=t.value}else a["process.env."+t.key]=JSON.stringify(t.value);n===void 0&&(e.production?n=l.PRODUCTION_ENV:e.development&&(n=l.DEVELOPMENT_ENV));try{await E(e.dir,s,n,i,{cjsInterop:e.cjsInterop,clean:e.clean,configPath:e.config??void 0,debug:e.debug,minify:e.minify===void 0?n===l.PRODUCTION_ENV: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})}catch(t){i.error(t),p.exit(1)}},"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},{conflicts:"jit",description:"Watch for changes",name:"watch",type:Boolean},{conflicts:"watch",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:g(i=>{const[e,s]=i.split("=");return{key:e,value:s}},"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},{conflicts:"development",description:"Run code in production environment",name:"production",type:Boolean},{conflicts:"production",description:"Run code in development environment",name:"development",type:Boolean},{description:"Do not clean the dist directory before building",name:"no-clean",type:Boolean}]})},"createBuildCommand");var T=Object.defineProperty,k=d((r,i)=>T(r,"name",{value:i,configurable:!0}),"m");const x=k(r=>{r.addCommand({description:"Initialize packem configuration",execute:k(async({logger:i,options:e})=>{if(o.intro("Welcome to packem setup"),m.isAccessibleSync(u.join(e.dir,"packem.config.ts"))){i.info("Packem project already initialized, you can use `packem build` to build your project");return}if(o.isCancel(e.transformer)){o.cancel("Operation cancelled");return}const s=u.join(e.dir,"package.json");if(!m.isAccessibleSync(s))throw new Error("No package.json found in the directory");const a=D.parsePackageJson(s),n=[];if(a.dependencies&&n.push(...Object.keys(a.dependencies)),a.devDependencies&&n.push(...Object.keys(a.devDependencies)),e.transformer===void 0&&(e.transformer=await o.select({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"}]}),!n.includes(e.transformer)&&await o.confirm({message:"Do you want to install "+e.transformer+"?"}))){const t=o.spinner();t.start("Installing "+e.transformer),await v.installPackage(e.transformer==="swc"?"@swc/core":e.transformer,{cwd:e.dir,dev:!0,silent:!0}),t.stop("")}if(e.isolatedDeclarationTransformer===void 0&&(e.isolatedDeclarationTransformer=await o.select({message:"Pick a isolated declaration transformer",options:[{label:"Typescript",value:"typescript"},{label:"swc",value:"swc"},{label:"OXC",value:"oxc"},{label:"None",value:null}]}),e.isolatedDeclarationTransformer!==null)){let t;switch(e.isolatedDeclarationTransformer){case"typescript":{t="typescript";break}case"swc":{t="@swc/core";break}case"oxc":{t="oxc-transform";break}default:o.cancel("Invalid isolated declaration transformer")}if(t&&!n.includes(t)&&await o.confirm({message:"Do you want to install "+t+"?"})){const c=o.spinner();c.start("Installing "+e.isolatedDeclarationTransformer),await v.installPackage(t,{cwd:e.dir,dev:!0,silent:!0}),c.stop("")}}if(n.includes("typescript")||a.type==="module"){const t=`import { defineConfig } from "@visulima/packem/config";
3
3
  import transformer from "@visulima/packem/transformer/${e.transformer}";
4
-
4
+ ${e.isolatedDeclarationTransformer===null?"":`import isolatedDeclarationTransformer from "@visulima/packem/dts/isolated/transformer/${e.isolatedDeclarationTransformer}";
5
+ `}
5
6
  export default defineConfig({
6
- transformer
7
+ transformer${e.isolatedDeclarationTransformer===null?"":`,
8
+ isolatedDeclarationTransformer`}
7
9
  });
8
- `,c=a.spinner(),f=r.type==="module"?"mjs":"ts";c.start("Creating packem.config."+f),m.writeFileSync(u.join(e.dir,"packem.config."+f),i),c.stop("Created packem.config."+f)}else{const i=`const { defineConfig } = require("@visulima/packem/config");
10
+ `,c=o.spinner(),f=a.type==="module"?"mjs":"ts";c.start("Creating packem.config."+f),m.writeFileSync(u.join(e.dir,"packem.config."+f),t),c.stop("Created packem.config."+f)}else{const t=`const { defineConfig } = require("@visulima/packem/config");
9
11
  const transformer = require("@visulima/packem/transformer/${e.transformer}");
10
12
 
11
13
  module.exports = defineConfig({
12
14
  transformer
13
15
  });
14
- `,c=a.spinner();c.start("Creating packem.config.js"),m.writeFileSync(u.join(e.dir,"packem.config.js"),i),c.stop("Created packem.config.js")}a.outro("Now you can run `packem build` to build your project")},"execute"),name:"init",options:[{defaultValue:".",description:"The directory to initialize",name:"dir",type:String},{description:"Choose a transformer to use for packem",name:"transformer",type:String}]})},"createInitCommand"),y=new C("packem",{logger:{reporters:[new E.SimpleReporter({error:{hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0}})],scope:"packem"},packageName:V,packageVersion:O});_(y);P(y);y.run({shouldExitProcess:!1});
16
+ `,c=o.spinner();c.start("Creating packem.config.js"),m.writeFileSync(u.join(e.dir,"packem.config.js"),t),c.stop("Created packem.config.js")}o.outro("Now you can run `packem build` to build your project")},"execute"),name:"init",options:[{defaultValue:".",description:"The directory to initialize",name:"dir",type:String},{description:"Choose a transformer",name:"transformer",type:String},{description:"Choose a isolated declaration transformer",name:"isolated-declaration-transformer",type:String}]})},"createInitCommand"),y=new N("packem",{logger:{reporters:[new b.SimpleReporter({error:{hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0}})],scope:"packem"},packageName:C,packageVersion:O});x(y);P(y);y.run({shouldExitProcess:!1});
package/dist/cli.mjs CHANGED
@@ -1,16 +1,18 @@
1
1
  #!/usr/bin/env node
2
- var b=Object.defineProperty;var m=(n,i)=>b(n,"name",{value:i,configurable:!0});import w from"@visulima/cerebro";import{SimpleReporter as E}from"@visulima/pail/reporter";import{env as l,exit as j}from"node:process";import{b as y,P as d}from"./shared/packem.DcRh98q_.mjs";import C from"./create-bundler.mjs";import{installPackage as N}from"@antfu/install-pkg";import{intro as V,isCancel as O,cancel as D,select as P,confirm as x,spinner as f,outro as S}from"@clack/prompts";import{isAccessibleSync as v,writeFileSync as h}from"@visulima/fs";import{parsePackageJson as B}from"@visulima/package/package-json";import{join as s}from"@visulima/path";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
2
+ var E=Object.defineProperty;var p=(a,t)=>E(a,"name",{value:t,configurable:!0});import C from"@visulima/cerebro";import{SimpleReporter as N}from"@visulima/pail/reporter";import{env as d,exit as V}from"node:process";import{b as y,P as f}from"./shared/constants-DcRh98q_.mjs";import x from"./create-bundler.mjs";import{installPackage as v}from"@antfu/install-pkg";import{intro as O,isCancel as T,cancel as w,select as h,confirm as k,spinner as c,outro as P}from"@clack/prompts";import{isAccessibleSync as b,writeFileSync as j}from"@visulima/fs";import{parsePackageJson as S}from"@visulima/package/package-json";import{join as l}from"@visulima/path";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
3
3
  const require = __cjs_mod__.createRequire(import.meta.url);
4
- const z="@visulima/packem",I="1.0.0-alpha.84";var _=Object.defineProperty,u=m((n,i)=>_(n,"name",{value:i,configurable:!0}),"a");const T=u(n=>{n.addCommand({description:"Demonstrate options required",execute:u(async({logger:i,options:e})=>{let a="build";e.watch?a="watch":e.jit&&(a="jit");const r={};let o;if(l.NODE_ENV&&[y,d].includes(l.NODE_ENV)&&(o=l.NODE_ENV),e.env)for(const t of e.env)if(t.key==="NODE_ENV"){if(o)throw new Error("NODE_ENV was already set, this can't be overridden.");o=t.value}else r["process.env."+t.key]=JSON.stringify(t.value);o===void 0&&(e.production?o=d:e.development&&(o=y));try{await C(e.dir,a,o,i,{cjsInterop:e.cjsInterop,clean:e.clean,configPath:e.config??void 0,debug:e.debug,minify:e.minify===void 0?o===d:e.minify,replace:{...r},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})}catch(t){i.error(t),j(1)}},"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},{conflicts:"jit",description:"Watch for changes",name:"watch",type:Boolean},{conflicts:"watch",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:u(i=>{const[e,a]=i.split("=");return{key:e,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},{conflicts:"development",description:"Run code in production environment",name:"production",type:Boolean},{conflicts:"production",description:"Run code in development environment",name:"development",type:Boolean},{description:"Do not clean the dist directory before building",name:"no-clean",type:Boolean}]})},"createBuildCommand");var J=Object.defineProperty,k=m((n,i)=>J(n,"name",{value:i,configurable:!0}),"m");const R=k(n=>{n.addCommand({description:"Initialize packem configuration",execute:k(async({logger:i,options:e})=>{if(V("Welcome to packem setup"),v(s(e.dir,"packem.config.ts"))){i.info("Packem project already initialized, you can use `packem build` to build your project");return}if(O(e.transformer)){D("Operation cancelled");return}const a=s(e.dir,"package.json");if(!v(a))throw new Error("No package.json found in the directory");const r=B(a),o=[];if(r.dependencies&&o.push(...Object.keys(r.dependencies)),r.devDependencies&&o.push(...Object.keys(r.devDependencies)),e.transformer===void 0&&(e.transformer=await P({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"}]}),!o.includes(e.transformer)&&await x({message:"Do you want to install "+e.transformer+"?"}))){const t=f();t.start("Installing "+e.transformer),await N(e.transformer==="swc"?"@swc/core":e.transformer,{cwd:e.dir,dev:!0,silent:!0}),t.stop("")}if(o.includes("typescript")||r.type==="module"){const t=`import { defineConfig } from "@visulima/packem/config";
4
+ const B="@visulima/packem",I="1.0.0-alpha.86";var z=Object.defineProperty,u=p((a,t)=>z(a,"name",{value:t,configurable:!0}),"a");const _=u(a=>{a.addCommand({description:"Demonstrate options required",execute:u(async({logger:t,options:e})=>{let n="build";e.watch?n="watch":e.jit&&(n="jit");const i={};let o;if(d.NODE_ENV&&[y,f].includes(d.NODE_ENV)&&(o=d.NODE_ENV),e.env)for(const r of e.env)if(r.key==="NODE_ENV"){if(o)throw new Error("NODE_ENV was already set, this can't be overridden.");o=r.value}else i["process.env."+r.key]=JSON.stringify(r.value);o===void 0&&(e.production?o=f:e.development&&(o=y));try{await x(e.dir,n,o,t,{cjsInterop:e.cjsInterop,clean:e.clean,configPath:e.config??void 0,debug:e.debug,minify:e.minify===void 0?o===f:e.minify,replace:{...i},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})}catch(r){t.error(r),V(1)}},"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},{conflicts:"jit",description:"Watch for changes",name:"watch",type:Boolean},{conflicts:"watch",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:u(t=>{const[e,n]=t.split("=");return{key:e,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},{conflicts:"development",description:"Run code in production environment",name:"production",type:Boolean},{conflicts:"production",description:"Run code in development environment",name:"development",type:Boolean},{description:"Do not clean the dist directory before building",name:"no-clean",type:Boolean}]})},"createBuildCommand");var $=Object.defineProperty,D=p((a,t)=>$(a,"name",{value:t,configurable:!0}),"m");const J=D(a=>{a.addCommand({description:"Initialize packem configuration",execute:D(async({logger:t,options:e})=>{if(O("Welcome to packem setup"),b(l(e.dir,"packem.config.ts"))){t.info("Packem project already initialized, you can use `packem build` to build your project");return}if(T(e.transformer)){w("Operation cancelled");return}const n=l(e.dir,"package.json");if(!b(n))throw new Error("No package.json found in the directory");const i=S(n),o=[];if(i.dependencies&&o.push(...Object.keys(i.dependencies)),i.devDependencies&&o.push(...Object.keys(i.devDependencies)),e.transformer===void 0&&(e.transformer=await h({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"}]}),!o.includes(e.transformer)&&await k({message:"Do you want to install "+e.transformer+"?"}))){const r=c();r.start("Installing "+e.transformer),await v(e.transformer==="swc"?"@swc/core":e.transformer,{cwd:e.dir,dev:!0,silent:!0}),r.stop("")}if(e.isolatedDeclarationTransformer===void 0&&(e.isolatedDeclarationTransformer=await h({message:"Pick a isolated declaration transformer",options:[{label:"Typescript",value:"typescript"},{label:"swc",value:"swc"},{label:"OXC",value:"oxc"},{label:"None",value:null}]}),e.isolatedDeclarationTransformer!==null)){let r;switch(e.isolatedDeclarationTransformer){case"typescript":{r="typescript";break}case"swc":{r="@swc/core";break}case"oxc":{r="oxc-transform";break}default:w("Invalid isolated declaration transformer")}if(r&&!o.includes(r)&&await k({message:"Do you want to install "+r+"?"})){const s=c();s.start("Installing "+e.isolatedDeclarationTransformer),await v(r,{cwd:e.dir,dev:!0,silent:!0}),s.stop("")}}if(o.includes("typescript")||i.type==="module"){const r=`import { defineConfig } from "@visulima/packem/config";
5
5
  import transformer from "@visulima/packem/transformer/${e.transformer}";
6
-
6
+ ${e.isolatedDeclarationTransformer===null?"":`import isolatedDeclarationTransformer from "@visulima/packem/dts/isolated/transformer/${e.isolatedDeclarationTransformer}";
7
+ `}
7
8
  export default defineConfig({
8
- transformer
9
+ transformer${e.isolatedDeclarationTransformer===null?"":`,
10
+ isolatedDeclarationTransformer`}
9
11
  });
10
- `,c=f(),p=r.type==="module"?"mjs":"ts";c.start("Creating packem.config."+p),h(s(e.dir,"packem.config."+p),t),c.stop("Created packem.config."+p)}else{const t=`const { defineConfig } = require("@visulima/packem/config");
12
+ `,s=c(),m=i.type==="module"?"mjs":"ts";s.start("Creating packem.config."+m),j(l(e.dir,"packem.config."+m),r),s.stop("Created packem.config."+m)}else{const r=`const { defineConfig } = require("@visulima/packem/config");
11
13
  const transformer = require("@visulima/packem/transformer/${e.transformer}");
12
14
 
13
15
  module.exports = defineConfig({
14
16
  transformer
15
17
  });
16
- `,c=f();c.start("Creating packem.config.js"),h(s(e.dir,"packem.config.js"),t),c.stop("Created packem.config.js")}S("Now you can run `packem build` to build your project")},"execute"),name:"init",options:[{defaultValue:".",description:"The directory to initialize",name:"dir",type:String},{description:"Choose a transformer to use for packem",name:"transformer",type:String}]})},"createInitCommand"),g=new w("packem",{logger:{reporters:[new E({error:{hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0}})],scope:"packem"},packageName:z,packageVersion:I});R(g);T(g);g.run({shouldExitProcess:!1});
18
+ `,s=c();s.start("Creating packem.config.js"),j(l(e.dir,"packem.config.js"),r),s.stop("Created packem.config.js")}P("Now you can run `packem build` to build your project")},"execute"),name:"init",options:[{defaultValue:".",description:"The directory to initialize",name:"dir",type:String},{description:"Choose a transformer",name:"transformer",type:String},{description:"Choose a isolated declaration transformer",name:"isolated-declaration-transformer",type:String}]})},"createInitCommand"),g=new C("packem",{logger:{reporters:[new N({error:{hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0}})],scope:"packem"},packageName:B,packageVersion:I});J(g);_(g);g.run({shouldExitProcess:!1});
package/dist/config.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { B as BuildConfig, a as BuildPreset, E as Environment, M as Mode } from './shared/packem.Cbc-R3fD.cjs';
2
- export { b as BuildHooks } from './shared/packem.Cbc-R3fD.cjs';
1
+ import { B as BuildConfig, a as BuildPreset, E as Environment, M as Mode } from './shared/types-CqOiWvwZ.cjs';
2
+ export { b as BuildHooks } from './shared/types-CqOiWvwZ.cjs';
3
3
  import '@rollup/plugin-alias';
4
4
  import '@rollup/plugin-commonjs';
5
5
  import '@rollup/plugin-json';
@@ -16,11 +16,11 @@ import 'rollup';
16
16
  import 'rollup-plugin-dts';
17
17
  import 'rollup-plugin-polyfill-node';
18
18
  import 'rollup-plugin-visualizer';
19
- import './shared/packem.Db-Z_7e-.cjs';
19
+ import './shared/types-Db-Z_7e-.cjs';
20
20
  import 'esbuild';
21
- import './shared/packem.DvWhOdt5.cjs';
21
+ import './shared/types-DvWhOdt5.cjs';
22
22
  import 'sucrase';
23
- import './shared/packem.CzGE8V_d.cjs';
23
+ import './shared/types-CzGE8V_d.cjs';
24
24
 
25
25
  type BuildConfigFunction = (enviroment: Environment, mode: Mode) => BuildConfig;
26
26
 
package/dist/config.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { B as BuildConfig, a as BuildPreset, E as Environment, M as Mode } from './shared/packem.D1jC0r53.mjs';
2
- export { b as BuildHooks } from './shared/packem.D1jC0r53.mjs';
1
+ import { B as BuildConfig, a as BuildPreset, E as Environment, M as Mode } from './shared/types-DRxO9m8T.mjs';
2
+ export { b as BuildHooks } from './shared/types-DRxO9m8T.mjs';
3
3
  import '@rollup/plugin-alias';
4
4
  import '@rollup/plugin-commonjs';
5
5
  import '@rollup/plugin-json';
@@ -16,11 +16,11 @@ import 'rollup';
16
16
  import 'rollup-plugin-dts';
17
17
  import 'rollup-plugin-polyfill-node';
18
18
  import 'rollup-plugin-visualizer';
19
- import './shared/packem.Db-Z_7e-.mjs';
19
+ import './shared/types-Db-Z_7e-.mjs';
20
20
  import 'esbuild';
21
- import './shared/packem.DvWhOdt5.mjs';
21
+ import './shared/types-DvWhOdt5.mjs';
22
22
  import 'sucrase';
23
- import './shared/packem.CzGE8V_d.mjs';
23
+ import './shared/types-CzGE8V_d.mjs';
24
24
 
25
25
  type BuildConfigFunction = (enviroment: Environment, mode: Mode) => BuildConfig;
26
26