@tsmodule/tsmodule 9.0.1 → 9.0.6

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/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  <div align="center">
2
2
  <img src="assets/tsmodule.png">
3
- <h3>TypeScript Module Toolkit</h3>
3
+ <h4>TypeScript Module Toolkit</h4>
4
4
  </div>
5
5
 
6
- ## Features
6
+ ---
7
7
 
8
8
  ### Quickly create TypeScript projects with **`tsmodule create`**
9
9
 
@@ -1,3 +1,3 @@
1
- import{build as d}from"esbuild";import{existsSync as h,readFileSync as k,writeFileSync as w}from"fs";import{extname as x,resolve as u}from"path";import l from"chalk";import{env as F}from"process";import T from"fast-glob";import i from"ora";import{rm as B}from"fs/promises";import{createDebugLogger as E,log as a}from"create-debug-logger";import{isTs as N,isTsxOrJsx as g}from"../../utils/index.js";import{emitTsDeclarations as O}from"./lib/emitTsDeclarations.js";import{getPackageJsonFile as J}from"../../utils/pkgJson.js";import{normalizeImportSpecifiers as j}from"../normalize/index.js";const y=t=>{a(l.bgBlue(l.white(` ${t} `)))},D=async({dev:t=!1,fast:b=!1})=>{t&&(F.NODE_ENV="development");const r=E(D);t||y("Building for production.");const n=process.cwd(),S=await J(),c={absWorkingDir:n,outbase:"src",outdir:"dist",assetNames:"[name].js",logLevel:t?"debug":"error",charset:"utf8",format:"esm",target:"esnext",minify:!t,define:{PACKAGE_JSON:S}},m=u(n,"dist");r.log("Cleaning old output:",{distDir:m}),await B(m,{force:!0,recursive:!0}),console.log();const s=T.sync("src/**/*",{cwd:n}).filter(e=>x(e)!==".d.ts").map(e=>u(e)),f=s.filter(e=>N.test(e)).filter(e=>!g.test(e));r.log("Compiling TS files:",{tsFiles:f}),await d({...c,entryPoints:f.filter(e=>!e.endsWith(".d.ts"))}),i("Built TS files.").succeed();const p=s.filter(e=>g.test(e));if(r.log("Compiling TSX files:",{tsxFiles:p}),await d({...c,entryPoints:p.filter(e=>!e.endsWith(".d.ts")),jsxFactory:"createElement",banner:{js:`import { createElement } from 'react';
1
+ import{build as d}from"esbuild";import{existsSync as h,readFileSync as k,writeFileSync as w}from"fs";import{extname as x,resolve as u}from"path";import l from"chalk";import{env as F}from"process";import T from"fast-glob";import i from"ora";import{rm as B}from"fs/promises";import{createDebugLogger as E,log as a}from"create-debug-logger";import{isTs as N,isTsxOrJsx as g}from"../../utils/index.js";import{emitTsDeclarations as O}from"./lib/emitTsDeclarations.js";import{getPackageJsonFile as J}from"../../utils/pkgJson.js";import{normalizeImportSpecifiers as j}from"../normalize/index.js";const y=t=>{a(l.bgBlue(l.white(` ${t} `)))},D=async({dev:t=!1,fast:b=!1})=>{t&&(F.NODE_ENV="development");const r=E(D);t||y("Building for production.");const n=process.cwd(),S=await J(),c={absWorkingDir:n,outbase:"src",outdir:"dist",assetNames:"[name].js",logLevel:t?"debug":"error",charset:"utf8",format:"esm",target:"esnext",minify:!t,define:{PACKAGE_JSON:S}},m=u(n,"dist");r.log("Cleaning old output:",{distDir:m}),await B(m,{force:!0,recursive:!0}),console.log();const s=T.sync("src/**/*",{cwd:n}).filter(e=>x(e)!==".d.ts").map(e=>u(e)),f=s.filter(e=>N.test(e)).filter(e=>!g.test(e));r.log("Compiling TS files:",{tsFiles:f}),await d({...c,entryPoints:f.filter(e=>!e.endsWith(".d.ts"))}),i("Built TS files.").succeed();const p=s.filter(e=>g.test(e));if(r.log("Compiling TSX files:",{tsxFiles:p}),await d({...c,entryPoints:p.filter(e=>!e.endsWith(".d.ts")),jsxFactory:"createElement",banner:{js:`import { createElement } from "react";
2
2
  `}}),i("Built TSX files.").succeed(),process.env.NO_REWRITES||(await j(),i("Normalized import specifiers.").succeed(),console.log(),t||b))return;y("Running post-build setup."),a(`Generating type declarations.
3
3
  This might take a moment.`),O(s),i(`Generated delcarations for ${s.length} files.`).succeed();let o;h("dist/package.json")?o=JSON.parse(k("dist/package.json","utf-8")):o={},o.type="module",w("dist/package.json",JSON.stringify(o,null,2)),i('Forced "type": "module" in output.').succeed(),a(l.green("Build complete."))};export{y as bannerLog,D as build};
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- var r="@tsmodule/tsmodule",m="module",a="9.0.1",s="tsmodule/tsmodule",d="TypeScript Module loader and compiler",p="MIT",l={tsmodule:"dist/index.js"},c={".":"./dist/loader/index.js","./*":"./dist/*/index.js","./package.json":"./package.json"},u="dist/types/index.d.ts",f=[{name:"C. Lewis",email:"ctj.lewis@icloud.com",url:"https://ctjlewis.com"}],g=["dist/","template/"],v={node:">=14"},b={bootstrap:"node bootstrap.js",prebuild:"yarn bootstrap",build:"node --no-warnings --loader ./dist/loader/index.js src/index.ts build",lint:"eslint --fix src",prepare:"yarn build -f",prepublishOnly:"yarn build",test:"ava --no-worker-threads"},S={"await-shell":"^2.7.0",chalk:"^5.0.0",commander:"^8.3.0","create-debug-logger":"^1.10.1",esbuild:"^0.14.0","fast-glob":"^3.2.10",ora:"^6.0.1",path:"^0.12.7",react:"^17.0.2",rollup:"^2.63.0","rollup-plugin-preserve-shebang":"^1.0.1",typescript:"^4.5.5"},h={"@types/node":"17.0.8","@types/react":"17.0.38","@typescript-eslint/eslint-plugin":"^5.9.1","@typescript-eslint/parser":"^5.9.1",ava:"^4.0.1",eslint:"^8.6.0"},w=["esm","loader","typescript","loader hook","require hook","experimental-loader"],y={files:["test/**/*.test.ts"],extensions:{ts:"module"},nodeArguments:["--no-warnings","--loader=@tsmodule/tsmodule"]},t={name:r,type:m,version:a,repository:s,description:d,license:p,bin:l,exports:c,types:u,contributors:f,files:g,engines:v,scripts:b,dependencies:S,devDependencies:h,keywords:w,ava:y};import i from"chalk";import{Command as B}from"commander";import{build as T}from"./commands/build/index.js";import{create as A}from"./commands/create/index.js";import{execute as C}from"./commands/execute/index.js";import{normalizeImportSpecifiers as E}from"./commands/normalize/index.js";const{version:j}=t,e=new B;e.name(i.bold(i.blueBright("tsmodule"))).description(i.blueBright("A tool for building TypeScript modules.")).version(String(j)),e.command("run",{isDefault:!0}).argument("<file>","The file to run.").option("--d, --dev","Enable development mode").description("Run the given TS program, analogous to `node <file>`.").action(C),e.command("build").option("-d, --dev","Build development version (default: production)").option("-f, --fast","Do not emit type declarations, only transform to JS.").description("Builds TS files to output in dist/.").action(T),e.command("create <name>").description("Create a new project.").action(A),e.command("normalize [files]").description(`Rewrites import specifiers in files to ESM-compliant paths.
2
+ var r="@tsmodule/tsmodule",m="module",a="9.0.6",s="tsmodule/tsmodule",d="TypeScript Module loader and compiler",p="MIT",l={tsmodule:"dist/index.js"},c={".":"./dist/loader/index.js","./*":"./dist/*/index.js","./package.json":"./package.json"},u="dist/types/index.d.ts",f=[{name:"C. Lewis",email:"ctj.lewis@icloud.com",url:"https://ctjlewis.com"}],g=["dist/","template/"],v={node:">=14"},b={bootstrap:"node bootstrap.js",prebuild:"yarn bootstrap",build:"node --no-warnings --loader ./dist/loader/index.js src/index.ts build",lint:"eslint --fix src",prepare:"yarn build -f",prepublishOnly:"yarn build && yarn test",test:"ava --no-worker-threads"},S={"await-shell":"^2.7.0",chalk:"^5.0.0",commander:"^8.3.0","create-debug-logger":"^1.10.1",esbuild:"^0.14.0","fast-glob":"^3.2.10",ora:"^6.0.1",path:"^0.12.7",react:"^17.0.2",rollup:"^2.63.0","rollup-plugin-preserve-shebang":"^1.0.1",typescript:"^4.5.5"},h={"@types/node":"17.0.8","@types/react":"17.0.38","@typescript-eslint/eslint-plugin":"^5.9.1","@typescript-eslint/parser":"^5.9.1",ava:"^4.0.1",eslint:"^8.6.0"},w=["esm","loader","typescript","loader hook","require hook","experimental-loader"],y={files:["test/**/*.test.ts"],extensions:{ts:"module"},nodeArguments:["--no-warnings","--loader=@tsmodule/tsmodule"]},t={name:r,type:m,version:a,repository:s,description:d,license:p,bin:l,exports:c,types:u,contributors:f,files:g,engines:v,scripts:b,dependencies:S,devDependencies:h,keywords:w,ava:y};import i from"chalk";import{Command as B}from"commander";import{build as T}from"./commands/build/index.js";import{create as A}from"./commands/create/index.js";import{execute as C}from"./commands/execute/index.js";import{normalizeImportSpecifiers as E}from"./commands/normalize/index.js";const{version:j}=t,e=new B;e.name(i.bold(i.blueBright("tsmodule"))).description(i.blueBright("A tool for building TypeScript modules.")).version(String(j)),e.command("run",{isDefault:!0}).argument("<file>","The file to run.").option("--d, --dev","Enable development mode").description("Run the given TS program, analogous to `node <file>`.").action(C),e.command("build").option("-d, --dev","Build development version (default: production)").option("-f, --fast","Do not emit type declarations, only transform to JS.").description("Builds TS files to output in dist/.").action(T),e.command("create <name>").description("Create a new project.").action(A),e.command("normalize [files]").description(`Rewrites import specifiers in files to ESM-compliant paths.
3
3
  (default: dist/**/*.js)`).action(async({files:n})=>{await E(n)}),e.parse(process.argv);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tsmodule/tsmodule",
3
3
  "type": "module",
4
- "version": "9.0.1",
4
+ "version": "9.0.6",
5
5
  "repository": "tsmodule/tsmodule",
6
6
  "description": "TypeScript Module loader and compiler",
7
7
  "license": "MIT",
@@ -34,7 +34,7 @@
34
34
  "build": "node --no-warnings --loader ./dist/loader/index.js src/index.ts build",
35
35
  "lint": "eslint --fix src",
36
36
  "prepare": "yarn build -f",
37
- "prepublishOnly": "yarn build",
37
+ "prepublishOnly": "yarn build && yarn test",
38
38
  "test": "ava --no-worker-threads"
39
39
  },
40
40
  "dependencies": {