@tsmodule/tsmodule 41.26.0 → 41.27.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/bin.js CHANGED
@@ -4,7 +4,7 @@
4
4
  if(typeof process<"u"){let{dirname:e}=await import("path"),{fileURLToPath:i}=await import("url");globalThis.__filename=i(import.meta.url),globalThis.__dirname=e(globalThis.__filename);let{default:a}=await import("module");globalThis.require=a.createRequire(import.meta.url)}
5
5
  /** __ESM_SHIM_END */
6
6
 
7
- import{a as d,b as L,c as R,e as B,g as U,i as J,j as G,k as K,l as z,m as Y}from"./chunk-U5LAIS5T.js";import{a as w,b,c as fe}from"./chunk-SXU4PYPZ.js";var E=b(H=>{var y=class extends Error{constructor(e,t,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},V=class extends y{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};H.CommanderError=y;H.InvalidArgumentError=V});var S=b(F=>{var{InvalidArgumentError:ge}=E(),k=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,i)=>{if(!this.argChoices.includes(t))throw new ge(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,i):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function _e(h){let e=h.name()+(h.variadic===!0?"...":"");return h.required?"<"+e+">":"["+e+"]"}F.Argument=k;F.humanReadableArgName=_e});var N=b(Q=>{var{humanReadableArgName:Oe}=S(),D=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1}visibleCommands(e){let t=e.commands.filter(i=>!i._hidden);if(e._hasImplicitHelpCommand()){let[,i,n]=e._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/),s=e.createCommand(i).helpOption(!1);s.description(e._helpCommandDescription),n&&s.arguments(n),t.push(s)}return this.sortSubcommands&&t.sort((i,n)=>i.name().localeCompare(n.name())),t}visibleOptions(e){let t=e.options.filter(s=>!s.hidden),i=e._hasHelpOption&&e._helpShortFlag&&!e._findOption(e._helpShortFlag),n=e._hasHelpOption&&!e._findOption(e._helpLongFlag);if(i||n){let s;i?n?s=e.createOption(e._helpFlags,e._helpDescription):s=e.createOption(e._helpShortFlag,e._helpDescription):s=e.createOption(e._helpLongFlag,e._helpDescription),t.push(s)}if(this.sortOptions){let s=r=>r.short?r.short.replace(/^-/,""):r.long.replace(/^--/,"");t.sort((r,a)=>s(r).localeCompare(s(a)))}return t}visibleArguments(e){return e._argsDescription&&e._args.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e._args.find(t=>t.description)?e._args:[]}subcommandTerm(e){let t=e._args.map(i=>Oe(i)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((i,n)=>Math.max(i,t.subcommandTerm(n).length),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((i,n)=>Math.max(i,t.optionTerm(n).length),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((i,n)=>Math.max(i,t.argumentTerm(n).length),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let i="";for(let n=e.parent;n;n=n.parent)i=n.name()+" "+i;return i+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];return e.argChoices&&t.push(`choices: ${e.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0?`${e.description} (${t.join(", ")})`:e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let i=`(${t.join(", ")})`;return e.description?`${e.description} ${i}`:i}return e.description}formatHelp(e,t){let i=t.padWidth(e,t),n=t.helpWidth||80,s=2,r=2;function a(m,W){if(W){let de=`${m.padEnd(i+r)}${W}`;return t.wrap(de,n-s,i+r)}return m}function o(m){return m.join(`
7
+ import{a as d,b as L,c as R,e as B,g as U,i as J,j as G,k as K,l as z,m as Y}from"./chunk-MASZ6UKV.js";import{a as w,b,c as fe}from"./chunk-SXU4PYPZ.js";var E=b(H=>{var y=class extends Error{constructor(e,t,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},V=class extends y{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};H.CommanderError=y;H.InvalidArgumentError=V});var S=b(F=>{var{InvalidArgumentError:ge}=E(),k=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,i)=>{if(!this.argChoices.includes(t))throw new ge(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,i):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function _e(h){let e=h.name()+(h.variadic===!0?"...":"");return h.required?"<"+e+">":"["+e+"]"}F.Argument=k;F.humanReadableArgName=_e});var N=b(Q=>{var{humanReadableArgName:Oe}=S(),D=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1}visibleCommands(e){let t=e.commands.filter(i=>!i._hidden);if(e._hasImplicitHelpCommand()){let[,i,n]=e._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/),s=e.createCommand(i).helpOption(!1);s.description(e._helpCommandDescription),n&&s.arguments(n),t.push(s)}return this.sortSubcommands&&t.sort((i,n)=>i.name().localeCompare(n.name())),t}visibleOptions(e){let t=e.options.filter(s=>!s.hidden),i=e._hasHelpOption&&e._helpShortFlag&&!e._findOption(e._helpShortFlag),n=e._hasHelpOption&&!e._findOption(e._helpLongFlag);if(i||n){let s;i?n?s=e.createOption(e._helpFlags,e._helpDescription):s=e.createOption(e._helpShortFlag,e._helpDescription):s=e.createOption(e._helpLongFlag,e._helpDescription),t.push(s)}if(this.sortOptions){let s=r=>r.short?r.short.replace(/^-/,""):r.long.replace(/^--/,"");t.sort((r,a)=>s(r).localeCompare(s(a)))}return t}visibleArguments(e){return e._argsDescription&&e._args.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e._args.find(t=>t.description)?e._args:[]}subcommandTerm(e){let t=e._args.map(i=>Oe(i)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((i,n)=>Math.max(i,t.subcommandTerm(n).length),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((i,n)=>Math.max(i,t.optionTerm(n).length),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((i,n)=>Math.max(i,t.argumentTerm(n).length),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let i="";for(let n=e.parent;n;n=n.parent)i=n.name()+" "+i;return i+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];return e.argChoices&&t.push(`choices: ${e.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0?`${e.description} (${t.join(", ")})`:e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let i=`(${t.join(", ")})`;return e.description?`${e.description} ${i}`:i}return e.description}formatHelp(e,t){let i=t.padWidth(e,t),n=t.helpWidth||80,s=2,r=2;function a(m,W){if(W){let de=`${m.padEnd(i+r)}${W}`;return t.wrap(de,n-s,i+r)}return m}function o(m){return m.join(`
8
8
  `).replace(/^/gm," ".repeat(s))}let l=[`Usage: ${t.commandUsage(e)}`,""],u=t.commandDescription(e);u.length>0&&(l=l.concat([u,""]));let c=t.visibleArguments(e).map(m=>a(t.argumentTerm(m),t.argumentDescription(m)));c.length>0&&(l=l.concat(["Arguments:",o(c),""]));let f=t.visibleOptions(e).map(m=>a(t.optionTerm(m),t.optionDescription(m)));f.length>0&&(l=l.concat(["Options:",o(f),""]));let A=t.visibleCommands(e).map(m=>a(t.subcommandTerm(m),t.subcommandDescription(m)));return A.length>0&&(l=l.concat(["Commands:",o(A),""])),l.join(`
9
9
  `)}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}wrap(e,t,i,n=40){if(e.match(/[\n]\s+/))return e;let s=t-i;if(s<n)return e;let r=e.slice(0,i),a=e.slice(i),o=" ".repeat(i),l=new RegExp(".{1,"+(s-1)+"}([\\s​]|$)|[^\\s​]+?([\\s​]|$)","g"),u=a.match(l)||[];return r+u.map((c,f)=>(c.slice(-1)===`
10
10
  `&&(c=c.slice(0,c.length-1)),(f>0?o:"")+c.trimRight())).join(`
@@ -23,7 +23,7 @@ if(typeof process<"u"){let{dirname:e}=await import("path"),{fileURLToPath:i}=awa
23
23
  import ReactDOM from "react-dom";
24
24
  `,Jf=e=>{let t=` ${e} `;ge(L.bgBlue(L.bold(L.white(t))),[],{preLines:1,postLines:1})},Qv=e=>{let t=` ${e} `;ge(L.bgRed(L.bold(L.white(t))))},nE=async(e="esm")=>{let t;switch(fr("dist")||await Vf("dist"),fr("dist/package.json")?t=JSON.parse(await Xf("dist/package.json","utf-8")):t={},e){case"esm":t.type="module";break;case"cjs":t.type="commonjs";break;default:return!1}return await Xm("dist/package.json",JSON.stringify(t,null,2)),!0},Yf=(e,t,r)=>{t=Mt(t);let n=yo(t);return{stdin:{contents:e,sourcefile:t,resolveDir:Zf(t),loader:r},outdir:void 0,outfile:n,splitting:!1}},Wf=async(e,t,r)=>{e=Mt(e),t=Mt(t);let o=["yarn tailwindcss",r?"":"--minify","--postcss postcss.config.js",`-i ${e}`,`-o ${t}`];fr(Mt(process.cwd(),"tailwind.config.js"))&&o.push("--config tailwind.config.js");let a=de({log:!1,stdio:"ignore"}),l=o.join(" "),{code:c,stdout:u,stderr:A}=await a.run(l);if(c!==0)throw new Error(`Building CSS bundle exited with code ${c} for ${e}.
25
25
  \rTried running: ${l}.
26
- \rError: ${u+A}`)},Ar=async({input:e="src/**/*",styles:t="src/components/index.css",target:r="esnext",format:n="esm",dev:i=!1,bundle:s=!1,standalone:o=!1,runtimeOnly:a=!1,jsOnly:l=!1,noWrite:c=!1,stdin:u=void 0,stdinFile:A=void 0,external:f=[]}={})=>{Uf.NODE_ENV=i?"development":"production";let y=Ae(Ar);i&&(a=!0),o&&(s=!0);let{cwd:_,srcDir:m,outDir:v}=Eo(),b=await bo(),O=JSON.parse(b),F={treeShaking:s,target:r,minify:!i,jsx:"transform",jsxFactory:"React.createElement",format:n,charset:"utf8",logLevel:i?"warning":"error",define:{"process.env.NODE_ENV":i?JSON.stringify("development"):JSON.stringify("production")}},ne=["esbuild","*.png"],S=Mt(_,"tsconfig.export.json"),K=fr(S),I=[];o||I.push(Of),n==="cjs"&&I.push(Pf);let w;if(s)switch(n){case"esm":w={js:Tn};break}let P={...F,tsconfig:K?S:void 0,bundle:s,splitting:n==="esm"&&s&&!u,absWorkingDir:_,outbase:"src",outdir:"dist",assetNames:"[name].js",format:n,target:"esnext",platform:O?.platform??"node",write:!c,external:s?[...ne,...f]:void 0,banner:w,plugins:I};y.log("Build options",P);let Z="";if(u){y.log("Building file from stdin",{stdin:u,stdinFile:A,noWrite:c}),A||(ge(L.red("ERROR: --stdin-file must be specified to emulate a file location when using stdin.")),process.exit(1)),typeof u=="string"&&u.length?Z=u:Z=await vo();let B={...F,sourcefile:A,loader:"tsx",banner:void 0,footer:void 0};if(c)return(await tE(Z,B)).code;{let R=Yf(Z,A,"tsx");await He(async()=>await Bo({...P,...R}),{start:"Building stdin to dist/.",success:"Built stdin to dist/.",error:"Error building stdin to dist/."}),ge(L.grey("Use --no-write to print to stdout instead."));return}}y.log("Building",{files:e,dev:i,runtimeOnly:a}),Jf(`${L.bold("TS Module")} [${Uf.NODE_ENV}]`);let d=wo.default.sync(e,{cwd:_}).filter(B=>Zm(B)!==".d.ts").map(B=>Mt(B));if(zm(e)){d.length||d.push(e);let B=e.replace(m,v).replace(gt,".js").replace(tt,".js");y.log("Cleaning emitted file:",{outfile:B}),await Gf(B,{force:!0})}else y.log("Cleaning old output:",{outDir:v}),await Gf(v,{force:!0,recursive:!0});let M=d.filter(B=>tt.test(B));y.log("Compiling TSX files:",{tsxJsxInput:M});let q=M.filter(B=>!B.endsWith(".d.ts"));await He(async()=>await Promise.all(q.map(async B=>{let R=await Xf(B,"utf-8"),le=rE+R,_e=Yf(le,B,"tsx");await Bo({...P,..._e})})),{start:"Compiling TSX files.",success:"Compiled TSX files.",error:"Failed to compile TSX files."});let ve=d.filter(B=>gt.test(B)).filter(B=>!tt.test(B));y.log("Compiling TS files:",{tsJsInput:ve}),await He(async()=>await Bo({...P,entryPoints:ve.filter(B=>!B.endsWith(".d.ts"))}),{start:"Compiling TS/JS files.",success:"Compiled TS/JS files.",error:"Failed to compile TS/JS files."});let p=d.filter(B=>!No.test(B));if(await He(async()=>{for(let B of p){let R=yo(B);y.log("Copying non-source file:",{file:B,emittedFile:R}),await Vf(Zf(R),{recursive:!0}),await Vm(B,R,Wm.COPYFILE_FICLONE)}},{start:"Copying non-source files to dist/.",success:"Copied non-source files to dist/.",error:"Failed to copy non-source files to dist/."}),!process.env.NO_REWRITES){let B=e.replace(m,v).replace(/^(\.\/)?src\//,"dist/").replace(gt,".js").replace(tt,".js");y.log("Normalizing import specifiers in emitted JS.",{emittedJs:B}),await He(async()=>await zr(B.endsWith(".js")?B:`${B}.js`),{start:"Normalizing import specifiers.",success:"Normalized import specifiers.",error:"Failed to normalize import specifiers."}),await zr(B.endsWith(".js")?B:`${B}.js`)}if(await nE(n)&&je({text:'Forced "type" package.json field in dist.',indent:2}).succeed(),!a){if(!l)if(fr(eE(t))){y.log("Building styles for production.");let{style:B="./dist/bundle.css"}=O;if(y.log("Building style bundle.",{bundleInput:t,bundleOutput:B,dev:i}),await He(async()=>await Wf(t,B,i),{start:"Bundling styles with Tailwind.",success:"Bundled styles with Tailwind.",error:"Failed to bundle styles."}),s){y.log("Bundling all styles.");let R=wo.default.sync("dist/**/*.css");await He(async()=>await Promise.all(R.map(async le=>await Wf(le,le,i))),{start:"Bundling emitted styles",success:`Bundled all styles to ${L.bold(B)}.`,error:"Failed to bundle styles."})}}else ge(),ge(L.grey("Bundle styles not found for this project.")),ge("Checked: "+L.bold(t)),ge();Jf("Running post-build setup."),await He(async()=>await Co(),{start:"Generating type declarations.",success:`Generated declarations for ${d.length} files.`,error:"Failed to generate type declarations."}),ge(),ge("Build complete.",["green"])}},Rv=async(e,t)=>await Ar({input:e,...t});var eA={"./package.json":"./package.json",".":"./dist/index.js","./*":"./dist/*/index.js"},zf={packageJson:{type:"module",platform:"node",engines:{node:">=14"},types:"dist/index.d.ts",files:["dist"],exports:eA,scripts:{dev:"tsmodule dev",build:"tsmodule build",test:"ava",pretest:"yarn build",prepublishOnly:"yarn test",lint:"eslint src --fix"}},files:[".github/**",".eslintrc",".gitignore","tsconfig.json","tsconfig.export.json","LICENSE","ava.config.mjs"],dependencies:[],devDependencies:["@types/node","@tsmodule/tsmodule","@typescript-eslint/eslint-plugin","@typescript-eslint/parser","ava","eslint","typescript"]},dt={default:zf,react:{packageJson:{platform:"browser",style:"dist/bundle.css",exports:{...eA,"./*":"./dist/components/*/index.js","./styles":"./dist/bundle.css","./styles/*":"./dist/components/*/index.css"},scripts:{export:"tsmodule build",dev:"next dev",build:"next build",start:"next start",lint:"next lint --fix",pretest:"tsmodule build --runtime-only",test:"ava",prepublishOnly:"yarn export && yarn test"}},files:[".github/**",".gitignore","next-env.d.ts","next.config.js","postcss.config.js","tailwind.config.js"],dependencies:["react@^18.2.0","react-dom@^18.2.0"],devDependencies:[...zf.devDependencies,"@types/react@^18.0.23","@types/react-dom@^18.0.7","eslint-config-next","@tsmodule/react","next","tailwindcss","autoprefixer","cssnano","postcss","postcss-import"]}};import{dirname as iE,resolve as tA}from"path";import{fileURLToPath as sE}from"url";import{readFile as oE}from"fs/promises";var pr=tA(iE(sE(import.meta.url)),".."),Pv=async()=>{let e=await oE(tA(pr,"package.json"),"utf-8");return JSON.parse(e)};import{resolve as iA}from"path";var rA=Pe(Zr(),1);import{copyFile as aE,mkdir as xo}from"fs/promises";import{dirname as lE,resolve as qt}from"path";var nA=e=>qt(pr,`./templates/${e}`),Qo=async({template:e,targetDir:t=process.cwd()})=>{let r=de(),n=nA(e),i=qt(t);await xo(i,{recursive:!0}),await r.run({posix:`cp -rf ${n}/. ${i}`,win32:`xcopy /E /I /Q /Y ${n}\\ ${i}\\`})},So=async({template:e,targetDir:t=process.cwd()})=>{let r=Ae(So);r.log("Copying template files",{template:e,targetDir:t});let n=nA(e),i=qt(t);await xo(i,{recursive:!0});let s=await(0,rA.default)(dt[e].files,{cwd:n,dot:!0});if(s.length)for(let o of s){let a=qt(n,o),l=qt(i,o);r.log({sourcePath:a,replacementPath:l}),await xo(lE(l),{recursive:!0}),await aE(a,l)}},hr=async({template:e,targetDir:t=process.cwd()})=>{let r=qt(t),n=dt[e].packageJson;return await In(r,n)},Dn=async({template:e,targetDir:t=process.cwd()})=>{let r=de({cwd:t}),n=[...dt.default.dependencies],i=[...dt.default.devDependencies];switch(e){case"react":n.push(...dt.react.dependencies),i.push(...dt.react.devDependencies);break}n.length&&await r.run(`yarn add ${n.join(" ")}`),i.length&&await r.run(`yarn add -D ${i.join(" ")}`)},Uv=async({template:e,targetDir:t=process.cwd()})=>{let r={template:"default",targetDir:t};if(await So(r),await hr(r),e!=="default"){let n={template:e,targetDir:t};await So(n),await hr(n)}await Dn({template:e,targetDir:t})};var tB=async(e,{react:t=!1})=>{let r=je({text:`Creating new module ${L.blueBright(e)}.`,indent:2}).start(),n={template:"default",targetDir:e};if(await Qo(n),await hr(n),t){let s={template:"react",targetDir:e};await Qo(s),await hr(s)}await In(iA(process.cwd(),e),{name:e}),r.succeed("Project created."),await Dn({template:"default",targetDir:e}),t&&await Dn({template:"react",targetDir:e}),r.succeed("Dependencies installed."),await de({cwd:iA(e),stdio:["ignore","ignore","inherit"]}).run("git init"),r.succeed("Set up as Git repository.")};import{relative as vE,resolve as BE}from"path";import{existsSync as wE}from"fs";import{lstat as xE}from"fs/promises";var wA=Pe(bA(),1);var vA=()=>{console.clear()},BA=e=>{jt(`
26
+ \rError: ${u+A}`)},Ar=async({input:e="src/**/*",styles:t="src/components/index.css",target:r="esnext",format:n="esm",dev:i=!1,bundle:s=!1,standalone:o=!1,runtimeOnly:a=!1,jsOnly:l=!1,noWrite:c=!1,stdin:u=void 0,stdinFile:A=void 0,external:f=[]}={})=>{Uf.NODE_ENV=i?"development":"production";let y=Ae(Ar);i&&(a=!0),o&&(s=!0);let{cwd:_,srcDir:m,outDir:v}=Eo(),b=await bo(),O=JSON.parse(b),F={treeShaking:s,target:r,minify:!i,jsx:"transform",jsxFactory:"React.createElement",format:n,charset:"utf8",logLevel:i?"warning":"error",define:{"process.env.NODE_ENV":i?JSON.stringify("development"):JSON.stringify("production")}},ne=["esbuild","*.png"],S=Mt(_,"tsconfig.export.json"),K=fr(S),I=[];o||I.push(Of),n==="cjs"&&I.push(Pf);let w;if(s)switch(n){case"esm":w={js:Tn};break}let P={...F,tsconfig:K?S:void 0,bundle:s,splitting:n==="esm"&&s&&!u,absWorkingDir:_,outbase:"src",outdir:"dist",assetNames:"[name].js",format:n,target:"esnext",platform:O?.platform??"node",write:!c,external:s?[...ne,...f]:void 0,banner:w,plugins:I};y.log("Build options",P);let Z="";if(u){y.log("Building file from stdin",{stdin:u,stdinFile:A,noWrite:c}),A||(ge(L.red("ERROR: --stdin-file must be specified to emulate a file location when using stdin.")),process.exit(1)),typeof u=="string"&&u.length?Z=u:Z=await vo();let B={...F,sourcefile:A,loader:"tsx",banner:void 0,footer:void 0};if(c)return(await tE(Z,B)).code;{let R=Yf(Z,A,"tsx");await He(async()=>await Bo({...P,...R}),{start:"Building stdin to dist/.",success:"Built stdin to dist/.",error:"Error building stdin to dist/."}),ge(L.grey("Use --no-write to print to stdout instead."));return}}y.log("Building",{files:e,dev:i,runtimeOnly:a}),Jf(`${L.bold("TS Module")} [${Uf.NODE_ENV}]`);let d=wo.default.sync(e,{cwd:_}).filter(B=>Zm(B)!==".d.ts").map(B=>Mt(B));if(zm(e)){d.length||d.push(e);let B=e.replace(m,v).replace(gt,".js").replace(tt,".js");y.log("Cleaning emitted file:",{outfile:B}),await Gf(B,{force:!0})}else y.log("Cleaning old output:",{outDir:v}),await Gf(v,{force:!0,recursive:!0});let M=d.filter(B=>tt.test(B));y.log("Compiling TSX files:",{tsxJsxInput:M});let q=M.filter(B=>!B.endsWith(".d.ts"));await He(async()=>await Promise.all(q.map(async B=>{let R=await Xf(B,"utf-8"),le=rE+R,_e=Yf(le,B,"tsx");await Bo({...P,..._e})})),{start:"Compiling TSX files.",success:"Compiled TSX files.",error:"Failed to compile TSX files."});let ve=d.filter(B=>gt.test(B)).filter(B=>!tt.test(B));y.log("Compiling TS files:",{tsJsInput:ve}),await He(async()=>await Bo({...P,entryPoints:ve.filter(B=>!B.endsWith(".d.ts"))}),{start:"Compiling TS/JS files.",success:"Compiled TS/JS files.",error:"Failed to compile TS/JS files."});let p=d.filter(B=>!No.test(B));if(await He(async()=>{for(let B of p){let R=yo(B);y.log("Copying non-source file:",{file:B,emittedFile:R}),await Vf(Zf(R),{recursive:!0}),await Vm(B,R,Wm.COPYFILE_FICLONE)}},{start:"Copying non-source files to dist/.",success:"Copied non-source files to dist/.",error:"Failed to copy non-source files to dist/."}),!process.env.NO_REWRITES){let B=e.replace(m,v).replace(/^(\.\/)?src\//,"dist/").replace(gt,".js").replace(tt,".js");y.log("Normalizing import specifiers in emitted JS.",{emittedJs:B}),await He(async()=>await zr(B.endsWith(".js")?B:`${B}.js`),{start:"Normalizing import specifiers.",success:"Normalized import specifiers.",error:"Failed to normalize import specifiers."}),await zr(B.endsWith(".js")?B:`${B}.js`)}if(await nE(n)&&je({text:'Forced "type" package.json field in dist.',indent:2}).succeed(),!a){if(!l)if(fr(eE(t))){y.log("Building styles for production.");let{style:B="./dist/bundle.css"}=O;if(y.log("Building style bundle.",{bundleInput:t,bundleOutput:B,dev:i}),await He(async()=>await Wf(t,B,i),{start:"Bundling styles with Tailwind.",success:"Bundled styles with Tailwind.",error:"Failed to bundle styles."}),s){y.log("Bundling all styles.");let R=wo.default.sync("dist/**/*.css");await He(async()=>await Promise.all(R.map(async le=>await Wf(le,le,i))),{start:"Bundling emitted styles",success:`Bundled all styles to ${L.bold(B)}.`,error:"Failed to bundle styles."})}}else ge(),ge(L.grey("Bundle styles not found for this project.")),ge("Checked: "+L.bold(t)),ge();Jf("Running post-build setup."),await He(async()=>await Co(),{start:"Generating type declarations.",success:`Generated declarations for ${d.length} files.`,error:"Failed to generate type declarations."}),ge(),ge("Build complete.",["green"])}},Rv=async(e,t)=>await Ar({input:e,...t});var eA={"./package.json":"./package.json",".":"./dist/index.js","./*":"./dist/*/index.js"},zf={packageJson:{type:"module",platform:"node",engines:{node:">=14"},types:"dist/index.d.ts",files:["dist"],exports:eA,scripts:{dev:"tsmodule dev",build:"tsmodule build",test:"ava",pretest:"yarn build",prepublishOnly:"yarn test",lint:"eslint src --fix"}},files:[".github/**",".eslintrc",".gitignore","tsconfig.json","tsconfig.export.json","LICENSE","ava.config.mjs"],dependencies:[],devDependencies:["@types/node","@tsmodule/tsmodule","@typescript-eslint/eslint-plugin","@typescript-eslint/parser","ava","eslint","typescript"]},dt={default:zf,react:{packageJson:{platform:"browser",style:"dist/bundle.css",exports:{...eA,"./*":"./dist/components/*/index.js","./styles":"./dist/bundle.css","./styles/*":"./dist/components/*/index.css"},scripts:{export:"tsmodule build",dev:"next dev",build:"next build",start:"next start",lint:"next lint --fix",pretest:"tsmodule build --runtime-only",test:"ava",prepublishOnly:"yarn test && yarn export"}},files:[".github/**",".gitignore","next-env.d.ts","next.config.js","postcss.config.js","tailwind.config.js"],dependencies:["react@^18.2.0","react-dom@^18.2.0"],devDependencies:[...zf.devDependencies,"@types/react@^18.0.23","@types/react-dom@^18.0.7","eslint-config-next","@tsmodule/react","next","tailwindcss","autoprefixer","cssnano","postcss","postcss-import"]}};import{dirname as iE,resolve as tA}from"path";import{fileURLToPath as sE}from"url";import{readFile as oE}from"fs/promises";var pr=tA(iE(sE(import.meta.url)),".."),Pv=async()=>{let e=await oE(tA(pr,"package.json"),"utf-8");return JSON.parse(e)};import{resolve as iA}from"path";var rA=Pe(Zr(),1);import{copyFile as aE,mkdir as xo}from"fs/promises";import{dirname as lE,resolve as qt}from"path";var nA=e=>qt(pr,`./templates/${e}`),Qo=async({template:e,targetDir:t=process.cwd()})=>{let r=de(),n=nA(e),i=qt(t);await xo(i,{recursive:!0}),await r.run({posix:`cp -rf ${n}/. ${i}`,win32:`xcopy /E /I /Q /Y ${n}\\ ${i}\\`})},So=async({template:e,targetDir:t=process.cwd()})=>{let r=Ae(So);r.log("Copying template files",{template:e,targetDir:t});let n=nA(e),i=qt(t);await xo(i,{recursive:!0});let s=await(0,rA.default)(dt[e].files,{cwd:n,dot:!0});if(s.length)for(let o of s){let a=qt(n,o),l=qt(i,o);r.log({sourcePath:a,replacementPath:l}),await xo(lE(l),{recursive:!0}),await aE(a,l)}},hr=async({template:e,targetDir:t=process.cwd()})=>{let r=qt(t),n=dt[e].packageJson;return await In(r,n)},Dn=async({template:e,targetDir:t=process.cwd()})=>{let r=de({cwd:t}),n=[...dt.default.dependencies],i=[...dt.default.devDependencies];switch(e){case"react":n.push(...dt.react.dependencies),i.push(...dt.react.devDependencies);break}n.length&&await r.run(`yarn add ${n.join(" ")}`),i.length&&await r.run(`yarn add -D ${i.join(" ")}`)},Uv=async({template:e,targetDir:t=process.cwd()})=>{let r={template:"default",targetDir:t};if(await So(r),await hr(r),e!=="default"){let n={template:e,targetDir:t};await So(n),await hr(n)}await Dn({template:e,targetDir:t})};var tB=async(e,{react:t=!1})=>{let r=je({text:`Creating new module ${L.blueBright(e)}.`,indent:2}).start(),n={template:"default",targetDir:e};if(await Qo(n),await hr(n),t){let s={template:"react",targetDir:e};await Qo(s),await hr(s)}await In(iA(process.cwd(),e),{name:e}),r.succeed("Project created."),await Dn({template:"default",targetDir:e}),t&&await Dn({template:"react",targetDir:e}),r.succeed("Dependencies installed."),await de({cwd:iA(e),stdio:["ignore","ignore","inherit"]}).run("git init"),r.succeed("Set up as Git repository.")};import{relative as vE,resolve as BE}from"path";import{existsSync as wE}from"fs";import{lstat as xE}from"fs/promises";var wA=Pe(bA(),1);var vA=()=>{console.clear()},BA=e=>{jt(`
27
27
  `,L.gray(`Built ${L.bold(e)}.`),`
28
28
  `,L.blue(new Date().toLocaleString()))},hB=async({format:e="esm"})=>{let t=process.cwd(),r=de();process.platform!=="win32"&&await r.run("clear"),vA(),await Ar({format:e,dev:!0}),BA("src/**/*"),(0,wA.default)(BE(t,"src"),{recursive:!0}).on("change",async(n,i)=>{if(!wE(i)||(await xE(i)).isDirectory())return;vA();let l=Date.now();try{await Ar({dev:!0,runtimeOnly:!0,input:i})}catch(u){jt("ERROR:",u)}let c=Date.now()-l;je({text:L.blueBright(`Dev refresh finished in ${L.bold(`${c}ms`)}.`),indent:2}).succeed(),BA(vE(t,i))})};import{pathToFileURL as SE}from"url";import{resolve as QE}from"path";var yB=async()=>{let e=QE(pr,"dist/loader/index.js"),t=["--no-warnings","--loader",SE(e).href,...process.argv.slice(2)],r=de({stdio:"inherit"}),{code:n}=await r.run(`node ${t.join(" ")}`);process.exit(n??0)};export{L as a,Pm as b,zr as c,Jf as d,Qv as e,Ar as f,Rv as g,dt as h,Pv as i,Uv as j,tB as k,hB as l,yB as m};
29
29
  /*!
package/dist/index.js CHANGED
@@ -3,4 +3,4 @@
3
3
  if(typeof process<"u"){let{dirname:e}=await import("path"),{fileURLToPath:i}=await import("url");globalThis.__filename=i(import.meta.url),globalThis.__dirname=e(globalThis.__filename);let{default:a}=await import("module");globalThis.require=a.createRequire(import.meta.url)}
4
4
  /** __ESM_SHIM_END */
5
5
 
6
- import{c as o,d as r,e,f,g as m,h as p,k as t,l as x,m as a}from"./chunk-U5LAIS5T.js";import"./chunk-SXU4PYPZ.js";export{e as bannerError,r as bannerLog,f as build,m as buildCommand,t as create,x as dev,a as execute,o as normalizeImportSpecifiers,p as specification};
6
+ import{c as o,d as r,e,f,g as m,h as p,k as t,l as x,m as a}from"./chunk-MASZ6UKV.js";import"./chunk-SXU4PYPZ.js";export{e as bannerError,r as bannerLog,f as build,m as buildCommand,t as create,x as dev,a as execute,o as normalizeImportSpecifiers,p as specification};
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@tsmodule/tsmodule",
3
3
  "platform": "node",
4
4
  "type": "module",
5
- "version": "41.26.0",
5
+ "version": "41.27.0",
6
6
  "repository": "tsmodule/tsmodule",
7
7
  "description": "TypeScript Module loader and compiler",
8
8
  "license": "MIT",
@@ -1,15 +0,0 @@
1
- node_modules
2
-
3
- # Potential Firebase / GCP credentials.
4
- service-account.json
5
-
6
- # Emitted output.
7
- dist/
8
-
9
- # Incremental TS build info.
10
- *.tsbuildinfo
11
-
12
- .env
13
- .env.*
14
-
15
- yarn-error.log
@@ -1,16 +0,0 @@
1
- node_modules
2
-
3
- # Potential Firebase / GCP credentials.
4
- service-account.json
5
-
6
- # Emitted output.
7
- dist/
8
- .next/
9
-
10
- # Incremental TS build info.
11
- *.tsbuildinfo
12
-
13
- .env
14
- .env.*
15
-
16
- yarn-error.log