@tsmodule/tsmodule 44.4.0 → 44.5.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/index.js CHANGED
@@ -31,7 +31,7 @@ if(typeof process<"u"){let{dirname:e}=await import("path"),{fileURLToPath:i}=awa
31
31
  /** __ESM_SHIM_END */
32
32
  `,$A={name:"removeEsmShim",setup(e){e.initialOptions.format==="cjs"&&e.onLoad({filter:/\.js$/},async({path:t})=>{let r=await Qy(t,"utf8");if(r.startsWith(Gi))return{contents:r.slice(Gi.length),loader:"js"}})}};import{existsSync as Zo}from"fs";import{mkdir as Ty,readFile as Iy,writeFile as ky}from"fs/promises";import{dirname as Oy,resolve as Ji}from"path";var UA=async(e="esm")=>{let t;switch(Zo("dist")||await Ty("dist"),Zo("dist/package.json")?t=JSON.parse(await Iy("dist/package.json","utf-8")):t={},e){case"esm":t.type="module";break;case"cjs":t.type="commonjs";break;default:return!1}return await ky("dist/package.json",JSON.stringify(t,null,2)),!0},zo=(e,t,r)=>{t=Ji(t);let i=Wt(t);return{stdin:{contents:e,sourcefile:t,resolveDir:Oy(t),loader:r},outdir:void 0,outfile:i,splitting:!1}},ea=async(e,t,r)=>{let i=await wr(),{dependencies:n={},devDependencies:s}=i;if(!(n?.tailwindcss??s?.tailwindcss))return;e=Ji(e),t=Ji(t);let a=["pnpm tailwindcss","--postcss postcss.config.cjs",`-i ${e}`,`-o ${t}`];r||a.push("--minify"),Zo(Ji("tailwind.config.cjs"))&&a.push("--config tailwind.config.cjs");let l=he({log:qo,stdio:qo?"inherit":"ignore"}),c=a.join(" "),{code:u,stdout:A,stderr:f}=await l.run(c);if(u!==0)throw console.error(P.red(P.bold(c))),console.log(A),console.error(P.red(f)),new Error("Failed to build Tailwind styles")};var ta=e=>{let t=` ${e} `;de(P.bgBlue(P.bold(P.white(t))),[],{preLines:0,postLines:1})};var HA=async()=>{let e=he({log:!0});await bt({standalone:!0,format:"cjs",input:"src/bin.ts"}),await e.run("pnpm exec pkg --out-path dist dist/bin.js")};import{tmpdir as Gy}from"os";var Jy=`import React from "react";
33
33
  import ReactDOM from "react-dom";
34
- `,bt=async(e={})=>{let{bundle:t=!1,runtimeOnly:r=!1,splitting:i=!1}=e,{input:n="src/**/*",styles:s="src/**/*.css",target:o="esnext",format:a="esm",tsconfig:l="tsconfig.json",dev:c=!1,standalone:u=!1,binary:A=!1,clear:f=!0,jsOnly:B=!1,noWrite:h=!1,rawProcessEnv:_=!1,stdin:x=void 0,stdinFile:C=void 0,external:N=[]}=e;KA.NODE_ENV=c?"development":"production";let E=ge(bt);E.log("Building with options:",e),c&&(r=!0),u&&(t=!0,i=!1),(a!=="esm"||!t||x)&&(i=!1),f&&Br("./dist");let{cwd:T,srcDir:y,outDir:I}=$o(),w=await wr(),Q={};_||(Q["process.env.NODE_ENV"]=JSON.stringify(c?"development":"production"),E.log("Set process.env.NODE_ENV to",Q["process.env.NODE_ENV"]));let j={treeShaking:t,target:o,minify:!c,jsx:"transform",jsxFactory:"React.createElement",format:a,charset:"utf8",logLevel:c?"warning":"error",define:Q},re=["esbuild","*.png"],g=[];u||g.push(jA),a==="cjs"&&g.push($A);let S;if(t)switch(a){case"esm":S={js:Gi};break}E.log("Copying tsconfig to tmpdir() in order to override JSX settings.");let{config:k}=xA(l)??{},{compilerOptions:_e}=k??{},p={...k,compilerOptions:{..._e,jsx:"react",jsxFactory:"React.createElement"}},d=Uy(Gy(),`tsconfig.${Date.now()}.json`);My(d,JSON.stringify(p,null,2)),E.log("tsconfig copied.");let ne={...j,tsconfig:d,bundle:t,splitting:i,absWorkingDir:T,outbase:"src",outdir:"dist",assetNames:"[name].js",format:a,target:"esnext",platform:w?.platform??"node",write:!h,external:t?[...re,...N]:void 0,banner:S,plugins:g};E.log("Build options",ne);let q="";if(x){E.log("Building file from stdin",{stdin:x,stdinFile:C,noWrite:h}),C||(de(P.red("ERROR: --stdin-file must be specified to emulate a file location when using stdin.")),process.exit(1)),typeof x=="string"&&x.length?q=x:q=await Xo();let D={...j,sourcefile:C,loader:"tsx",banner:void 0,footer:void 0};if(h)return(await Ky(q,D)).code;{let R=zo(q,C,"tsx");await Ye(async()=>await ra({...ne,...R}),{start:"Building stdin to dist/.",success:"Built stdin to dist/.",error:"Error building stdin to dist/."}),de(P.grey("Use --no-write to print to stdout instead."));return}}E.log("Building",{files:n,dev:c,runtimeOnly:r}),ta(`${P.bold("TS Module")} [${KA.NODE_ENV}]`);let ae=ia.default.sync(n,{cwd:T}).filter(D=>qy(D)!==".d.ts").map(D=>Hy(D));if(E.log("All files",{allFiles:ae}),jy(n)){ae.length||ae.push(n);let D=n.replace(y,I).replace(Yt,".js").replace(yt,".js");E.log("Cleaning emitted file:",{outfile:D}),Br(D)}else E.log("Cleaning old output:",{outDir:I}),Br(I);let Ee=ae.filter(D=>yt.test(D));E.log("Compiling TSX files:",{tsxJsxInput:Ee});let Ae=Ee.filter(D=>!D.endsWith(".d.ts"));await Ye(async()=>await Promise.all(Ae.map(async D=>{let R=Ny(D,"utf-8"),ye=Jy+R,zi=zo(ye,D,"tsx");await ra({...ne,...zi})})),{start:"Compiling TSX files.",success:"Compiled TSX files.",error:"Failed to compile TSX files."});let ot=ae.filter(D=>Yt.test(D)).filter(D=>!yt.test(D));E.log("Compiling TS files:",{tsJsInput:ot}),await Ye(async()=>await ra({...ne,entryPoints:ot.filter(D=>!D.endsWith(".d.ts"))}),{start:"Compiling TS/JS files.",success:"Compiled TS/JS files.",error:"Failed to compile TS/JS files."}),Br(d),E.log("Deleted tsconfig copy in tmpdir().");let Zi=ae.filter(D=>!BA.test(D));if(await Ye(async()=>{for(let D of Zi){let R=Wt(D);E.log("Copying non-source file:",{file:D,emittedFile:R}),Py(Fy(R),{recursive:!0}),Ly(D,R,Dy.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 D=n.replace(y,I).replace(/^(\.\/)?src\//,"dist/").replace(Yt,".js").replace(yt,".js");E.log("Normalizing import specifiers in emitted JS.",{emittedJs:D}),await Ye(async()=>await Vo(D.endsWith(".js")?D:`${D}.js`),{start:"Normalizing import specifiers.",success:"Normalized import specifiers.",error:"Failed to normalize import specifiers."})}if(await UA(a)&&Je({text:'Forced "type" package.json field in dist.',indent:2}).succeed(),!B){let D=!1;if(s){let R=ia.default.sync(s);E.log("Building production style bundles.",{cssFiles:R}),R.length&&(D=!0,await Ye(async()=>await Promise.all(R.map(async ye=>await ea(ye,Wt(ye),!0))),{start:"Bundling emitted styles",success:"Bundled all styles to dist/.",error:"Failed to bundle styles."}))}else if(n.endsWith(".css")){E.log("Bundling changed CSS styles for development."),D=!0;let R=$y(T,n),ye=P.bold(P.gray(R));await Ye(async()=>await ea(n,Wt(n),!0),{start:`Bundling with Tailwind: ${ye}`,success:`Bundled with Tailwind: ${ye}`,error:`Failed to bundle with Tailwind: ${ye}`})}D||(de(),de(P.grey("CSS styles not found for this project.")),de(P.gray(`Checked: ${P.bold(s)}`)),de())}A&&(ta("Building binary executables."),de("IMPORTANT: Top-level await is not supported yet.",["bold","yellow"]),de("Your program cannot be built to a binary if it contains TLA. Wrap with an async iife for now."),de("See: https://github.com/vercel/pkg/issues/1291"),await HA()),!c&&(r||await Ye(async()=>await Ko(),{start:"Generating type declarations.",success:`Generated declarations for ${ae.length} files.`,error:"Failed to generate type declarations."}),de("Build complete.",["green"],{preLines:1}))},lw=async(e,t)=>await bt({input:e,...t});import{resolve as zA}from"path";var VA=Oe(hi(),1);import{copyFile as Xy,mkdir as na}from"fs/promises";import{dirname as Zy,resolve as Zt}from"path";var JA={"./package.json":"./package.json",".":"./dist/index.js","./*":"./dist/*/index.js"},GA={packageJson:{type:"module",platform:"node",engines:{node:">=14"},types:"dist/index.d.ts",files:["dist"],exports:JA,scripts:{dev:"tsmodule dev",build:"tsmodule build",pretest:"pnpm build",test:"ava",prepublishOnly:"pnpm test",lint:"eslint src --fix"}},files:[".github/**",".eslintrc.yml",".gitignore","tsconfig.json","LICENSE","ava.config.mjs"],dependencies:[],devDependencies:["@types/node","@tsmodule/tsmodule","ava","typescript","pkg","eslint@^8.0.1","eslint-config-standard-with-typescript@latest","@typescript-eslint/eslint-plugin@^5.0.0","eslint-plugin-import@^2.25.2","eslint-plugin-n@^15.0.0","eslint-plugin-promise@^6.0.0"]},Qr={default:GA,react:{packageJson:{...GA.packageJson,platform:"browser",style:"dist/bundle.css",exports:{...JA,"./*":"./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:"pnpm build",test:"ava",prepublishOnly:"pnpm test && pnpm export"}},files:[".github/**",".gitignore",".eslintrc.yml","next-env.d.ts","next.config.js","postcss.config.cjs","tailwind.config.cjs"],dependencies:["react@^18.2.0","react-dom@^18.2.0"],devDependencies:["@types/react@^18.0.23","@types/react-dom@^18.0.7","eslint-plugin-react@latest","eslint-config-next","@tsmodule/react","next","tailwindcss","autoprefixer","cssnano","postcss","postcss-import"]}};import{dirname as Yy,resolve as Wy}from"path";import{fileURLToPath as Vy}from"url";var Yi=Wy(Yy(Vy(import.meta.url)),"..");var XA=e=>Zt(Yi,`./templates/${e}`),oa=async({template:e,targetDir:t=process.cwd()})=>{let r=he({log:!1}),i=XA(e),n=Zt(t);await na(n,{recursive:!0}),await r.run({posix:`cp -rf ${i}/. ${n}`,win32:`xcopy /E /I /Q /Y ${i}\\ ${n}\\`})},sa=async({template:e,targetDir:t=process.cwd()})=>{let r=ge(sa);r.log("Copying template files",{template:e,targetDir:t});let i=XA(e),n=Zt(t);await na(n,{recursive:!0});let s=await(0,VA.default)(Qr[e].files,{cwd:i,dot:!0});if(s.length)for(let o of s){let a=Zt(i,o),l=Zt(n,o);r.log({sourcePath:a,replacementPath:l}),await na(Zy(l),{recursive:!0}),await Xy(a,l)}},YA=async({template:e,targetDir:t=process.cwd()})=>{let r=Zt(t),i=Qr[e].packageJson;return await Ki(r,i)},WA=async({template:e,targetDir:t=process.cwd()})=>{let r=he({cwd:t}),i=Qr[e].dependencies,n=Qr[e].devDependencies;i.length&&await r.run(`pnpm add ${i.join(" ")}`),n.length&&await r.run(`pnpm add -D ${n.join(" ")}`)},ZA=async({template:e,targetDir:t=process.cwd()})=>{let r={template:"default",targetDir:t};if(await sa(r),await YA(r),await WA(r),e==="default")return;let i={template:e,targetDir:t};await sa(i),await YA(i),await WA(i)};var Tw=async(e,{react:t=!1})=>{let r=t?"react":"default",i=Je({text:`Creating new module ${P.blueBright(e)}.`,indent:2}).start();await oa({template:"default",targetDir:e}),await Ki(zA(process.cwd(),e),{name:e}),r!=="default"&&await oa({template:r,targetDir:e}),i.succeed("Project created."),await ZA({template:r,targetDir:e}),i.succeed("Dependencies installed."),await he({cwd:zA(e),stdio:["ignore","ignore","inherit"]}).run("git init"),i.succeed("Set up as Git repository.")};import{relative as pb,resolve as db}from"path";import{existsSync as hb}from"fs";import{lstat as gb}from"fs/promises";var yp=Oe(mp(),1);var _p=()=>{console.clear()},Ep=e=>{console.log(),console.group(),console.log(P.blue(`Built ${P.bold(e)}.`)),console.log(P.blue(new Date().toLocaleString())),console.groupEnd()},Uw=async({format:e="esm"})=>{let t=process.cwd(),r=he();process.platform!=="win32"&&await r.run("clear"),_p(),await bt({format:e,dev:!0}),Ep("src/**/*"),(0,yp.default)(db(t,"src"),{recursive:!0}).on("change",async(i,n)=>{if(!hb(n)||(await gb(n)).isDirectory())return;_p();let l=Date.now();try{let u=n.endsWith(".css");await bt({dev:!0,runtimeOnly:!0,input:n,clear:!1,styles:null})}catch(u){Nr("ERROR:",u)}let c=Date.now()-l;console.log(),Je({text:P.blueBright(`Dev refresh finished in ${P.bold(`${c}ms`)}.`),indent:2}).succeed(),Ep(pb(t,n))})};import{pathToFileURL as mb}from"url";import{resolve as _b}from"path";var Ww=async()=>{let e=_b(Yi,"dist/loader/index.js"),t=["--no-warnings","--loader",mb(e).href,...process.argv.slice(2)],r=he({stdio:"inherit"}),{code:i}=await r.run(`node ${t.join(" ")}`);process.exit(i??0)};export{bt as build,lw as buildCommand,Tw as create,Uw as dev,Ww as execute,Vo as normalizeImportSpecifiers,Qr as specification};
34
+ `,bt=async(e={})=>{let{bundle:t=!1,runtimeOnly:r=!1,splitting:i=!1}=e,{input:n="src/**/*",styles:s="src/**/*.css",target:o="esnext",format:a="esm",tsconfig:l="tsconfig.json",dev:c=!1,standalone:u=!1,binary:A=!1,clear:f=!0,jsOnly:B=!1,noWrite:h=!1,rawProcessEnv:_=!1,stdin:x=void 0,stdinFile:C=void 0,external:N=[]}=e;KA.NODE_ENV=c?"development":"production";let E=ge(bt);E.log("Building with options:",e),c&&(r=!0),u&&(t=!0,i=!1),(a!=="esm"||!t||x)&&(i=!1),f&&Br("./dist");let{cwd:T,srcDir:y,outDir:I}=$o(),w=await wr(),Q={"process.env.NODE_ENV":"process.env.NODE_ENV"};_||(Q["process.env.NODE_ENV"]=JSON.stringify(c?"development":"production"),E.log("Set process.env.NODE_ENV to",Q["process.env.NODE_ENV"]));let j={treeShaking:t,target:o,minify:!c,jsx:"transform",jsxFactory:"React.createElement",format:a,charset:"utf8",logLevel:c?"warning":"error",define:Q},re=["esbuild","*.png"],g=[];u||g.push(jA),a==="cjs"&&g.push($A);let S;if(t)switch(a){case"esm":S={js:Gi};break}E.log("Copying tsconfig to tmpdir() in order to override JSX settings.");let{config:k}=xA(l)??{},{compilerOptions:_e}=k??{},p={...k,compilerOptions:{..._e,jsx:"react",jsxFactory:"React.createElement"}},d=Uy(Gy(),`tsconfig.${Date.now()}.json`);My(d,JSON.stringify(p,null,2)),E.log("tsconfig copied.");let ne={...j,tsconfig:d,bundle:t,splitting:i,absWorkingDir:T,outbase:"src",outdir:"dist",assetNames:"[name].js",format:a,target:"esnext",platform:w?.platform??"node",write:!h,external:t?[...re,...N]:void 0,banner:S,plugins:g};E.log("Build options",ne);let q="";if(x){E.log("Building file from stdin",{stdin:x,stdinFile:C,noWrite:h}),C||(de(P.red("ERROR: --stdin-file must be specified to emulate a file location when using stdin.")),process.exit(1)),typeof x=="string"&&x.length?q=x:q=await Xo();let D={...j,sourcefile:C,loader:"tsx",banner:void 0,footer:void 0};if(h)return(await Ky(q,D)).code;{let R=zo(q,C,"tsx");await Ye(async()=>await ra({...ne,...R}),{start:"Building stdin to dist/.",success:"Built stdin to dist/.",error:"Error building stdin to dist/."}),de(P.grey("Use --no-write to print to stdout instead."));return}}E.log("Building",{files:n,dev:c,runtimeOnly:r}),ta(`${P.bold("TS Module")} [${KA.NODE_ENV}]`);let ae=ia.default.sync(n,{cwd:T}).filter(D=>qy(D)!==".d.ts").map(D=>Hy(D));if(E.log("All files",{allFiles:ae}),jy(n)){ae.length||ae.push(n);let D=n.replace(y,I).replace(Yt,".js").replace(yt,".js");E.log("Cleaning emitted file:",{outfile:D}),Br(D)}else E.log("Cleaning old output:",{outDir:I}),Br(I);let Ee=ae.filter(D=>yt.test(D));E.log("Compiling TSX files:",{tsxJsxInput:Ee});let Ae=Ee.filter(D=>!D.endsWith(".d.ts"));await Ye(async()=>await Promise.all(Ae.map(async D=>{let R=Ny(D,"utf-8"),ye=Jy+R,zi=zo(ye,D,"tsx");await ra({...ne,...zi})})),{start:"Compiling TSX files.",success:"Compiled TSX files.",error:"Failed to compile TSX files."});let ot=ae.filter(D=>Yt.test(D)).filter(D=>!yt.test(D));E.log("Compiling TS files:",{tsJsInput:ot}),await Ye(async()=>await ra({...ne,entryPoints:ot.filter(D=>!D.endsWith(".d.ts"))}),{start:"Compiling TS/JS files.",success:"Compiled TS/JS files.",error:"Failed to compile TS/JS files."}),Br(d),E.log("Deleted tsconfig copy in tmpdir().");let Zi=ae.filter(D=>!BA.test(D));if(await Ye(async()=>{for(let D of Zi){let R=Wt(D);E.log("Copying non-source file:",{file:D,emittedFile:R}),Py(Fy(R),{recursive:!0}),Ly(D,R,Dy.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 D=n.replace(y,I).replace(/^(\.\/)?src\//,"dist/").replace(Yt,".js").replace(yt,".js");E.log("Normalizing import specifiers in emitted JS.",{emittedJs:D}),await Ye(async()=>await Vo(D.endsWith(".js")?D:`${D}.js`),{start:"Normalizing import specifiers.",success:"Normalized import specifiers.",error:"Failed to normalize import specifiers."})}if(await UA(a)&&Je({text:'Forced "type" package.json field in dist.',indent:2}).succeed(),!B){let D=!1;if(s){let R=ia.default.sync(s);E.log("Building production style bundles.",{cssFiles:R}),R.length&&(D=!0,await Ye(async()=>await Promise.all(R.map(async ye=>await ea(ye,Wt(ye),!0))),{start:"Bundling emitted styles",success:"Bundled all styles to dist/.",error:"Failed to bundle styles."}))}else if(n.endsWith(".css")){E.log("Bundling changed CSS styles for development."),D=!0;let R=$y(T,n),ye=P.bold(P.gray(R));await Ye(async()=>await ea(n,Wt(n),!0),{start:`Bundling with Tailwind: ${ye}`,success:`Bundled with Tailwind: ${ye}`,error:`Failed to bundle with Tailwind: ${ye}`})}D||(de(),de(P.grey("CSS styles not found for this project.")),de(P.gray(`Checked: ${P.bold(s)}`)),de())}A&&(ta("Building binary executables."),de("IMPORTANT: Top-level await is not supported yet.",["bold","yellow"]),de("Your program cannot be built to a binary if it contains TLA. Wrap with an async iife for now."),de("See: https://github.com/vercel/pkg/issues/1291"),await HA()),!c&&(r||await Ye(async()=>await Ko(),{start:"Generating type declarations.",success:`Generated declarations for ${ae.length} files.`,error:"Failed to generate type declarations."}),de("Build complete.",["green"],{preLines:1}))},lw=async(e,t)=>await bt({input:e,...t});import{resolve as zA}from"path";var VA=Oe(hi(),1);import{copyFile as Xy,mkdir as na}from"fs/promises";import{dirname as Zy,resolve as Zt}from"path";var JA={"./package.json":"./package.json",".":"./dist/index.js","./*":"./dist/*/index.js"},GA={packageJson:{type:"module",platform:"node",engines:{node:">=14"},types:"dist/index.d.ts",files:["dist"],exports:JA,scripts:{dev:"tsmodule dev",build:"tsmodule build",pretest:"pnpm build",test:"ava",prepublishOnly:"pnpm test",lint:"eslint src --fix"}},files:[".github/**",".eslintrc.yml",".gitignore","tsconfig.json","LICENSE","ava.config.mjs"],dependencies:[],devDependencies:["@types/node","@tsmodule/tsmodule","ava","typescript","pkg","eslint@^8.0.1","eslint-config-standard-with-typescript@latest","@typescript-eslint/eslint-plugin@^5.0.0","eslint-plugin-import@^2.25.2","eslint-plugin-n@^15.0.0","eslint-plugin-promise@^6.0.0"]},Qr={default:GA,react:{packageJson:{...GA.packageJson,platform:"browser",style:"dist/bundle.css",exports:{...JA,"./*":"./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:"pnpm build",test:"ava",prepublishOnly:"pnpm test && pnpm export"}},files:[".github/**",".gitignore",".eslintrc.yml","next-env.d.ts","next.config.js","postcss.config.cjs","tailwind.config.cjs"],dependencies:["react@^18.2.0","react-dom@^18.2.0"],devDependencies:["@types/react@^18.0.23","@types/react-dom@^18.0.7","eslint-plugin-react@latest","eslint-config-next","@tsmodule/react","next","tailwindcss","autoprefixer","cssnano","postcss","postcss-import"]}};import{dirname as Yy,resolve as Wy}from"path";import{fileURLToPath as Vy}from"url";var Yi=Wy(Yy(Vy(import.meta.url)),"..");var XA=e=>Zt(Yi,`./templates/${e}`),oa=async({template:e,targetDir:t=process.cwd()})=>{let r=he({log:!1}),i=XA(e),n=Zt(t);await na(n,{recursive:!0}),await r.run({posix:`cp -rf ${i}/. ${n}`,win32:`xcopy /E /I /Q /Y ${i}\\ ${n}\\`})},sa=async({template:e,targetDir:t=process.cwd()})=>{let r=ge(sa);r.log("Copying template files",{template:e,targetDir:t});let i=XA(e),n=Zt(t);await na(n,{recursive:!0});let s=await(0,VA.default)(Qr[e].files,{cwd:i,dot:!0});if(s.length)for(let o of s){let a=Zt(i,o),l=Zt(n,o);r.log({sourcePath:a,replacementPath:l}),await na(Zy(l),{recursive:!0}),await Xy(a,l)}},YA=async({template:e,targetDir:t=process.cwd()})=>{let r=Zt(t),i=Qr[e].packageJson;return await Ki(r,i)},WA=async({template:e,targetDir:t=process.cwd()})=>{let r=he({cwd:t}),i=Qr[e].dependencies,n=Qr[e].devDependencies;i.length&&await r.run(`pnpm add ${i.join(" ")}`),n.length&&await r.run(`pnpm add -D ${n.join(" ")}`)},ZA=async({template:e,targetDir:t=process.cwd()})=>{let r={template:"default",targetDir:t};if(await sa(r),await YA(r),await WA(r),e==="default")return;let i={template:e,targetDir:t};await sa(i),await YA(i),await WA(i)};var Tw=async(e,{react:t=!1})=>{let r=t?"react":"default",i=Je({text:`Creating new module ${P.blueBright(e)}.`,indent:2}).start();await oa({template:"default",targetDir:e}),await Ki(zA(process.cwd(),e),{name:e}),r!=="default"&&await oa({template:r,targetDir:e}),i.succeed("Project created."),await ZA({template:r,targetDir:e}),i.succeed("Dependencies installed."),await he({cwd:zA(e),stdio:["ignore","ignore","inherit"]}).run("git init"),i.succeed("Set up as Git repository.")};import{relative as pb,resolve as db}from"path";import{existsSync as hb}from"fs";import{lstat as gb}from"fs/promises";var yp=Oe(mp(),1);var _p=()=>{console.clear()},Ep=e=>{console.log(),console.group(),console.log(P.blue(`Built ${P.bold(e)}.`)),console.log(P.blue(new Date().toLocaleString())),console.groupEnd()},Uw=async({format:e="esm"})=>{let t=process.cwd(),r=he();process.platform!=="win32"&&await r.run("clear"),_p(),await bt({format:e,dev:!0}),Ep("src/**/*"),(0,yp.default)(db(t,"src"),{recursive:!0}).on("change",async(i,n)=>{if(!hb(n)||(await gb(n)).isDirectory())return;_p();let l=Date.now();try{let u=n.endsWith(".css");await bt({dev:!0,runtimeOnly:!0,input:n,clear:!1,styles:null})}catch(u){Nr("ERROR:",u)}let c=Date.now()-l;console.log(),Je({text:P.blueBright(`Dev refresh finished in ${P.bold(`${c}ms`)}.`),indent:2}).succeed(),Ep(pb(t,n))})};import{pathToFileURL as mb}from"url";import{resolve as _b}from"path";var Ww=async()=>{let e=_b(Yi,"dist/loader/index.js"),t=["--no-warnings","--loader",mb(e).href,...process.argv.slice(2)],r=he({stdio:"inherit"}),{code:i}=await r.run(`node ${t.join(" ")}`);process.exit(i??0)};export{bt as build,lw as buildCommand,Tw as create,Uw as dev,Ww as execute,Vo as normalizeImportSpecifiers,Qr as specification};
35
35
  /*! Bundled license information:
36
36
 
37
37
  is-extglob/index.js:
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@tsmodule/tsmodule",
3
3
  "platform": "node",
4
4
  "type": "module",
5
- "version": "44.4.0",
5
+ "version": "44.5.0",
6
6
  "repository": "tsmodule/tsmodule",
7
7
  "description": "Create standardized TypeScript ESM packages for Node or browser.",
8
8
  "license": "MIT",