@tsmodule/tsmodule 40.0.3 → 40.0.4
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.
@@ -27,7 +27,7 @@ import ReactDOM from "react-dom";
|
|
27
27
|
\rTried running: ${l}.
|
28
28
|
\rError: ${u+h}`)},W0=`
|
29
29
|
typeof document>"u"&&await(async()=>{let{dirname:e}=await import("path"),{fileURLToPath:i}=await import("url");if(typeof globalThis.__filename>"u"&&(globalThis.__filename=i(import.meta.url)),typeof globalThis.__dirname>"u"&&(globalThis.__dirname=e(globalThis.__filename)),typeof globalThis.require>"u"){let{default:a}=await import("module");globalThis.require=a.createRequire(import.meta.url)}})();
|
30
|
-
`,V0=async({input:e="src/**/*",styles:t="src/components/index.css",target:r="esnext",dev:n=!1,bundle:i=!1,runtimeOnly:s
|
30
|
+
`,V0=async({input:e="src/**/*",styles:t="src/components/index.css",target:r="esnext",dev:n=!1,bundle:i=!1,runtimeOnly:s=!1,jsOnly:o=!1,noWrite:a=!1,stdin:l=void 0,stdinFile:f=void 0})=>{sc.NODE_ENV=n?"development":"production";let u=ye(V0);n&&(s=!0);let{cwd:h,srcDir:A,outDir:C}=Zs(),E=await tc(),_=JSON.parse(E),B={treeShaking:i,target:r,minify:!n,jsx:"transform",jsxFactory:"React.createElement",format:"esm",charset:"utf8",logLevel:n?"warning":"error",define:{"process.env.NODE_ENV":n?JSON.stringify("development"):JSON.stringify("production")}},b=["esbuild","*.png"],O={...B,bundle:i,absWorkingDir:h,outbase:"src",outdir:"dist",assetNames:"[name].js",format:"esm",target:"esnext",platform:_?.platform??"node",write:!a,external:i?b:void 0,banner:i?{js:W0}:void 0},k="";if(l){u.log("Building file from stdin",{stdin:l,stdinFile:f,noWrite:a}),f||(Pe(F.red("ERROR: --stdin-file must be specified to emulate a file location when using stdin.")),process.exit(1)),typeof l=="string"&&l.length?k=l:k=await oo();let c={...B,sourcefile:f,loader:"tsx",banner:void 0,footer:void 0};if(a)return(await K0(k,c)).code;{let D=ac(k,f,"tsx");await ao({...O,...D}),Pe(F.green("Successfully built stdin file to dist/.")),Pe(F.grey("Use --no-write to print to stdout instead."));return}}u.log("Building",{files:e,dev:n,runtimeOnly:s}),oc(`${F.bold("TS Module")} [${sc.NODE_ENV}]`);let G=lo.default.sync(e,{cwd:h}).filter(c=>$0(c)!==".d.ts").map(c=>sr(c));if(G0(e)){G.length||G.push(e);let c=e.replace(A,C).replace(kt,".js").replace(ct,".js");u.log("Cleaning emitted file:",{outfile:c}),await ic(c,{force:!0})}else u.log("Cleaning old output:",{outDir:C}),await ic(C,{force:!0,recursive:!0});let x=G.filter(c=>ct.test(c));u.log("Compiling TSX files:",{tsxJsxInput:x});let q=x.filter(c=>!c.endsWith(".d.ts"));await Promise.all(q.map(async c=>{let D=await uc(c,"utf-8"),M=J0+D,ae=ac(M,c,"tsx");await ao({...O,...ae})})),Ye("Built TSX files.").succeed();let w=G.filter(c=>kt.test(c)).filter(c=>!ct.test(c));u.log("Compiling TS files:",{tsJsInput:w}),await ao({...O,entryPoints:w.filter(c=>!c.endsWith(".d.ts"))}),Ye("Built TS files.").succeed();let S=G.filter(c=>!ec.test(c));u.log("Copying non-JS/TS files.",{allFiles:G,nonTsJsInput:S});for(let c of S){let D=zs(c);u.log("Copying non-source file:",{file:c,emittedFile:D}),await H0(fc(D),{recursive:!0}),await q0(c,D,F0.COPYFILE_FICLONE)}if(!process.env.NO_REWRITES){let c=e.replace(A,C).replace(/^(\.\/)?src\//,"dist/").replace(kt,".js").replace(ct,".js");u.log("Normalizing import specifiers in emitted JS.",{emittedJs:c}),await so(c.endsWith(".js")?c:`${c}.js`),Ye("Normalized import specifiers.").succeed()}if(await Y0()&&Ye('Forced "type": "module" in output.').succeed(),s)return;if(!o)if(uo(U0(t))){u.log("Building styles for production.");let{style:c="./dist/bundle.css"}=_;if(u.log("Building style bundle.",{bundleInput:t,bundleOutput:c,dev:n}),await lc(t,c,n),i){u.log("Bundling all styles.");let D=lo.default.sync("dist/**/*.css"),M=Ye("Bundling emitted styles.").start();await Promise.all(D.map(async ae=>await lc(ae,ae,n))),M.succeed(`Bundled all styles to ${F.bold(c)}.`)}}else Pe(F.grey(`Bundle styles not found for this project.
|
31
31
|
\rChecked: `+F.bold(t)));oc("Running post-build setup.");let Z=Ye("Generating type declarations.").start();await eo(),Z.succeed(`Generated delcarations for ${G.length} files.`),Pe(F.green("Build complete."))};export{oc as bannerLog,V0 as build};
|
32
32
|
/*!
|
33
33
|
* fill-range <https://github.com/jonschlinkert/fill-range>
|
@@ -27,10 +27,10 @@ import ReactDOM from "react-dom";
|
|
27
27
|
\rTried running: ${u}.
|
28
28
|
\rError: ${l+h}`)},JE=`
|
29
29
|
typeof document>"u"&&await(async()=>{let{dirname:e}=await import("path"),{fileURLToPath:i}=await import("url");if(typeof globalThis.__filename>"u"&&(globalThis.__filename=i(import.meta.url)),typeof globalThis.__dirname>"u"&&(globalThis.__dirname=e(globalThis.__filename)),typeof globalThis.require>"u"){let{default:a}=await import("module");globalThis.require=a.createRequire(import.meta.url)}})();
|
30
|
-
`,xn=async({input:e="src/**/*",styles:t="src/components/index.css",target:r="esnext",dev:n=!1,bundle:i=!1,runtimeOnly:s
|
30
|
+
`,xn=async({input:e="src/**/*",styles:t="src/components/index.css",target:r="esnext",dev:n=!1,bundle:i=!1,runtimeOnly:s=!1,jsOnly:o=!1,noWrite:a=!1,stdin:u=void 0,stdinFile:f=void 0})=>{qc.NODE_ENV=n?"development":"production";let l=me(xn);n&&(s=!0);let{cwd:h,srcDir:A,outDir:C}=go(),E=await Pc(),_=JSON.parse(E),v={treeShaking:i,target:r,minify:!n,jsx:"transform",jsxFactory:"React.createElement",format:"esm",charset:"utf8",logLevel:n?"warning":"error",define:{"process.env.NODE_ENV":n?JSON.stringify("development"):JSON.stringify("production")}},b=["esbuild","*.png"],O={...v,bundle:i,absWorkingDir:h,outbase:"src",outdir:"dist",assetNames:"[name].js",format:"esm",target:"esnext",platform:_?.platform??"node",write:!a,external:i?b:void 0,banner:i?{js:JE}:void 0},P="";if(u){l.log("Building file from stdin",{stdin:u,stdinFile:f,noWrite:a}),f||(ye(k.red("ERROR: --stdin-file must be specified to emulate a file location when using stdin.")),process.exit(1)),typeof u=="string"&&u.length?P=u:P=await So();let c={...v,sourcefile:f,loader:"tsx",banner:void 0,footer:void 0};if(a)return(await GE(P,c)).code;{let D=jc(P,f,"tsx");await Bo({...O,...D}),ye(k.green("Successfully built stdin file to dist/.")),ye(k.grey("Use --no-write to print to stdout instead."));return}}l.log("Building",{files:e,dev:n,runtimeOnly:s}),Hc(`${k.bold("TS Module")} [${qc.NODE_ENV}]`);let U=xo.default.sync(e,{cwd:h}).filter(c=>HE(c)!==".d.ts").map(c=>cr(c));if(jE(e)){U.length||U.push(e);let c=e.replace(A,C).replace(Mt,".js").replace(ht,".js");l.log("Cleaning emitted file:",{outfile:c}),await Fc(c,{force:!0})}else l.log("Cleaning old output:",{outDir:C}),await Fc(C,{force:!0,recursive:!0});let x=U.filter(c=>ht.test(c));l.log("Compiling TSX files:",{tsxJsxInput:x});let H=x.filter(c=>!c.endsWith(".d.ts"));await Promise.all(H.map(async c=>{let D=await Gc(c,"utf-8"),F=UE+D,ue=jc(F,c,"tsx");await Bo({...O,...ue})})),Re("Built TSX files.").succeed();let R=U.filter(c=>Mt.test(c)).filter(c=>!ht.test(c));l.log("Compiling TS files:",{tsJsInput:R}),await Bo({...O,entryPoints:R.filter(c=>!c.endsWith(".d.ts"))}),Re("Built TS files.").succeed();let S=U.filter(c=>!Lc.test(c));l.log("Copying non-JS/TS files.",{allFiles:U,nonTsJsInput:S});for(let c of S){let D=_o(c);l.log("Copying non-source file:",{file:c,emittedFile:D}),await FE(Uc(D),{recursive:!0}),await ME(c,D,NE.COPYFILE_FICLONE)}if(!process.env.NO_REWRITES){let c=e.replace(A,C).replace(/^(\.\/)?src\//,"dist/").replace(Mt,".js").replace(ht,".js");l.log("Normalizing import specifiers in emitted JS.",{emittedJs:c}),await vo(c.endsWith(".js")?c:`${c}.js`),Re("Normalized import specifiers.").succeed()}if(await KE()&&Re('Forced "type": "module" in output.').succeed(),s)return;if(!o)if(wo($E(t))){l.log("Building styles for production.");let{style:c="./dist/bundle.css"}=_;if(l.log("Building style bundle.",{bundleInput:t,bundleOutput:c,dev:n}),await $c(t,c,n),i){l.log("Bundling all styles.");let D=xo.default.sync("dist/**/*.css"),F=Re("Bundling emitted styles.").start();await Promise.all(D.map(async ue=>await $c(ue,ue,n))),F.succeed(`Bundled all styles to ${k.bold(c)}.`)}}else ye(k.grey(`Bundle styles not found for this project.
|
31
31
|
\rChecked: `+k.bold(t)));Hc("Running post-build setup.");let z=Re("Generating type declarations.").start();await Eo(),z.succeed(`Generated delcarations for ${U.length} files.`),ye(k.green("Build complete."))};var Kc=()=>{console.clear()},Jc=e=>{ye(`
|
32
32
|
`,k.gray(`Built ${k.bold(e)}.`),`
|
33
|
-
`,k.blue(new Date().toLocaleString()))},ev=async()=>{let e=process.cwd(),t=Et();process.platform!=="win32"&&await t.run("clear"),Kc(),await xn({dev:!0}),Jc("src/**/*"),(0,Yc.default)(WE(e,"src"),{recursive:!0}).on("change",async(r,n)=>{if(!VE(n)||(await XE(n)).isDirectory())return;Kc();let a=Date.now();await xn({dev:!0,input:n});let u=Date.now()-a;Re(k.blueBright(`Dev refresh finished in ${k.bold(`${u}ms`)}.`)).succeed(),Jc(YE(e,n))})};export{ev as dev};
|
33
|
+
`,k.blue(new Date().toLocaleString()))},ev=async()=>{let e=process.cwd(),t=Et();process.platform!=="win32"&&await t.run("clear"),Kc(),await xn({dev:!0}),Jc("src/**/*"),(0,Yc.default)(WE(e,"src"),{recursive:!0}).on("change",async(r,n)=>{if(!VE(n)||(await XE(n)).isDirectory())return;Kc();let a=Date.now();await xn({dev:!0,runtimeOnly:!0,input:n});let u=Date.now()-a;Re(k.blueBright(`Dev refresh finished in ${k.bold(`${u}ms`)}.`)).succeed(),Jc(YE(e,n))})};export{ev as dev};
|
34
34
|
/*!
|
35
35
|
* fill-range <https://github.com/jonschlinkert/fill-range>
|
36
36
|
*
|
package/dist/commands/index.js
CHANGED
@@ -27,10 +27,10 @@ import ReactDOM from "react-dom";
|
|
27
27
|
\rTried running: ${l}.
|
28
28
|
\rError: ${u+h}`)},qE=`
|
29
29
|
typeof document>"u"&&await(async()=>{let{dirname:e}=await import("path"),{fileURLToPath:i}=await import("url");if(typeof globalThis.__filename>"u"&&(globalThis.__filename=i(import.meta.url)),typeof globalThis.__dirname>"u"&&(globalThis.__dirname=e(globalThis.__filename)),typeof globalThis.require>"u"){let{default:a}=await import("module");globalThis.require=a.createRequire(import.meta.url)}})();
|
30
|
-
`,vn=async({input:e="src/**/*",styles:t="src/components/index.css",target:r="esnext",dev:n=!1,bundle:i=!1,runtimeOnly:s
|
30
|
+
`,vn=async({input:e="src/**/*",styles:t="src/components/index.css",target:r="esnext",dev:n=!1,bundle:i=!1,runtimeOnly:s=!1,jsOnly:o=!1,noWrite:a=!1,stdin:l=void 0,stdinFile:f=void 0})=>{Bc.NODE_ENV=n?"development":"production";let u=ve(vn);n&&(s=!0);let{cwd:h,srcDir:A,outDir:C}=lo(),E=await bc(),_=JSON.parse(E),v={treeShaking:i,target:r,minify:!n,jsx:"transform",jsxFactory:"React.createElement",format:"esm",charset:"utf8",logLevel:n?"warning":"error",define:{"process.env.NODE_ENV":n?JSON.stringify("development"):JSON.stringify("production")}},b=["esbuild","*.png"],D={...v,bundle:i,absWorkingDir:h,outbase:"src",outdir:"dist",assetNames:"[name].js",format:"esm",target:"esnext",platform:_?.platform??"node",write:!a,external:i?b:void 0,banner:i?{js:qE}:void 0},P="";if(l){u.log("Building file from stdin",{stdin:l,stdinFile:f,noWrite:a}),f||(Se(T.red("ERROR: --stdin-file must be specified to emulate a file location when using stdin.")),process.exit(1)),typeof l=="string"&&l.length?P=l:P=await _o();let c={...v,sourcefile:f,loader:"tsx",banner:void 0,footer:void 0};if(a)return(await NE(P,c)).code;{let k=Rc(P,f,"tsx");await Eo({...D,...k}),Se(T.green("Successfully built stdin file to dist/.")),Se(T.grey("Use --no-write to print to stdout instead."));return}}u.log("Building",{files:e,dev:n,runtimeOnly:s}),wc(`${T.bold("TS Module")} [${Bc.NODE_ENV}]`);let U=mo.default.sync(e,{cwd:h}).filter(c=>kE(c)!==".d.ts").map(c=>lr(c));if(LE(e)){U.length||U.push(e);let c=e.replace(A,C).replace(Mt,".js").replace(pt,".js");u.log("Cleaning emitted file:",{outfile:c}),await xc(c,{force:!0})}else u.log("Cleaning old output:",{outDir:C}),await xc(C,{force:!0,recursive:!0});let B=U.filter(c=>pt.test(c));u.log("Compiling TSX files:",{tsxJsxInput:B});let H=B.filter(c=>!c.endsWith(".d.ts"));await Promise.all(H.map(async c=>{let k=await Ic(c,"utf-8"),F=ME+k,le=Rc(F,c,"tsx");await Eo({...D,...le})})),_e("Built TSX files.").succeed();let R=U.filter(c=>Mt.test(c)).filter(c=>!pt.test(c));u.log("Compiling TS files:",{tsJsInput:R}),await Eo({...D,entryPoints:R.filter(c=>!c.endsWith(".d.ts"))}),_e("Built TS files.").succeed();let S=U.filter(c=>!Cc.test(c));u.log("Copying non-JS/TS files.",{allFiles:U,nonTsJsInput:S});for(let c of S){let k=uo(c);u.log("Copying non-source file:",{file:c,emittedFile:k}),await OE(Tc(k),{recursive:!0}),await TE(c,k,IE.COPYFILE_FICLONE)}if(!process.env.NO_REWRITES){let c=e.replace(A,C).replace(/^(\.\/)?src\//,"dist/").replace(Mt,".js").replace(pt,".js");u.log("Normalizing import specifiers in emitted JS.",{emittedJs:c}),await go(c.endsWith(".js")?c:`${c}.js`),_e("Normalized import specifiers.").succeed()}if(await FE()&&_e('Forced "type": "module" in output.').succeed(),s)return;if(!o)if(yo(PE(t))){u.log("Building styles for production.");let{style:c="./dist/bundle.css"}=_;if(u.log("Building style bundle.",{bundleInput:t,bundleOutput:c,dev:n}),await Qc(t,c,n),i){u.log("Bundling all styles.");let k=mo.default.sync("dist/**/*.css"),F=_e("Bundling emitted styles.").start();await Promise.all(k.map(async le=>await Qc(le,le,n))),F.succeed(`Bundled all styles to ${T.bold(c)}.`)}}else Se(T.grey(`Bundle styles not found for this project.
|
31
31
|
\rChecked: `+T.bold(t)));wc("Running post-build setup.");let z=_e("Generating type declarations.").start();await fo(),z.succeed(`Generated delcarations for ${U.length} files.`),Se(T.green("Build complete."))};import{dirname as HE,resolve as jE}from"path";import{fileURLToPath as $E}from"url";var Co={default:[],react:["react@^17.0.2","react-dom@^17.0.2"]},bo={default:["@types/node","@tsmodule/tsmodule","@typescript-eslint/eslint-plugin","@typescript-eslint/parser","ava","eslint","typescript"],react:["next","@types/react@^17.0.39","@types/react-dom@^17.0.11","@tsmodule/react","eslint","eslint-config-next","tailwindcss","autoprefixer","cssnano","postcss","postcss-import"]},Sn=jE(HE($E(import.meta.url)),"..");import{mkdir as GE}from"fs/promises";import{resolve as Oc}from"path";var vo=async(e,t)=>{let r=me(),n=Oc(Sn,`./templates/${e}`),i=Oc(t);await GE(i,{recursive:!0}),await r.run({posix:`cp -rf ${n}/. ${i}`,win32:`xcopy /E /I /Q /Y ${n}\\ ${i}\\`})};import Dc from"fs/promises";import{resolve as UE}from"path";var kc=async e=>{let t=UE(process.cwd(),e,"package.json"),r=await Dc.readFile(t,"utf-8"),n=JSON.parse(r);n.name=e,await Dc.writeFile(t,JSON.stringify(n,null,2))};globalThis.SHELL_OPTIONS={stdio:["ignore","ignore","inherit"]};var yv=async(e,{react:t=!1})=>{let r=me(),n=_e(`Creating new module ${T.blueBright(e)}.`).start();await vo("default",e),t&&await vo("react",e),await kc(e),n.succeed("Project created."),process.chdir(e);let i=[...Co.default],s=[...bo.default];t&&(i.push(...Co.react),s.push(...bo.react)),i.length&&await r.run(`yarn add ${i.join(" ")}`),s.length&&await r.run(`yarn add -D ${s.join(" ")}`),n.succeed("Dependencies installed."),await r.run("git init"),n.succeed("Set up as Git repository.")};import{relative as om,resolve as am}from"path";import{existsSync as lm}from"fs";import{lstat as um}from"fs/promises";var tA=He(Zc(),1);var zc=()=>{console.clear()},eA=e=>{Se(`
|
32
32
|
`,T.gray(`Built ${T.bold(e)}.`),`
|
33
|
-
`,T.blue(new Date().toLocaleString()))},Dv=async()=>{let e=process.cwd(),t=me();process.platform!=="win32"&&await t.run("clear"),zc(),await vn({dev:!0}),eA("src/**/*"),(0,tA.default)(am(e,"src"),{recursive:!0}).on("change",async(r,n)=>{if(!lm(n)||(await um(n)).isDirectory())return;zc();let a=Date.now();await vn({dev:!0,input:n});let l=Date.now()-a;_e(T.blueBright(`Dev refresh finished in ${T.bold(`${l}ms`)}.`)).succeed(),eA(om(e,n))})};import{pathToFileURL as fm}from"url";import{resolve as cm}from"path";var Fv=async()=>{let e=cm(Sn,"dist/loader/index.js"),t=["--no-warnings","--loader",fm(e).href,...process.argv.slice(2)];await me().run(`node ${t.join(" ")}`)};export{wc as bannerLog,vn as build,yv as create,Dv as dev,Fv as execute,go as normalizeImportSpecifiers};
|
33
|
+
`,T.blue(new Date().toLocaleString()))},Dv=async()=>{let e=process.cwd(),t=me();process.platform!=="win32"&&await t.run("clear"),zc(),await vn({dev:!0}),eA("src/**/*"),(0,tA.default)(am(e,"src"),{recursive:!0}).on("change",async(r,n)=>{if(!lm(n)||(await um(n)).isDirectory())return;zc();let a=Date.now();await vn({dev:!0,runtimeOnly:!0,input:n});let l=Date.now()-a;_e(T.blueBright(`Dev refresh finished in ${T.bold(`${l}ms`)}.`)).succeed(),eA(om(e,n))})};import{pathToFileURL as fm}from"url";import{resolve as cm}from"path";var Fv=async()=>{let e=cm(Sn,"dist/loader/index.js"),t=["--no-warnings","--loader",fm(e).href,...process.argv.slice(2)];await me().run(`node ${t.join(" ")}`)};export{wc as bannerLog,vn as build,yv as create,Dv as dev,Fv as execute,go as normalizeImportSpecifiers};
|
34
34
|
/*!
|
35
35
|
* fill-range <https://github.com/jonschlinkert/fill-range>
|
36
36
|
*
|
package/dist/index.js
CHANGED
@@ -45,10 +45,10 @@ import ReactDOM from "react-dom";
|
|
45
45
|
\rTried running: ${l}.
|
46
46
|
\rError: ${u+f}`)},G0=`
|
47
47
|
typeof document>"u"&&await(async()=>{let{dirname:e}=await import("path"),{fileURLToPath:i}=await import("url");if(typeof globalThis.__filename>"u"&&(globalThis.__filename=i(import.meta.url)),typeof globalThis.__dirname>"u"&&(globalThis.__dirname=e(globalThis.__filename)),typeof globalThis.require>"u"){let{default:a}=await import("module");globalThis.require=a.createRequire(import.meta.url)}})();
|
48
|
-
`,jt=async({input:t="src/**/*",styles:e="src/components/index.css",target:r="esnext",dev:i=!1,bundle:n=!1,runtimeOnly:s
|
48
|
+
`,jt=async({input:t="src/**/*",styles:e="src/components/index.css",target:r="esnext",dev:i=!1,bundle:n=!1,runtimeOnly:s=!1,jsOnly:o=!1,noWrite:a=!1,stdin:l=void 0,stdinFile:c=void 0})=>{uh.NODE_ENV=i?"development":"production";let u=Se(jt);i&&(s=!0);let{cwd:f,srcDir:h,outDir:y}=Oo(),_=await sh(),m=JSON.parse(_),v={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")}},b=["esbuild","*.png"],D={...v,bundle:n,absWorkingDir:f,outbase:"src",outdir:"dist",assetNames:"[name].js",format:"esm",target:"esnext",platform:m?.platform??"node",write:!a,external:n?b:void 0,banner:n?{js:G0}:void 0},P="";if(l){u.log("Building file from stdin",{stdin:l,stdinFile:c,noWrite:a}),c||(we(w.red("ERROR: --stdin-file must be specified to emulate a file location when using stdin.")),process.exit(1)),typeof l=="string"&&l.length?P=l:P=await Mo();let p={...v,sourcefile:c,loader:"tsx",banner:void 0,footer:void 0};if(a)return(await q0(P,p)).code;{let k=fh(P,c,"tsx");await Fo({...D,...k}),we(w.green("Successfully built stdin file to dist/.")),we(w.grey("Use --no-write to print to stdout instead."));return}}u.log("Building",{files:t,dev:i,runtimeOnly:s}),ch(`${w.bold("TS Module")} [${uh.NODE_ENV}]`);let U=Ho.default.sync(t,{cwd:f}).filter(p=>M0(p)!==".d.ts").map(p=>gr(p));if(F0(t)){U.length||U.push(t);let p=t.replace(h,y).replace($t,".js").replace(_t,".js");u.log("Cleaning emitted file:",{outfile:p}),await lh(p,{force:!0})}else u.log("Cleaning old output:",{outDir:y}),await lh(y,{force:!0,recursive:!0});let B=U.filter(p=>_t.test(p));u.log("Compiling TSX files:",{tsxJsxInput:B});let q=B.filter(p=>!p.endsWith(".d.ts"));await Promise.all(q.map(async p=>{let k=await ph(p,"utf-8"),F=$0+k,ue=fh(F,p,"tsx");await Fo({...D,...ue})})),me("Built TSX files.").succeed();let Q=U.filter(p=>$t.test(p)).filter(p=>!_t.test(p));u.log("Compiling TS files:",{tsJsInput:Q}),await Fo({...D,entryPoints:Q.filter(p=>!p.endsWith(".d.ts"))}),me("Built TS files.").succeed();let S=U.filter(p=>!nh.test(p));u.log("Copying non-JS/TS files.",{allFiles:U,nonTsJsInput:S});for(let p of S){let k=To(p);u.log("Copying non-source file:",{file:p,emittedFile:k}),await P0(dh(k),{recursive:!0}),await L0(p,k,k0.COPYFILE_FICLONE)}if(!process.env.NO_REWRITES){let p=t.replace(h,y).replace(/^(\.\/)?src\//,"dist/").replace($t,".js").replace(_t,".js");u.log("Normalizing import specifiers in emitted JS.",{emittedJs:p}),await Ar(p.endsWith(".js")?p:`${p}.js`),me("Normalized import specifiers.").succeed()}if(await j0()&&me('Forced "type": "module" in output.').succeed(),s)return;if(!o)if(qo(H0(e))){u.log("Building styles for production.");let{style:p="./dist/bundle.css"}=m;if(u.log("Building style bundle.",{bundleInput:e,bundleOutput:p,dev:i}),await hh(e,p,i),n){u.log("Bundling all styles.");let k=Ho.default.sync("dist/**/*.css"),F=me("Bundling emitted styles.").start();await Promise.all(k.map(async ue=>await hh(ue,ue,i))),F.succeed(`Bundled all styles to ${w.bold(p)}.`)}}else we(w.grey(`Bundle styles not found for this project.
|
49
49
|
\rChecked: `+w.bold(e)));ch("Running post-build setup.");let ee=me("Generating type declarations.").start();await Do(),ee.succeed(`Generated delcarations for ${U.length} files.`),we(w.green("Build complete."))};import{readFile as U0}from"fs/promises";import{dirname as K0,resolve as Ah}from"path";import{fileURLToPath as J0}from"url";var $o={default:[],react:["react@^17.0.2","react-dom@^17.0.2"]},jo={default:["@types/node","@tsmodule/tsmodule","@typescript-eslint/eslint-plugin","@typescript-eslint/parser","ava","eslint","typescript"],react:["next","@types/react@^17.0.39","@types/react-dom@^17.0.11","@tsmodule/react","eslint","eslint-config-next","tailwindcss","autoprefixer","cssnano","postcss","postcss-import"]},_r=Ah(K0(J0(import.meta.url)),".."),gh=async()=>{let t=await U0(Ah(_r,"package.json"),"utf-8");return JSON.parse(t)};import{mkdir as V0}from"fs/promises";import{resolve as _h}from"path";var Go=async(t,e)=>{let r=ye(),i=_h(_r,`./templates/${t}`),n=_h(e);await V0(n,{recursive:!0}),await r.run({posix:`cp -rf ${i}/. ${n}`,win32:`xcopy /E /I /Q /Y ${i}\\ ${n}\\`})};import mh from"fs/promises";import{resolve as Y0}from"path";var Eh=async t=>{let e=Y0(process.cwd(),t,"package.json"),r=await mh.readFile(e,"utf-8"),i=JSON.parse(r);i.name=t,await mh.writeFile(e,JSON.stringify(i,null,2))};globalThis.SHELL_OPTIONS={stdio:["ignore","ignore","inherit"]};var yh=async(t,{react:e=!1})=>{let r=ye(),i=me(`Creating new module ${w.blueBright(t)}.`).start();await Go("default",t),e&&await Go("react",t),await Eh(t),i.succeed("Project created."),process.chdir(t);let n=[...$o.default],s=[...jo.default];e&&(n.push(...$o.react),s.push(...jo.react)),n.length&&await r.run(`yarn add ${n.join(" ")}`),s.length&&await r.run(`yarn add -D ${s.join(" ")}`),i.succeed("Dependencies installed."),await r.run("git init"),i.succeed("Set up as Git repository.")};import{relative as cy,resolve as fy}from"path";import{existsSync as hy}from"fs";import{lstat as py}from"fs/promises";var qh=Me(Mh(),1);var Fh=()=>{console.clear()},Hh=t=>{we(`
|
50
50
|
`,w.gray(`Built ${w.bold(t)}.`),`
|
51
|
-
`,w.blue(new Date().toLocaleString()))},$h=async()=>{let t=process.cwd(),e=ye();process.platform!=="win32"&&await e.run("clear"),Fh(),await jt({dev:!0}),Hh("src/**/*"),(0,qh.default)(fy(t,"src"),{recursive:!0}).on("change",async(r,i)=>{if(!hy(i)||(await py(i)).isDirectory())return;Fh();let a=Date.now();await jt({dev:!0,input:i});let l=Date.now()-a;me(w.blueBright(`Dev refresh finished in ${w.bold(`${l}ms`)}.`)).succeed(),Hh(cy(t,i))})};import{pathToFileURL as dy}from"url";import{resolve as Ay}from"path";var jh=async()=>{let t=Ay(_r,"dist/loader/index.js"),e=["--no-warnings","--loader",dy(t).href,...process.argv.slice(2)];await ye().run(`node ${e.join(" ")}`)};var{version:gy}=await gh(),mt=new wa;mt.name(w.white(w.bold("tsmodule"))).usage(w.white(w.bold("<file | command> [options]"))).description(w.blueBright(`A tool for building TypeScript modules.
|
51
|
+
`,w.blue(new Date().toLocaleString()))},$h=async()=>{let t=process.cwd(),e=ye();process.platform!=="win32"&&await e.run("clear"),Fh(),await jt({dev:!0}),Hh("src/**/*"),(0,qh.default)(fy(t,"src"),{recursive:!0}).on("change",async(r,i)=>{if(!hy(i)||(await py(i)).isDirectory())return;Fh();let a=Date.now();await jt({dev:!0,runtimeOnly:!0,input:i});let l=Date.now()-a;me(w.blueBright(`Dev refresh finished in ${w.bold(`${l}ms`)}.`)).succeed(),Hh(cy(t,i))})};import{pathToFileURL as dy}from"url";import{resolve as Ay}from"path";var jh=async()=>{let t=Ay(_r,"dist/loader/index.js"),e=["--no-warnings","--loader",dy(t).href,...process.argv.slice(2)];await ye().run(`node ${e.join(" ")}`)};var{version:gy}=await gh(),mt=new wa;mt.name(w.white(w.bold("tsmodule"))).usage(w.white(w.bold("<file | command> [options]"))).description(w.blueBright(`A tool for building TypeScript modules.
|
52
52
|
|
53
53
|
Run TS directly: ${w.bold("tsmodule src/index.ts")}
|
54
54
|
Use a command: ${w.bold("tsmodule build")}`)).version(String(gy));mt.command("dev").description("Build and watch for changes.").action($h);mt.command("build").description("Builds TS files to output in dist/.").option("-i, --input <files>","Entrypoints to compile.").option("-j, --js-only","Do not build styles").option("-s, --styles <styles>","Specify stylesheet entrypoint.").option("-t, --target <target>","ECMAScript featureset to target.").option("-b, --bundle","Bundle dependencies into entrypoints.").option("-d, --dev","Build development runtime.").option("-r, --runtime-only","Do not emit type declarations, only build JS runtime.").option("--stdin [source]","Read from a string or stdin.").option("--stdin-file [file]","File path to mock for stdin.").option("--no-write",`Return code from build() rather than write to disk.
|
package/dist/types/index.js
CHANGED
@@ -27,10 +27,10 @@ import ReactDOM from "react-dom";
|
|
27
27
|
\rTried running: ${l}.
|
28
28
|
\rError: ${u+h}`)},qE=`
|
29
29
|
typeof document>"u"&&await(async()=>{let{dirname:e}=await import("path"),{fileURLToPath:i}=await import("url");if(typeof globalThis.__filename>"u"&&(globalThis.__filename=i(import.meta.url)),typeof globalThis.__dirname>"u"&&(globalThis.__dirname=e(globalThis.__filename)),typeof globalThis.require>"u"){let{default:a}=await import("module");globalThis.require=a.createRequire(import.meta.url)}})();
|
30
|
-
`,vn=async({input:e="src/**/*",styles:t="src/components/index.css",target:r="esnext",dev:n=!1,bundle:i=!1,runtimeOnly:s
|
30
|
+
`,vn=async({input:e="src/**/*",styles:t="src/components/index.css",target:r="esnext",dev:n=!1,bundle:i=!1,runtimeOnly:s=!1,jsOnly:o=!1,noWrite:a=!1,stdin:l=void 0,stdinFile:f=void 0})=>{Bc.NODE_ENV=n?"development":"production";let u=ve(vn);n&&(s=!0);let{cwd:h,srcDir:A,outDir:C}=lo(),E=await bc(),_=JSON.parse(E),v={treeShaking:i,target:r,minify:!n,jsx:"transform",jsxFactory:"React.createElement",format:"esm",charset:"utf8",logLevel:n?"warning":"error",define:{"process.env.NODE_ENV":n?JSON.stringify("development"):JSON.stringify("production")}},b=["esbuild","*.png"],D={...v,bundle:i,absWorkingDir:h,outbase:"src",outdir:"dist",assetNames:"[name].js",format:"esm",target:"esnext",platform:_?.platform??"node",write:!a,external:i?b:void 0,banner:i?{js:qE}:void 0},P="";if(l){u.log("Building file from stdin",{stdin:l,stdinFile:f,noWrite:a}),f||(xe(T.red("ERROR: --stdin-file must be specified to emulate a file location when using stdin.")),process.exit(1)),typeof l=="string"&&l.length?P=l:P=await _o();let c={...v,sourcefile:f,loader:"tsx",banner:void 0,footer:void 0};if(a)return(await NE(P,c)).code;{let k=Rc(P,f,"tsx");await Eo({...D,...k}),xe(T.green("Successfully built stdin file to dist/.")),xe(T.grey("Use --no-write to print to stdout instead."));return}}u.log("Building",{files:e,dev:n,runtimeOnly:s}),wc(`${T.bold("TS Module")} [${Bc.NODE_ENV}]`);let U=mo.default.sync(e,{cwd:h}).filter(c=>kE(c)!==".d.ts").map(c=>lr(c));if(LE(e)){U.length||U.push(e);let c=e.replace(A,C).replace(Mt,".js").replace(pt,".js");u.log("Cleaning emitted file:",{outfile:c}),await Sc(c,{force:!0})}else u.log("Cleaning old output:",{outDir:C}),await Sc(C,{force:!0,recursive:!0});let B=U.filter(c=>pt.test(c));u.log("Compiling TSX files:",{tsxJsxInput:B});let H=B.filter(c=>!c.endsWith(".d.ts"));await Promise.all(H.map(async c=>{let k=await Ic(c,"utf-8"),F=ME+k,le=Rc(F,c,"tsx");await Eo({...D,...le})})),_e("Built TSX files.").succeed();let R=U.filter(c=>Mt.test(c)).filter(c=>!pt.test(c));u.log("Compiling TS files:",{tsJsInput:R}),await Eo({...D,entryPoints:R.filter(c=>!c.endsWith(".d.ts"))}),_e("Built TS files.").succeed();let x=U.filter(c=>!Cc.test(c));u.log("Copying non-JS/TS files.",{allFiles:U,nonTsJsInput:x});for(let c of x){let k=uo(c);u.log("Copying non-source file:",{file:c,emittedFile:k}),await OE(Tc(k),{recursive:!0}),await TE(c,k,IE.COPYFILE_FICLONE)}if(!process.env.NO_REWRITES){let c=e.replace(A,C).replace(/^(\.\/)?src\//,"dist/").replace(Mt,".js").replace(pt,".js");u.log("Normalizing import specifiers in emitted JS.",{emittedJs:c}),await go(c.endsWith(".js")?c:`${c}.js`),_e("Normalized import specifiers.").succeed()}if(await FE()&&_e('Forced "type": "module" in output.').succeed(),s)return;if(!o)if(yo(PE(t))){u.log("Building styles for production.");let{style:c="./dist/bundle.css"}=_;if(u.log("Building style bundle.",{bundleInput:t,bundleOutput:c,dev:n}),await Qc(t,c,n),i){u.log("Bundling all styles.");let k=mo.default.sync("dist/**/*.css"),F=_e("Bundling emitted styles.").start();await Promise.all(k.map(async le=>await Qc(le,le,n))),F.succeed(`Bundled all styles to ${T.bold(c)}.`)}}else xe(T.grey(`Bundle styles not found for this project.
|
31
31
|
\rChecked: `+T.bold(t)));wc("Running post-build setup.");let z=_e("Generating type declarations.").start();await fo(),z.succeed(`Generated delcarations for ${U.length} files.`),xe(T.green("Build complete."))};import{dirname as HE,resolve as jE}from"path";import{fileURLToPath as $E}from"url";var Co={default:[],react:["react@^17.0.2","react-dom@^17.0.2"]},bo={default:["@types/node","@tsmodule/tsmodule","@typescript-eslint/eslint-plugin","@typescript-eslint/parser","ava","eslint","typescript"],react:["next","@types/react@^17.0.39","@types/react-dom@^17.0.11","@tsmodule/react","eslint","eslint-config-next","tailwindcss","autoprefixer","cssnano","postcss","postcss-import"]},xn=jE(HE($E(import.meta.url)),"..");import{mkdir as GE}from"fs/promises";import{resolve as Oc}from"path";var vo=async(e,t)=>{let r=me(),n=Oc(xn,`./templates/${e}`),i=Oc(t);await GE(i,{recursive:!0}),await r.run({posix:`cp -rf ${n}/. ${i}`,win32:`xcopy /E /I /Q /Y ${n}\\ ${i}\\`})};import Dc from"fs/promises";import{resolve as UE}from"path";var kc=async e=>{let t=UE(process.cwd(),e,"package.json"),r=await Dc.readFile(t,"utf-8"),n=JSON.parse(r);n.name=e,await Dc.writeFile(t,JSON.stringify(n,null,2))};globalThis.SHELL_OPTIONS={stdio:["ignore","ignore","inherit"]};var yv=async(e,{react:t=!1})=>{let r=me(),n=_e(`Creating new module ${T.blueBright(e)}.`).start();await vo("default",e),t&&await vo("react",e),await kc(e),n.succeed("Project created."),process.chdir(e);let i=[...Co.default],s=[...bo.default];t&&(i.push(...Co.react),s.push(...bo.react)),i.length&&await r.run(`yarn add ${i.join(" ")}`),s.length&&await r.run(`yarn add -D ${s.join(" ")}`),n.succeed("Dependencies installed."),await r.run("git init"),n.succeed("Set up as Git repository.")};import{relative as om,resolve as am}from"path";import{existsSync as lm}from"fs";import{lstat as um}from"fs/promises";var tA=He(Zc(),1);var zc=()=>{console.clear()},eA=e=>{xe(`
|
32
32
|
`,T.gray(`Built ${T.bold(e)}.`),`
|
33
|
-
`,T.blue(new Date().toLocaleString()))},Dv=async()=>{let e=process.cwd(),t=me();process.platform!=="win32"&&await t.run("clear"),zc(),await vn({dev:!0}),eA("src/**/*"),(0,tA.default)(am(e,"src"),{recursive:!0}).on("change",async(r,n)=>{if(!lm(n)||(await um(n)).isDirectory())return;zc();let a=Date.now();await vn({dev:!0,input:n});let l=Date.now()-a;_e(T.blueBright(`Dev refresh finished in ${T.bold(`${l}ms`)}.`)).succeed(),eA(om(e,n))})};import{pathToFileURL as fm}from"url";import{resolve as cm}from"path";var Fv=async()=>{let e=cm(xn,"dist/loader/index.js"),t=["--no-warnings","--loader",fm(e).href,...process.argv.slice(2)];await me().run(`node ${t.join(" ")}`)};export{wc as bannerLog,vn as build,yv as create,Dv as dev,Fv as execute,go as normalizeImportSpecifiers};
|
33
|
+
`,T.blue(new Date().toLocaleString()))},Dv=async()=>{let e=process.cwd(),t=me();process.platform!=="win32"&&await t.run("clear"),zc(),await vn({dev:!0}),eA("src/**/*"),(0,tA.default)(am(e,"src"),{recursive:!0}).on("change",async(r,n)=>{if(!lm(n)||(await um(n)).isDirectory())return;zc();let a=Date.now();await vn({dev:!0,runtimeOnly:!0,input:n});let l=Date.now()-a;_e(T.blueBright(`Dev refresh finished in ${T.bold(`${l}ms`)}.`)).succeed(),eA(om(e,n))})};import{pathToFileURL as fm}from"url";import{resolve as cm}from"path";var Fv=async()=>{let e=cm(xn,"dist/loader/index.js"),t=["--no-warnings","--loader",fm(e).href,...process.argv.slice(2)];await me().run(`node ${t.join(" ")}`)};export{wc as bannerLog,vn as build,yv as create,Dv as dev,Fv as execute,go as normalizeImportSpecifiers};
|
34
34
|
/*!
|
35
35
|
* fill-range <https://github.com/jonschlinkert/fill-range>
|
36
36
|
*
|