@tsmodule/tsmodule 41.9.0 → 41.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
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
 
5
- import{a as L,b as R,d as B,f as U,h as J,i as G,j as K,k as z,l as Y}from"./chunk-FS2JVFNA.js";import{a as w,b,c as fe,d}from"./chunk-UCISWLJO.js";var E=b(H=>{var x=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 x{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};H.CommanderError=x;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,M){if(M){let de=`${m.padEnd(i+r)}${M}`;return t.wrap(de,n-s,i+r)}return m}function o(m){return m.join(`
5
+ import{a as L,b as R,d as B,f as U,h as J,i as G,j as K,k as z,l as Y}from"./chunk-Z3HCFUI4.js";import{a as w,b,c as fe,d}from"./chunk-UCISWLJO.js";var E=b(H=>{var x=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 x{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};H.CommanderError=x;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,M){if(M){let de=`${m.padEnd(i+r)}${M}`;return t.wrap(de,n-s,i+r)}return m}function o(m){return m.join(`
6
6
  `).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(`
7
7
  `)}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)===`
8
8
  `&&(c=c.slice(0,c.length-1)),(f>0?o:"")+c.trimRight())).join(`
@@ -15,12 +15,12 @@ import{a as x,b as d,c as De,d as D,e as le,f as he,g as ht,i as Ze,j as So}from
15
15
  $ ${o} ${a.join(" ")}
16
16
  `)),await new Promise((u,f)=>{n=SE(o,a,i);let l="",A="";if(!n)throw new Error("Child process was not set.");let c=C=>{n=null;let _={code:C,stdout:l,stderr:A};C===0||C===1&&!so?u(_):f(_)};n.stdout?.on("data",C=>{l+=C.toString()}),n.stderr?.on("data",C=>{A+=C.toString()}),n.on("close",c),n.on("exit",c),n.on("error",c),n.stdout?.pipe(process.stdout),n.stderr?.pipe(process.stderr)})},kill(s="SIGKILL"){if(n?.pid)if(so)QE(`taskkill /t /f /pid ${n.pid}`);else return process.kill(-n.pid,s);return!0}}};import{extname as IC,resolve as ao}from"path";var uo=()=>{let e=process.cwd(),t=ao(e,"src"),r=ao(e,"dist");return{cwd:e,srcDir:t,outDir:r}},lo=e=>{e=ao(e);let{srcDir:t,outDir:r}=uo();return e.replace(t,r).replace(ht,".js").replace(Ze,".js")};var WE={moduleResolution:"Node",module:"ESNext",target:"ESNext",esModuleInterop:!0,incremental:!1,rootDir:"src",outDir:"dist",declaration:!0,noEmit:!1,emitDeclarationOnly:!0},fo=async()=>{let e=le(fo),t=Ae({log:!1}),i=`yarn tsc -p tsconfig.json ${Object.entries(WE).map(([n,s])=>`--${n} ${s}`).join(" ")}`;e.log(`Calling: ${i}`),await t.run(i)};import{readFile as VE,writeFile as XE}from"fs/promises";import{resolve as fc}from"path";var co=async(e=process.cwd())=>{let t=fc(e,"package.json");return await VE(t,"utf-8")},ZE=async(e=process.cwd())=>{let t=await co(e);return JSON.parse(t)},Bi=async(e=process.cwd(),t)=>{let r=fc(e,"package.json"),i=await ZE(e);return Object.assign(i,t),await XE(r,JSON.stringify(i,null,2),"utf-8"),i};import{readFileSync as zE}from"fs";function e0(e){return new Promise((t,r)=>{let i=[];function n(u){i.push(u)}function s(){a(),t(Buffer.concat(i))}function o(u){a(),r(u)}function a(){e.removeListener("data",n),e.removeListener("end",s),e.removeListener("error",o)}e.on("data",n),e.on("end",s),e.on("error",o)})}var Ao=async()=>{let e=le(Ao);e.log("Reading stdin");try{let r=zE(0).toString();if(r)return e.log("Found stdin",{stdin:r}),r}catch(r){e.log("Could not read stdin",{e:r})}return he(D.gray("Type your source code. Press Ctrl+D to finish.")),(await e0(process.stdin)).toString()};var Me=async(e,t)=>{let r=Fe(t.start);try{await e(),r.succeed(t.success)}catch(i){throw r.fail(t.error),i}};var cc={name:"relative-externs",setup(e){e.onResolve({filter:/^\.\.?\//},({path:t,importer:r})=>r.includes("node_modules")?null:{path:t,external:!0})}};var u0=`import React from "react";
17
17
  import ReactDOM from "react-dom";
18
- `,pc=e=>{let t=` ${e} `;he(D.bgBlue(D.bold(D.white(t))))},db=e=>{let t=` ${e} `;he(D.bgRed(D.bold(D.white(t))))},l0=async()=>{let e;if(ar("dist")||await _c("dist"),ar("dist/package.json")?e=JSON.parse(await Ec("dist/package.json","utf-8")):e={},e?.module==="module")return!0;e.type="module",await i0("dist/package.json",JSON.stringify(e,null,2))},dc=(e,t,r)=>{t=Pt(t);let i=lo(t);return{stdin:{contents:e,sourcefile:t,resolveDir:mc(t),loader:r},outdir:void 0,outfile:i}},gc=async(e,t,r)=>{e=Pt(e),t=Pt(t);let o=["yarn tailwindcss",r?"":"--minify","--postcss postcss.config.js",`-i ${e}`,`-o ${t}`];ar(Pt(process.cwd(),"tailwind.config.js"))&&o.push("--config tailwind.config.js");let a=Ae({log:!1,stdio:"ignore"}),u=o.join(" "),{code:f,stdout:l,stderr:A}=await a.run(u);if(f!==0)throw new Error(`Building CSS bundle exited with code ${f} for ${e}.
18
+ `,pc=e=>{let t=` ${e} `;he(D.bgBlue(D.bold(D.white(t))))},db=e=>{let t=` ${e} `;he(D.bgRed(D.bold(D.white(t))))},l0=async()=>{let e;if(ar("dist")||await _c("dist"),ar("dist/package.json")?e=JSON.parse(await Ec("dist/package.json","utf-8")):e={},e?.module==="module")return!0;e.type="module",await i0("dist/package.json",JSON.stringify(e,null,2))},dc=(e,t,r)=>{t=Pt(t);let i=lo(t);return{stdin:{contents:e,sourcefile:t,resolveDir:mc(t),loader:r},outdir:void 0,outfile:i,splitting:!1}},gc=async(e,t,r)=>{e=Pt(e),t=Pt(t);let o=["yarn tailwindcss",r?"":"--minify","--postcss postcss.config.js",`-i ${e}`,`-o ${t}`];ar(Pt(process.cwd(),"tailwind.config.js"))&&o.push("--config tailwind.config.js");let a=Ae({log:!1,stdio:"ignore"}),u=o.join(" "),{code:f,stdout:l,stderr:A}=await a.run(u);if(f!==0)throw new Error(`Building CSS bundle exited with code ${f} for ${e}.
19
19
  \rTried running: ${u}.
20
20
  \rError: ${l+A}`)},f0=`
21
21
  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)}
22
- `,ur=async({input:e="src/**/*",styles:t="src/components/index.css",target:r="esnext",dev:i=!1,bundle:n=!1,standalone:s=!1,runtimeOnly:o=!1,jsOnly:a=!1,noWrite:u=!1,stdin:f=void 0,stdinFile:l=void 0}={})=>{hc.NODE_ENV=i?"development":"production";let A=le(ur);i&&(o=!0),s&&(n=!0);let{cwd:c,srcDir:C,outDir:_}=uo(),E=await co(),v=JSON.parse(E),b={treeShaking:n,target:r,minify:!i,jsx:"transform",jsxFactory:"React.createElement",format:"esm",charset:"utf8",logLevel:i?"warning":"error",define:{"process.env.NODE_ENV":i?JSON.stringify("development"):JSON.stringify("production")}},L=["esbuild","*.png"],F=Pt(c,"tsconfig.export.json"),ee=ar(F),S=[];s||S.push(cc);let M={...b,tsconfig:ee?F:void 0,bundle:n,splitting:s,absWorkingDir:c,outbase:"src",outdir:"dist",assetNames:"[name].js",format:"esm",target:"esnext",platform:v?.platform??"node",write:!u,external:n?L:void 0,banner:n?{js:f0}:void 0,plugins:S};A.log("Build options",M);let R="";if(f){A.log("Building file from stdin",{stdin:f,stdinFile:l,noWrite:u}),l||(he(D.red("ERROR: --stdin-file must be specified to emulate a file location when using stdin.")),process.exit(1)),typeof f=="string"&&f.length?R=f:R=await Ao();let w={...b,sourcefile:l,loader:"tsx",banner:void 0,footer:void 0};if(u)return(await a0(R,w)).code;{let h=dc(R,l,"tsx");await Me(async()=>await ho({...M,...h}),{start:"Building stdin to dist/.",success:"Built stdin to dist/.",error:"Error building stdin to dist/."}),he(D.grey("Use --no-write to print to stdout instead."));return}}A.log("Building",{files:e,dev:i,runtimeOnly:o}),pc(`${D.bold("TS Module")} [${hc.NODE_ENV}]`);let B=po.default.sync(e,{cwd:c}).filter(w=>n0(w)!==".d.ts").map(w=>Pt(w));if(s0(e)){B.length||B.push(e);let w=e.replace(C,_).replace(ht,".js").replace(Ze,".js");A.log("Cleaning emitted file:",{outfile:w}),await Ac(w,{force:!0})}else A.log("Cleaning old output:",{outDir:_}),await Ac(_,{force:!0,recursive:!0});let P=B.filter(w=>Ze.test(w));A.log("Compiling TSX files:",{tsxJsxInput:P});let Z=P.filter(w=>!w.endsWith(".d.ts"));await Me(async()=>await Promise.all(Z.map(async w=>{let h=await Ec(w,"utf-8"),p=u0+h,re=dc(p,w,"tsx");await ho({...M,...re})})),{start:"Compiling TSX files.",success:"Compiled TSX files.",error:"Failed to compile TSX files."});let g=B.filter(w=>ht.test(w)).filter(w=>!Ze.test(w));A.log("Compiling TS files:",{tsJsInput:g}),await Me(async()=>await ho({...M,entryPoints:g.filter(w=>!w.endsWith(".d.ts"))}),{start:"Compiling TS/JS files.",success:"Compiled TS/JS files.",error:"Failed to compile TS/JS files."});let H=B.filter(w=>!So.test(w));if(await Me(async()=>{for(let w of H){let h=lo(w);A.log("Copying non-source file:",{file:w,emittedFile:h}),await _c(mc(h),{recursive:!0}),await r0(w,h,t0.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 w=e.replace(C,_).replace(/^(\.\/)?src\//,"dist/").replace(ht,".js").replace(Ze,".js");A.log("Normalizing import specifiers in emitted JS.",{emittedJs:w}),await Me(async()=>await Jr(w.endsWith(".js")?w:`${w}.js`),{start:"Normalizing import specifiers.",success:"Normalized import specifiers.",error:"Failed to normalize import specifiers."}),await Jr(w.endsWith(".js")?w:`${w}.js`)}if(await l0()&&Fe('Forced "type": "module" in output.').succeed(),!o){if(!a)if(ar(o0(t))){A.log("Building styles for production.");let{style:w="./dist/bundle.css"}=v;if(A.log("Building style bundle.",{bundleInput:t,bundleOutput:w,dev:i}),await Me(async()=>await gc(t,w,i),{start:"Bundling styles with Tailwind.",success:"Bundled styles with Tailwind.",error:"Failed to bundle styles."}),n){A.log("Bundling all styles.");let h=po.default.sync("dist/**/*.css");await Me(async()=>await Promise.all(h.map(async p=>await gc(p,p,i))),{start:"Bundling emitted styles",success:`Bundled all styles to ${D.bold(w)}.`,error:"Failed to bundle styles."})}}else he(D.grey(`Bundle styles not found for this project.
23
- \rChecked: `+D.bold(t)));pc("Running post-build setup."),await Me(async()=>await fo(),{start:"Generating type declarations.",success:`Generated declarations for ${B.length} files.`,error:"Failed to generate type declarations."}),he(D.green("Build complete."))}},gb=async(e,t)=>await ur({input:e,...t});var Cc={"./package.json":"./package.json",".":"./dist/index.js","./*":"./dist/*/index.js"},yc={packageJson:{type:"module",platform:"node",engines:{node:">=14"},types:"dist/index.d.ts",files:["dist"],exports:Cc,scripts:{dev:"tsmodule dev",build:"tsmodule build",test:"ava",pretest:"tsmodule 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"]},At={default:yc,react:{packageJson:{platform:"browser",style:"dist/bundle.css",exports:{...Cc,"./*":"./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:[...yc.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 c0,resolve as bc}from"path";import{fileURLToPath as A0}from"url";import{readFile as h0}from"fs/promises";var lr=bc(c0(A0(import.meta.url)),".."),vb=async()=>{let e=await h0(bc(lr,"package.json"),"utf-8");return JSON.parse(e)};import{resolve as wc}from"path";var vc=De(Gr(),1);import{copyFile as p0,mkdir as go}from"fs/promises";import{dirname as d0,resolve as Nt}from"path";var Bc=e=>Nt(lr,`./templates/${e}`),Eo=async({template:e,targetDir:t=process.cwd()})=>{let r=Ae(),i=Bc(e),n=Nt(t);await go(n,{recursive:!0}),await r.run({posix:`cp -rf ${i}/. ${n}`,win32:`xcopy /E /I /Q /Y ${i}\\ ${n}\\`})},_o=async({template:e,targetDir:t=process.cwd()})=>{let r=le(_o);r.log("Copying template files",{template:e,targetDir:t});let i=Bc(e),n=Nt(t);await go(n,{recursive:!0});let s=await(0,vc.default)(At[e].files,{cwd:i,dot:!0});if(s.length)for(let o of s){let a=Nt(i,o),u=Nt(n,o);r.log({sourcePath:a,replacementPath:u}),await go(d0(u),{recursive:!0}),await p0(a,u)}},fr=async({template:e,targetDir:t=process.cwd()})=>{let r=Nt(t),i=At[e].packageJson;return await Bi(r,i)},wi=async({template:e,targetDir:t=process.cwd()})=>{let r=Ae({cwd:t}),i=[...At.default.dependencies],n=[...At.default.devDependencies];switch(e){case"react":i.push(...At.react.dependencies),n.push(...At.react.devDependencies);break}i.length&&await r.run(`yarn add ${i.join(" ")}`),n.length&&await r.run(`yarn add -D ${n.join(" ")}`)},Db=async({template:e,targetDir:t=process.cwd()})=>{let r={template:"default",targetDir:t};if(await _o(r),await fr(r),e!=="default"){let i={template:e,targetDir:t};await _o(i),await fr(i)}await wi({template:e,targetDir:t})};var Hb=async(e,{react:t=!1})=>{let r=Fe(`Creating new module ${D.blueBright(e)}.`).start(),i={template:"default",targetDir:e};if(await Eo(i),await fr(i),t){let s={template:"react",targetDir:e};await Eo(s),await fr(s)}await Bi(wc(process.cwd(),e),{name:e}),r.succeed("Project created."),await wi({template:"default",targetDir:e}),t&&await wi({template:"react",targetDir:e}),r.succeed("Dependencies installed."),await Ae({cwd:wc(e),stdio:["ignore","ignore","inherit"]}).run("git init"),r.succeed("Set up as Git repository.")};import{relative as I0,resolve as T0}from"path";import{existsSync as k0}from"fs";import{lstat as D0}from"fs/promises";var Gc=De(Kc(),1);var Uc=()=>{console.clear()},$c=e=>{he(`
22
+ `,ur=async({input:e="src/**/*",styles:t="src/components/index.css",target:r="esnext",dev:i=!1,bundle:n=!1,standalone:s=!1,runtimeOnly:o=!1,jsOnly:a=!1,noWrite:u=!1,stdin:f=void 0,stdinFile:l=void 0}={})=>{hc.NODE_ENV=i?"development":"production";let A=le(ur);i&&(o=!0),s&&(n=!0);let{cwd:c,srcDir:C,outDir:_}=uo(),E=await co(),v=JSON.parse(E),b={treeShaking:n,target:r,minify:!i,jsx:"transform",jsxFactory:"React.createElement",format:"esm",charset:"utf8",logLevel:i?"warning":"error",define:{"process.env.NODE_ENV":i?JSON.stringify("development"):JSON.stringify("production")}},L=["esbuild","*.png"],F=Pt(c,"tsconfig.export.json"),ee=ar(F),S=[];s||S.push(cc);let M={...b,tsconfig:ee?F:void 0,bundle:n,splitting:n&&!f,absWorkingDir:c,outbase:"src",outdir:"dist",assetNames:"[name].js",format:"esm",target:"esnext",platform:v?.platform??"node",write:!u,external:n?L:void 0,banner:n?{js:f0}:void 0,plugins:S};A.log("Build options",M);let R="";if(f){A.log("Building file from stdin",{stdin:f,stdinFile:l,noWrite:u}),l||(he(D.red("ERROR: --stdin-file must be specified to emulate a file location when using stdin.")),process.exit(1)),typeof f=="string"&&f.length?R=f:R=await Ao();let w={...b,sourcefile:l,loader:"tsx",banner:void 0,footer:void 0};if(u)return(await a0(R,w)).code;{let h=dc(R,l,"tsx");await Me(async()=>await ho({...M,...h}),{start:"Building stdin to dist/.",success:"Built stdin to dist/.",error:"Error building stdin to dist/."}),he(D.grey("Use --no-write to print to stdout instead."));return}}A.log("Building",{files:e,dev:i,runtimeOnly:o}),pc(`${D.bold("TS Module")} [${hc.NODE_ENV}]`);let B=po.default.sync(e,{cwd:c}).filter(w=>n0(w)!==".d.ts").map(w=>Pt(w));if(s0(e)){B.length||B.push(e);let w=e.replace(C,_).replace(ht,".js").replace(Ze,".js");A.log("Cleaning emitted file:",{outfile:w}),await Ac(w,{force:!0})}else A.log("Cleaning old output:",{outDir:_}),await Ac(_,{force:!0,recursive:!0});let P=B.filter(w=>Ze.test(w));A.log("Compiling TSX files:",{tsxJsxInput:P});let Z=P.filter(w=>!w.endsWith(".d.ts"));await Me(async()=>await Promise.all(Z.map(async w=>{let h=await Ec(w,"utf-8"),p=u0+h,re=dc(p,w,"tsx");await ho({...M,...re})})),{start:"Compiling TSX files.",success:"Compiled TSX files.",error:"Failed to compile TSX files."});let g=B.filter(w=>ht.test(w)).filter(w=>!Ze.test(w));A.log("Compiling TS files:",{tsJsInput:g}),await Me(async()=>await ho({...M,entryPoints:g.filter(w=>!w.endsWith(".d.ts"))}),{start:"Compiling TS/JS files.",success:"Compiled TS/JS files.",error:"Failed to compile TS/JS files."});let H=B.filter(w=>!So.test(w));if(await Me(async()=>{for(let w of H){let h=lo(w);A.log("Copying non-source file:",{file:w,emittedFile:h}),await _c(mc(h),{recursive:!0}),await r0(w,h,t0.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 w=e.replace(C,_).replace(/^(\.\/)?src\//,"dist/").replace(ht,".js").replace(Ze,".js");A.log("Normalizing import specifiers in emitted JS.",{emittedJs:w}),await Me(async()=>await Jr(w.endsWith(".js")?w:`${w}.js`),{start:"Normalizing import specifiers.",success:"Normalized import specifiers.",error:"Failed to normalize import specifiers."}),await Jr(w.endsWith(".js")?w:`${w}.js`)}if(await l0()&&Fe('Forced "type": "module" in output.').succeed(),!o){if(!a)if(ar(o0(t))){A.log("Building styles for production.");let{style:w="./dist/bundle.css"}=v;if(A.log("Building style bundle.",{bundleInput:t,bundleOutput:w,dev:i}),await Me(async()=>await gc(t,w,i),{start:"Bundling styles with Tailwind.",success:"Bundled styles with Tailwind.",error:"Failed to bundle styles."}),n){A.log("Bundling all styles.");let h=po.default.sync("dist/**/*.css");await Me(async()=>await Promise.all(h.map(async p=>await gc(p,p,i))),{start:"Bundling emitted styles",success:`Bundled all styles to ${D.bold(w)}.`,error:"Failed to bundle styles."})}}else he(D.grey(`Bundle styles not found for this project.
23
+ \rChecked: `+D.bold(t)));pc("Running post-build setup."),await Me(async()=>await fo(),{start:"Generating type declarations.",success:`Generated declarations for ${B.length} files.`,error:"Failed to generate type declarations."}),he(D.green("Build complete."))}},gb=async(e,t)=>await ur({input:e,...t});var Cc={"./package.json":"./package.json",".":"./dist/index.js","./*":"./dist/*/index.js"},yc={packageJson:{type:"module",platform:"node",engines:{node:">=14"},types:"dist/index.d.ts",files:["dist"],exports:Cc,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"]},At={default:yc,react:{packageJson:{platform:"browser",style:"dist/bundle.css",exports:{...Cc,"./*":"./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:[...yc.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 c0,resolve as bc}from"path";import{fileURLToPath as A0}from"url";import{readFile as h0}from"fs/promises";var lr=bc(c0(A0(import.meta.url)),".."),vb=async()=>{let e=await h0(bc(lr,"package.json"),"utf-8");return JSON.parse(e)};import{resolve as wc}from"path";var vc=De(Gr(),1);import{copyFile as p0,mkdir as go}from"fs/promises";import{dirname as d0,resolve as Nt}from"path";var Bc=e=>Nt(lr,`./templates/${e}`),Eo=async({template:e,targetDir:t=process.cwd()})=>{let r=Ae(),i=Bc(e),n=Nt(t);await go(n,{recursive:!0}),await r.run({posix:`cp -rf ${i}/. ${n}`,win32:`xcopy /E /I /Q /Y ${i}\\ ${n}\\`})},_o=async({template:e,targetDir:t=process.cwd()})=>{let r=le(_o);r.log("Copying template files",{template:e,targetDir:t});let i=Bc(e),n=Nt(t);await go(n,{recursive:!0});let s=await(0,vc.default)(At[e].files,{cwd:i,dot:!0});if(s.length)for(let o of s){let a=Nt(i,o),u=Nt(n,o);r.log({sourcePath:a,replacementPath:u}),await go(d0(u),{recursive:!0}),await p0(a,u)}},fr=async({template:e,targetDir:t=process.cwd()})=>{let r=Nt(t),i=At[e].packageJson;return await Bi(r,i)},wi=async({template:e,targetDir:t=process.cwd()})=>{let r=Ae({cwd:t}),i=[...At.default.dependencies],n=[...At.default.devDependencies];switch(e){case"react":i.push(...At.react.dependencies),n.push(...At.react.devDependencies);break}i.length&&await r.run(`yarn add ${i.join(" ")}`),n.length&&await r.run(`yarn add -D ${n.join(" ")}`)},Db=async({template:e,targetDir:t=process.cwd()})=>{let r={template:"default",targetDir:t};if(await _o(r),await fr(r),e!=="default"){let i={template:e,targetDir:t};await _o(i),await fr(i)}await wi({template:e,targetDir:t})};var Hb=async(e,{react:t=!1})=>{let r=Fe(`Creating new module ${D.blueBright(e)}.`).start(),i={template:"default",targetDir:e};if(await Eo(i),await fr(i),t){let s={template:"react",targetDir:e};await Eo(s),await fr(s)}await Bi(wc(process.cwd(),e),{name:e}),r.succeed("Project created."),await wi({template:"default",targetDir:e}),t&&await wi({template:"react",targetDir:e}),r.succeed("Dependencies installed."),await Ae({cwd:wc(e),stdio:["ignore","ignore","inherit"]}).run("git init"),r.succeed("Set up as Git repository.")};import{relative as I0,resolve as T0}from"path";import{existsSync as k0}from"fs";import{lstat as D0}from"fs/promises";var Gc=De(Kc(),1);var Uc=()=>{console.clear()},$c=e=>{he(`
24
24
  `,D.gray(`Built ${D.bold(e)}.`),`
25
25
  `,D.blue(new Date().toLocaleString()))},tv=async()=>{let e=process.cwd(),t=Ae();process.platform!=="win32"&&await t.run("clear"),Uc(),await ur({dev:!0}),$c("src/**/*"),(0,Gc.default)(T0(e,"src"),{recursive:!0}).on("change",async(r,i)=>{if(!k0(i)||(await D0(i)).isDirectory())return;Uc();let a=Date.now();try{await ur({dev:!0,runtimeOnly:!0,input:i})}catch(f){he("ERROR:",f)}let u=Date.now()-a;Fe(D.blueBright(`Dev refresh finished in ${D.bold(`${u}ms`)}.`)).succeed(),$c(I0(e,i))})};import{pathToFileURL as L0}from"url";import{resolve as O0}from"path";var av=async()=>{let e=O0(lr,"dist/loader/index.js"),t=["--no-warnings","--loader",L0(e).href,...process.argv.slice(2)],r=Ae({stdio:"inherit"}),{code:i}=await r.run(`node ${t.join(" ")}`);process.exit(i??0)};export{ZE as a,Jr as b,pc as c,db as d,ur as e,gb as f,At as g,vb as h,Db as i,Hb as j,tv as k,av as l};
26
26
  /*!
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
 
2
2
  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)}
3
3
 
4
- import{b as o,c as r,d as e,e as f,f as m,g as p,j as t,k as x,l as a}from"./chunk-FS2JVFNA.js";import"./chunk-UCISWLJO.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};
4
+ import{b as o,c as r,d as e,e as f,f as m,g as p,j as t,k as x,l as a}from"./chunk-Z3HCFUI4.js";import"./chunk-UCISWLJO.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.9.0",
5
+ "version": "41.11.0",
6
6
  "repository": "tsmodule/tsmodule",
7
7
  "description": "TypeScript Module loader and compiler",
8
8
  "license": "MIT",
@@ -40,20 +40,20 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "esbuild": "^0.15.15",
43
- "typescript": "^4.8.4"
43
+ "typescript": "^4.9.3"
44
44
  },
45
45
  "devDependencies": {
46
- "@types/node": "^18.11.5",
47
- "@typescript-eslint/eslint-plugin": "^5.41.0",
48
- "@typescript-eslint/parser": "^5.41.0",
46
+ "@types/node": "^18.11.9",
47
+ "@typescript-eslint/eslint-plugin": "^5.44.0",
48
+ "@typescript-eslint/parser": "^5.44.0",
49
49
  "assert": "^2.0.0",
50
- "ava": "^5.0.1",
50
+ "ava": "^5.1.0",
51
51
  "chalk": "^5.1.2",
52
52
  "commander": "^9.4.1",
53
53
  "debug-logging": "^4.0.4",
54
54
  "es-module-lexer": "^1.1.0",
55
- "eslint": "^8.26.0",
56
- "eslint-config-next": "^13.0.0",
55
+ "eslint": "^8.28.0",
56
+ "eslint-config-next": "^13.0.4",
57
57
  "fast-glob": "^3.2.12",
58
58
  "node-watch": "^0.7.3",
59
59
  "ora": "^6.1.2",