build-ts 3.2.2 → 3.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.mjs +1 -1
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import e from"yargs";import{hideBin as o}from"yargs/helpers";import r from"node:fs";import t from"node:path";import{rollup as n}from"rollup";import i from"node:url";import{babel as s}from"@rollup/plugin-babel";import a from"@rollup/plugin-commonjs";import p from"@rollup/plugin-json";import c from"@rollup/plugin-node-resolve";import l from"@rollup/plugin-replace";import m from"@rollup/plugin-terser";import d from"rollup-plugin-analyzer";import{externals as u}from"rollup-plugin-node-externals";import{string as f}from"rollup-plugin-string";import g from"rollup-plugin-ts";import h from"dotenv";import*as b from"node:child_process";async function y(e){try{const o=await r.promises.readFile(t.join(e,"package.json"),"utf8");return JSON.parse(o)}catch{}}function j(e){const o={};for(const r of(e.env??[]).map((e=>e.toString())))void 0!==process.env[r]&&(o[`process.env.${r}`]=JSON.stringify(process.env[r]));for(const r of e.dotenv??[]){const e=h.config({path:r.toString()}).parsed||{};for(const[r,t]of Object.entries(e))void 0!==t&&(o[`process.env.${r}`]=JSON.stringify(t))}return o}function v(e,o,r){const n=[...e.external??[]].map((e=>e.toString()));o?.dependencies?.["@prisma/client"]&&n.push("prisma-client");const h=[".cjs",".mjs",".js",".jsx",".json",".cts",".mts",".ts",".tsx"],b=t.join(i.fileURLToPath(t.dirname(t.dirname(import.meta.url))),"babel.config.mjs"),y=[l({delimiters:["",""],preventAssignment:!0,values:j(e)}),p(),u({deps:!0,devDeps:!1,include:n,exclude:r&&new RegExp(`${r}\\/.+`)}),c({extensions:h}),a()];return"app"===e.target?y.push(s({configFile:b,extensions:h,babelHelpers:"bundled",exclude:"node_modules/**"})):y.push(g({transpiler:"babel",babelConfig:b})),y.push(f({include:["**/*.csv","**/*.txt"]})),e.minify&&y.push(m()),y.push(d({summaryOnly:!0})),y}const x={command:"build [package]",describe:"Build a package",builder:{target:{description:"A target format: app, lib or functions",type:"string",require:!0,alias:"t"},input:{description:'A file path of main source code. Default value is "src/index.ts" from package directory.',type:"string",alias:"i"},"core-js":{description:"Whether or not core-js is employed.",type:"boolean",default:!1},minify:{description:"Whether or not minification is enabled.",type:"boolean",default:!0},sourcemap:{description:"Whether or not sourcemap is enabled.",type:"boolean",default:!0},external:{description:"Additional external dependencies.",type:"array"},verbose:{description:"Whether or not verbose mode is enabled.",type:"boolean",alias:"v"},env:{description:"Environment variables to be inlined.",type:"array",alias:"e"},dotenv:{description:".env files to be inlined.",type:"array"}},async handler(e){"app"!==e.target&&"lib"!==e.target&&"functions"!==e.target&&(console.error('target option must be "app", "lib" or "functions'),process.exit(1));const o=t.resolve(e.package?.toString()??"."),i=await y(o);i||(console.error("Failed to parse package.json"),process.exit(1)),e.coreJs&&(process.env.BUILD_TS_COREJS="1"),e.verbose&&(process.env.BUILD_TS_VERBOSE="1"),process.env.BUILD_TS_TARGET=e.target;const[s]=function(e){const o=e.name?.toString()||"",r=/@([^/]+)\/(.+)/.exec(o),[,t,n]=r||[];return[t,n]}(i),a=v(e,i,s),p="module"===i.type;let c,l;await r.promises.rm(t.join(o,"dist"),{recursive:!0,force:!0}),"app"===e.target||"functions"===e.target?(i.main=p?"index.mjs":"index.cjs",c=[{file:t.join(o,"dist",i.main),format:p?"module":"commonjs",sourcemap:e.sourcemap}]):c=[{file:t.join(o,"dist","cjs","index.cjs"),format:"commonjs",sourcemap:e.sourcemap},{dir:t.join(o,"dist","esm"),entryFileNames:"[name].mjs",format:"module",preserveModules:!0,sourcemap:e.sourcemap}],0===c.length&&(console.error("Failed to detect output files."),process.exit(1));let m=!1;try{const s=await n({input:e.input||t.join(o,t.join("src","index.ts")),plugins:a});l=s,await Promise.all(c.map((e=>s.write(e)))),"functions"===e.target&&(i.name+="-dist",delete i.devDependencies,await r.promises.writeFile(t.join(o,"dist","package.json"),JSON.stringify(i)))}catch(e){m=!0,console.error("Filed to index due to:",e)}await(l?.close()),m&&process.exit(1)}},w={command:"run <file>",describe:"Run script",builder:{module:{description:"A module type: cjs or esm",type:"string",alias:"m"},watch:{description:"Whether watch mode is enabled or not",type:"boolean",alias:"w"}},async handler(e){const o=e.file?.toString()||"",r=await async function(e,o){if("cjs"===o||e.endsWith(".cts"))return"cjs";if("esm"===o||e.endsWith(".mts"))return"esm";let r=t.dirname(e);for(;;){const e=await y(r);if(e){if("module"===e.type)return"esm";break}const o=t.dirname(r);if(!o||o===r)break;r=o}return"cjs"}(o,e.module),n=["--no-warnings"];e.watch&&n.push("--watch"),"cjs"===r?n.push("--require","ts-node/register"):n.push("--loader","ts-node/esm"),n.push(o);const[,...i]=e._;b.spawnSync("node",[...n,...i.map((e=>e.toString()))],{shell:!0,stdio:"inherit",env:{...process.env,TS_NODE_TRANSPILE_ONLY:"1"}})}};await e(o(process.argv)).command(x).command(w).demandCommand().strict().help().argv;
1
+ import e from"yargs";import{hideBin as o}from"yargs/helpers";import r from"node:fs";import t from"node:path";import{rollup as n}from"rollup";import i from"node:url";import{babel as s}from"@rollup/plugin-babel";import a from"@rollup/plugin-commonjs";import p from"@rollup/plugin-json";import c from"@rollup/plugin-node-resolve";import l from"@rollup/plugin-replace";import m from"@rollup/plugin-terser";import d from"rollup-plugin-analyzer";import{externals as u}from"rollup-plugin-node-externals";import{string as f}from"rollup-plugin-string";import g from"rollup-plugin-ts";import h from"dotenv";import*as b from"node:child_process";async function j(e){try{const o=await r.promises.readFile(t.join(e,"package.json"),"utf8");return JSON.parse(o)}catch{}}function y(e,o){const r={};for(const o of(e.env??[]).map((e=>e.toString())))void 0!==process.env[o]&&(r[`process.env.${o}`]=JSON.stringify(process.env[o]));for(const n of e.dotenv??[]){const e=h.config({path:t.join(o,n.toString())}).parsed||{};for(const[o,t]of Object.entries(e))void 0!==t&&(r[`process.env.${o}`]=JSON.stringify(t))}return r}function v(e,o,r,n){const h=[...e.external??[]].map((e=>e.toString()));o?.dependencies?.["@prisma/client"]&&h.push("prisma-client");const b=[".cjs",".mjs",".js",".jsx",".json",".cts",".mts",".ts",".tsx"],j=t.join(i.fileURLToPath(t.dirname(t.dirname(import.meta.url))),"babel.config.mjs"),v=[l({delimiters:["",""],preventAssignment:!0,values:y(e,n)}),p(),u({deps:!0,devDeps:!1,include:h,exclude:r&&new RegExp(`${r}\\/.+`)}),c({extensions:b}),a()];return"app"===e.target?v.push(s({configFile:j,extensions:b,babelHelpers:"bundled",exclude:"node_modules/**"})):v.push(g({transpiler:"babel",babelConfig:j})),v.push(f({include:["**/*.csv","**/*.txt"]})),e.minify&&v.push(m()),v.push(d({summaryOnly:!0})),v}const x={command:"build [package]",describe:"Build a package",builder:{target:{description:"A target format: app, lib or functions",type:"string",require:!0,alias:"t"},input:{description:'A file path of main source code. Default value is "src/index.ts" from package directory.',type:"string",alias:"i"},"core-js":{description:"Whether or not core-js is employed.",type:"boolean",default:!1},minify:{description:"Whether or not minification is enabled.",type:"boolean",default:!0},sourcemap:{description:"Whether or not sourcemap is enabled.",type:"boolean",default:!0},external:{description:"Additional external dependencies.",type:"array"},verbose:{description:"Whether or not verbose mode is enabled.",type:"boolean",alias:"v"},env:{description:"Environment variables to be inlined.",type:"array",alias:"e"},dotenv:{description:".env files to be inlined.",type:"array"}},async handler(e){const o=process.cwd();"app"!==e.target&&"lib"!==e.target&&"functions"!==e.target&&(console.error('target option must be "app", "lib" or "functions"'),process.exit(1));const i=t.resolve(e.package?.toString()??"."),s=await j(i);s||(console.error("Failed to parse package.json"),process.exit(1));const[a]=function(e){const o=e.name?.toString()||"",r=/@([^/]+)\/(.+)/.exec(o),[,t,n]=r||[];return[t,n]}(s),p="module"===s.type;let c,l;e.coreJs&&(process.env.BUILD_TS_COREJS="1"),e.verbose&&(process.env.BUILD_TS_VERBOSE="1"),process.env.BUILD_TS_TARGET=e.target,"app"===e.target||"functions"===e.target?(s.main=p?"index.mjs":"index.cjs",c=[{file:t.join(i,"dist",s.main),format:p?"module":"commonjs",sourcemap:e.sourcemap}]):c=[{file:t.join(i,"dist","cjs","index.cjs"),format:"commonjs",sourcemap:e.sourcemap},{dir:t.join(i,"dist","esm"),entryFileNames:"[name].mjs",format:"module",preserveModules:!0,sourcemap:e.sourcemap}],0===c.length&&(console.error("Failed to detect output files."),process.exit(1));let m=!1;try{process.chdir(i);const[p]=await Promise.all([n({input:e.input?t.join(o,e.input):t.join(i,t.join("src","index.ts")),plugins:v(e,s,a,o)}),r.promises.rm(t.join(i,"dist"),{recursive:!0,force:!0})]);l=p,await Promise.all(c.map((e=>p.write(e)))),"functions"===e.target&&(s.name+="-dist",delete s.devDependencies,await r.promises.writeFile(t.join(i,"dist","package.json"),JSON.stringify(s)))}catch(e){m=!0,console.error("Filed to index due to:",e)}await(l?.close()),m&&process.exit(1)}},w={command:"run <file>",describe:"Run script",builder:{module:{description:"A module type: cjs or esm",type:"string",alias:"m"},watch:{description:"Whether watch mode is enabled or not",type:"boolean",alias:"w"}},async handler(e){const o=e.file?.toString()||"",r=await async function(e,o){if("cjs"===o||e.endsWith(".cts"))return"cjs";if("esm"===o||e.endsWith(".mts"))return"esm";let r=t.dirname(e);for(;;){const e=await j(r);if(e){if("module"===e.type)return"esm";break}const o=t.dirname(r);if(!o||o===r)break;r=o}return"cjs"}(o,e.module),n=["--no-warnings"];e.watch&&n.push("--watch"),"cjs"===r?n.push("--require","ts-node/register"):n.push("--loader","ts-node/esm"),n.push(o);const[,...i]=e._;b.spawnSync("node",[...n,...i.map((e=>e.toString()))],{shell:!0,stdio:"inherit",env:{...process.env,TS_NODE_TRANSPILE_ONLY:"1"}})}};await e(o(process.argv)).command(x).command(w).demandCommand().strict().help().argv;
2
2
  //# sourceMappingURL=index.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "build-ts",
3
- "version": "3.2.2",
3
+ "version": "3.2.3",
4
4
  "repository": "github:WillBooster/build-ts",
5
5
  "license": "UNLICENSED",
6
6
  "author": "WillBooster Inc.",