@tsmodule/tsmodule 27.0.1 → 28.0.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/README.md CHANGED
@@ -22,7 +22,7 @@ Supports React via TSX/JSX. Ready with zero config:
22
22
 
23
23
  - Build and watch for changes
24
24
 
25
- ### Run TypeScript directly with **`tsmodule <file>`**
25
+ #### Run TypeScript directly with **`tsmodule <file>`**
26
26
 
27
27
  - Uses Node module loader to resolve TS at runtime
28
28
  - Executable TypeScript files with `#!/usr/bin/env tsmodule`
@@ -133,6 +133,11 @@ And conditional exports in package.json will be configured like so, such that
133
133
  This has no restriction on internal imports between files, only the default
134
134
  configuration for how downstream consumers can import from module subpaths.
135
135
 
136
+ #### Package.json export
137
+
138
+ For information on why the `"./package.json": "./package.json"` export is
139
+ specified, see [#1](https://github.com/tsmodule/tsmodule/issues/1#issuecomment-1065500448).
140
+
136
141
  ## License
137
142
 
138
143
  MIT © [C. Lewis](https://ctjlewis.com)
@@ -0,0 +1,17 @@
1
+ export declare const bannerLog: (msg: string) => void;
2
+ /**
3
+ * Build TS to JS. This will contain incomplete specifiers like `./foo` which
4
+ * could mean many things, all of which is handled by the loader which will
5
+ * resolve them for us.
6
+ */
7
+ export declare const build: ({ files, styles, bundle, dev, target, runtimeOnly, noWrite, stdin, stdinFile, }: {
8
+ files?: string;
9
+ styles?: string;
10
+ bundle?: boolean;
11
+ dev?: boolean;
12
+ target?: string;
13
+ runtimeOnly?: boolean;
14
+ noWrite?: boolean;
15
+ stdin?: string;
16
+ stdinFile?: string;
17
+ }) => Promise<string | import("esbuild").BuildResult>;
@@ -1,4 +1,4 @@
1
- import{dirname as P,extname as X,isAbsolute as K,resolve as R,resolve as F}from"path";import{build as x,transform as U}from"esbuild";import{existsSync as v,mkdirSync as q,readFileSync as h,rmSync as _,writeFileSync as $}from"fs";import c from"chalk";import{env as L}from"process";import H from"fast-glob";import p from"ora";import{createDebugLogger as Q,log as S}from"create-debug-logger";import{isJsOrTs as M,isTs as O,isTsxOrJsx as f}from"../../utils/resolve.js";import{createShell as Y}from"await-shell";import{emitTsDeclarations as Z}from"./lib/emitTsDeclarations.js";import{normalizeImportSpecifiers as ee}from"../normalize/index.js";import{getPackageJsonFile as te}from"../../utils/pkgJson.js";import{getWorkingDirs as A}from"../../utils/cwd.js";import{readStdin as oe}from"../../utils/stdin.js";const se=`import React from "react";
1
+ import{dirname as R,extname as K,isAbsolute as U,resolve as F,resolve as v}from"path";import{build as h,transform as q}from"esbuild";import{existsSync as _,mkdirSync as H,readFileSync as j,rmSync as $,writeFileSync as L}from"fs";import c from"chalk";import{env as M}from"process";import Q from"fast-glob";import m from"ora";import{createDebugLogger as Y,log as y}from"create-debug-logger";import{isJsOrTs as A,isTs as S,isTsxOrJsx as p}from"../../utils/resolve.js";import{createShell as Z}from"await-shell";import{emitTsDeclarations as ee}from"./lib/emitTsDeclarations.js";import{normalizeImportSpecifiers as te}from"../normalize/index.js";import{getPackageJsonFile as oe}from"../../utils/pkgJson.js";import{getWorkingDirs as G}from"../../utils/cwd.js";import{readStdin as se}from"../../utils/stdin.js";const ie=`import React from "react";
2
2
  import ReactDOM from "react-dom";
3
- `,G=t=>{const o=` ${t} `;S(c.bgBlue(c.bold(c.white(o))))},ie=()=>{let t;if(v("dist/package.json")?t=JSON.parse(h("dist/package.json","utf-8")):t={},t?.module==="module")return!0;t.type="module",$("dist/package.json",JSON.stringify(t,null,2))},I=(t,o,d)=>{const{srcDir:i,outDir:u}=A();return o=F(o),{stdin:{contents:t,sourcefile:o,resolveDir:P(o),loader:d},outdir:void 0,outfile:o.replace(M,".js").replace(i,u)}},re=async({files:t="src/**/*",styles:o="src/styles/components/index.css",bundle:d=!1,dev:i=!1,runtimeOnly:u=!1,noWrite:l=!1,stdin:a="",stdinFile:g=""})=>{L.NODE_ENV=i?"development":"production";const s=Q(re),V=Y(),{cwd:w,srcDir:b,outDir:m}=A(),j=await te(),C=JSON.parse(j),J={treeShaking:d,logLevel:i?"warning":"error",charset:"utf8",format:"esm",target:"esnext",minify:!i,define:{PACKAGE_JSON:j,"process.env.NODE_ENV":i?JSON.stringify("development"):JSON.stringify("production")}},T={...J,bundle:d,absWorkingDir:w,outbase:"src",outdir:"dist",assetNames:"[name].js",format:"esm",target:"esnext",platform:C?.platform??"node",write:!l};let y="";if(a){s.log("Building file from stdin",{stdin:a,stdinFile:g,noWrite:l}),!l&&!g&&(S(c.red("ERROR: --stdin-file must be specified when using stdin in write mode.")),process.exit(1)),typeof a=="string"&&a.length?y=a:y=await oe();const e={...J,sourcefile:g,loader:"tsx",banner:void 0,footer:void 0};if(l)return(await U(y,e)).code;{const r=I(y,g,"tsx");return await x({...T,...r})}}s.log("Building",{files:t,dev:i,runtimeOnly:u}),G(`${c.bold("TS Module")} [${L.NODE_ENV}]`);const n=H.sync(t,{cwd:w}).filter(e=>X(e)!==".d.ts").map(e=>F(e));if(K(t)){n.length||n.push(t);const e=t.replace(b,m).replace(O,".js").replace(f,".js");s.log("Cleaning emitted file:",{outfile:e}),_(e,{force:!0})}else s.log("Cleaning old output:",{outDir:m}),_(m,{force:!0,recursive:!0});console.log();const k=n.filter(e=>O.test(e)).filter(e=>!f.test(e));s.log("Compiling TS files:",{tsFiles:k}),await x({...T,entryPoints:k.filter(e=>!e.endsWith(".d.ts"))}),p("Built TS files.").succeed();const D=n.filter(e=>f.test(e));s.log("Compiling TSX files:",{tsxFiles:D});const W=D.filter(e=>!e.endsWith(".d.ts"));await Promise.all(W.map(async e=>{const r=h(e,"utf-8"),E=se+r,B=I(E,e,"tsx");await x({...T,...B,jsxFactory:"React.createElement"})})),p("Built TSX files.").succeed();const N=n.filter(e=>!M.test(e));if(s.log("Copying non-JS/TS files.",{allFiles:n,nonJsTsFiles:N}),await Promise.all(N.map(async e=>{const r=R(w,e).replace(b,m).replace(O,".js").replace(f,".js");s.log("Copying non-source file:",{file:e,outfile:r}),q(P(r),{recursive:!0}),$(r,h(e),{encoding:"binary",flag:"w"})})),!process.env.NO_REWRITES){const e=t.replace(b,m).replace(/^(\.\/)?src\//,"dist/").replace(O,".js").replace(f,".js");await ee(e.endsWith(".js")?e:`${e}.js`),p("Normalized import specifiers.").succeed()}if(ie()&&p('Forced "type": "module" in output.').succeed(),console.log(),!(i||u)){if(v(R(o))){s.log("Building styles for production.");const{style:e="./dist/styles.css"}=C,z=["npx tailwindcss",i?"":"-m","--postcss postcss.config.js",`-i ${o}`,"-o",e];await V.run(z.join(" "))}else s.log("Styles not found.",{styles:o});G("Running post-build setup."),S(`Generating type declarations.
4
- This might take a moment.`),Z(n),p(`Generated delcarations for ${n.length} files.`).succeed(),S(c.green("Build complete."))}};export{G as bannerLog,re as build};
3
+ `,I=t=>{const o=` ${t} `;y(c.bgBlue(c.bold(c.white(o))))},ne=()=>{let t;if(_("dist/package.json")?t=JSON.parse(j("dist/package.json","utf-8")):t={},t?.module==="module")return!0;t.type="module",L("dist/package.json",JSON.stringify(t,null,2))},V=(t,o,f)=>{const{srcDir:i,outDir:O}=G();return o=v(o),{stdin:{contents:t,sourcefile:o,resolveDir:R(o),loader:f},outdir:void 0,outfile:o.replace(A,".js").replace(i,O)}},re=async({files:t="src/**/*",styles:o="src/styles/components/index.css",bundle:f=!1,dev:i=!1,target:O="esnext",runtimeOnly:w=!1,noWrite:d=!1,stdin:l="",stdinFile:u=""})=>{M.NODE_ENV=i?"development":"production";const s=Y(re),W=Z(),{cwd:b,srcDir:T,outDir:a}=G(),C=await oe(),J=JSON.parse(C),k={treeShaking:f,target:O,minify:!i,format:"esm",charset:"utf8",logLevel:i?"warning":"error",define:{PACKAGE_JSON:C,"process.env.NODE_ENV":i?JSON.stringify("development"):JSON.stringify("production")}},x={...k,bundle:f,absWorkingDir:b,outbase:"src",outdir:"dist",assetNames:"[name].js",format:"esm",target:"esnext",platform:J?.platform??"node",write:!d};let g="";if(l){s.log("Building file from stdin",{stdin:l,stdinFile:u,noWrite:d}),!d&&!u&&(y(c.red("ERROR: --stdin-file must be specified when using stdin in write mode.")),process.exit(1)),typeof l=="string"&&l.length?g=l:g=await se();const e={...k,sourcefile:u,loader:"tsx",banner:void 0,footer:void 0};if(d)return(await q(g,e)).code;{const n=V(g,u,"tsx");return await h({...x,...n})}}s.log("Building",{files:t,dev:i,runtimeOnly:w}),I(`${c.bold("TS Module")} [${M.NODE_ENV}]`);const r=Q.sync(t,{cwd:b}).filter(e=>K(e)!==".d.ts").map(e=>v(e));if(U(t)){r.length||r.push(t);const e=t.replace(T,a).replace(S,".js").replace(p,".js");s.log("Cleaning emitted file:",{outfile:e}),$(e,{force:!0})}else s.log("Cleaning old output:",{outDir:a}),$(a,{force:!0,recursive:!0});console.log();const D=r.filter(e=>S.test(e)).filter(e=>!p.test(e));s.log("Compiling TS files:",{tsFiles:D}),await h({...x,entryPoints:D.filter(e=>!e.endsWith(".d.ts"))}),m("Built TS files.").succeed();const N=r.filter(e=>p.test(e));s.log("Compiling TSX files:",{tsxFiles:N});const z=N.filter(e=>!e.endsWith(".d.ts"));await Promise.all(z.map(async e=>{const n=j(e,"utf-8"),B=ie+n,P=V(B,e,"tsx");await h({...x,...P,jsxFactory:"React.createElement"})})),m("Built TSX files.").succeed();const E=r.filter(e=>!A.test(e));if(s.log("Copying non-JS/TS files.",{allFiles:r,nonJsTsFiles:E}),await Promise.all(E.map(async e=>{const n=F(b,e).replace(T,a).replace(S,".js").replace(p,".js");s.log("Copying non-source file:",{file:e,outfile:n}),H(R(n),{recursive:!0}),L(n,j(e),{encoding:"binary",flag:"w"})})),!process.env.NO_REWRITES){const e=t.replace(T,a).replace(/^(\.\/)?src\//,"dist/").replace(S,".js").replace(p,".js");await te(e.endsWith(".js")?e:`${e}.js`),m("Normalized import specifiers.").succeed()}if(ne()&&m('Forced "type": "module" in output.').succeed(),console.log(),!(i||w)){if(_(F(o))){s.log("Building styles for production.");const{style:e="./dist/styles.css"}=J,X=["npx tailwindcss",i?"":"-m","--postcss postcss.config.js",`-i ${o}`,"-o",e];await W.run(X.join(" "))}else s.log("Styles not found.",{styles:o});I("Running post-build setup."),y(`Generating type declarations.
4
+ This might take a moment.`),ee(r),m(`Generated delcarations for ${r.length} files.`).succeed(),y(c.green("Build complete."))}};export{I as bannerLog,re as build};
@@ -0,0 +1 @@
1
+ export declare const emitTsDeclarations: (files: string[]) => void;
@@ -0,0 +1,3 @@
1
+ export declare const create: (name: string, { react }: {
2
+ react?: boolean;
3
+ }) => Promise<void>;
@@ -0,0 +1 @@
1
+ export declare const createTemplate: (template: string, projectName: string) => Promise<void>;
@@ -0,0 +1 @@
1
+ export declare const rewritePkgJson: (projectName: string) => Promise<void>;
@@ -0,0 +1 @@
1
+ export declare const dev: () => Promise<void>;
@@ -0,0 +1 @@
1
+ export declare const execute: () => Promise<void>;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @fileoverview
3
+ * This module contains the logic for normalizing import specifiers. It must use
4
+ * fully-specified filepaths here, since the bootstrap script will compile it
5
+ * with esbuild and then use it to normalize emitted output.
6
+ */
7
+ /**
8
+ * Matches a complete import statement, including the import keyword, as well as
9
+ * dynamic imports, requires, and export statements.
10
+ */
11
+ export declare const generateImportPattern: (importSource: string) => RegExp;
12
+ /**
13
+ * Rewrite an import/export/require statement.
14
+ */
15
+ export declare const rewriteImportStatement: (importStatement: string, specifierToReplace: string, specifierReplacement: string) => string;
16
+ /**
17
+ * Rewrite imports in the emitted JS to ESM-compliant paths.
18
+ */
19
+ export declare const normalizeImportSpecifiers: (files?: string) => Promise<any>;
@@ -0,0 +1,13 @@
1
+ import ts from "typescript";
2
+ export declare const TS_CONFIG: ts.CompilerOptions;
3
+ export declare const compilerHost: ts.CompilerHost;
4
+ interface SpecifierReplacement {
5
+ specifierToReplace: string;
6
+ specifierReplacement: string;
7
+ }
8
+ /**
9
+ * Get the rewritten specifiers for a given module. Import/export specifiers
10
+ * will be resolved ahead-of-time by the TypeScript compiler and returned.
11
+ */
12
+ export declare const getRewrittenSpecifiers: (modulePath: string) => SpecifierReplacement[];
13
+ export {};
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
- var r="@tsmodule/tsmodule",s="node",d="module",a="27.0.0",l="tsmodule/tsmodule",m="TypeScript Module loader and compiler",c="MIT",p={tsmodule:"dist/index.js"},u={".":"./dist/loader/index.js","./*":"./dist/*/index.js","./package.json":"./package.json"},f="dist/types/index.d.ts",b=[{name:"C. Lewis",email:"ctj.lewis@icloud.com",url:"https://ctjlewis.com"}],g=["dist/","templates/"],h={node:">=14"},y={bootstrap:"node bootstrap.js",bootload:"node --no-warnings --loader ./dist/loader/index.js src/index.ts build -r",prebuild:"yarn bootstrap && yarn bootload && yarn link -f",build:"tsmodule build",dev:"tsmodule dev",lint:"eslint --fix src",prepare:"yarn build -r",prepublishOnly:"yarn build && yarn test",pretest:"yarn build -r",test:"ava --no-worker-threads",retest:"SKIP_TEST_SETUP=1 yarn test"},v={"@types/glob":"^7.2.0","@types/node":"^17.0.21","@typescript-eslint/eslint-plugin":"^5.14.0","@typescript-eslint/parser":"^5.14.0",ava:"^4.1.0","await-shell":"^31.0.0",chalk:"^5.0.1",commander:"^9.0.0","create-debug-logger":"^3.0.0",esbuild:"^0.14.25",eslint:"^8.10.0","fast-glob":"^3.2.10","fs-extra":"^10.0.1",glob:"^7.2.0","node-watch":"^0.7.3",ora:"^6.1.0",path:"^0.12.7",typescript:"^4.6.2"},w=["esm","loader","typescript","loader hook","require hook","experimental-loader"],S={timeout:"10 minutes",files:["test/**/*.test.ts"],extensions:{ts:"module"},nodeArguments:["--no-warnings","--loader=@tsmodule/tsmodule"]},T={"@types/fs-extra":"^9.0.13"},n={name:r,platform:s,type:d,version:a,repository:l,description:m,license:c,bin:p,exports:u,types:f,contributors:b,files:g,engines:h,scripts:y,dependencies:v,keywords:w,ava:S,devDependencies:T};import o from"chalk";import{Command as B}from"commander";import{build as R}from"./commands/build/index.js";import{create as x}from"./commands/create/index.js";import{dev as C}from"./commands/dev/index.js";import{execute as j}from"./commands/execute/index.js";import{normalizeImportSpecifiers as k}from"./commands/normalize/index.js";const{version:A}=n,i=new B;i.name(o.white(o.bold("tsmodule"))).usage(o.white(o.bold("<file | command> [options]"))).description(o.blueBright(`A tool for building TypeScript modules.
2
+ var r="@tsmodule/tsmodule",s="node",a="module",d="27.1.0",m="tsmodule/tsmodule",l="TypeScript Module loader and compiler",p="MIT",c={tsmodule:"dist/index.js"},u={".":"./dist/loader/index.js","./*":"./dist/*/index.js","./package.json":"./package.json"},f="dist/types/index.d.ts",g=[{name:"C. Lewis",email:"ctj.lewis@icloud.com",url:"https://ctjlewis.com"}],b=["dist/","templates/"],y={node:">=14"},h={bootstrap:"node bootstrap.js",bootload:"node --no-warnings --loader ./dist/loader/index.js src/index.ts build -r",prebuild:"yarn bootstrap && yarn bootload && yarn link -f",build:"tsmodule build",dev:"tsmodule dev",lint:"eslint --fix src",prepare:"yarn build -r",prepublishOnly:"yarn build && yarn test",pretest:"yarn build -r",test:"ava --no-worker-threads",retest:"SKIP_TEST_SETUP=1 yarn test"},v={"@types/glob":"^7.2.0","@types/node":"^17.0.21","@typescript-eslint/eslint-plugin":"^5.14.0","@typescript-eslint/parser":"^5.14.0",ava:"^4.1.0","await-shell":"^32.0.0",chalk:"^5.0.1",commander:"^9.0.0","create-debug-logger":"^3.0.0",esbuild:"^0.14.25",eslint:"^8.11.0","fast-glob":"^3.2.10","fs-extra":"^10.0.1",glob:"^7.2.0","node-watch":"^0.7.3",ora:"^6.1.0",path:"^0.12.7",typescript:"^4.6.2"},w=["esm","loader","typescript","loader hook","require hook","experimental-loader"],S={timeout:"10 minutes",files:["test/**/*.test.ts"],extensions:{ts:"module"},nodeArguments:["--no-warnings","--loader=@tsmodule/tsmodule"]},R={"@types/fs-extra":"^9.0.13"},n={name:r,platform:s,type:a,version:d,repository:m,description:l,license:p,bin:c,exports:u,types:f,contributors:g,files:b,engines:y,scripts:h,dependencies:v,keywords:w,ava:S,devDependencies:R};import t from"chalk";import{Command as x}from"commander";import{build as B}from"./commands/build/index.js";import{create as C}from"./commands/create/index.js";import{dev as E}from"./commands/dev/index.js";import{execute as T}from"./commands/execute/index.js";import{normalizeImportSpecifiers as A}from"./commands/normalize/index.js";const{version:j}=n,o=new x;o.name(t.white(t.bold("tsmodule"))).usage(t.white(t.bold("<file | command> [options]"))).description(t.blueBright(`A tool for building TypeScript modules.
3
3
 
4
- Run TS directly: ${o.bold("tsmodule src/index.ts")}
5
- Use a command: ${o.bold("tsmodule build")}`)).version(String(A)),i.command("dev").description("Build and watch for changes.").action(C),i.command("build").option("--files <files>","Files to build","src/**/*").option("--styles <styles>","The styles to build","src/styles/components/index.css").option("-b, --bundle","Bundle dependencies",!1).option("-d, --dev","Build development runtime",!1).option("-r, --runtime-only","Do not emit type declarations, only build JS runtime",!1).option("--stdin [source]","Read from a string or stdin.","").option("--stdin-file [file]","File path to mock for stdin.","").option("--no-write","Do not write to disk",!1).description("Builds TS files to output in dist/.").action(async t=>{await R(t)}),i.command("create <name>").option("--react","Create React component library with Next.js").description("Create a new project.").action(x),i.command("normalize [files]").description(`Rewrites import specifiers in files to ESM-compliant paths.
6
- (default: dist/**/*.js)`).action(async({files:t})=>{await k(t)}),i.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(j),i.parse(process.argv);
4
+ Run TS directly: ${t.bold("tsmodule src/index.ts")}
5
+ Use a command: ${t.bold("tsmodule build")}`)).version(String(j)),o.command("dev").description("Build and watch for changes.").action(E),o.command("build").option("--files <files>","Entrypoints to compile.\r","src/**/*").option("--styles <styles>","Specify stylesheet entrypoint.\r","src/styles/components/index.css").option("-t, --target <target>","ECMAScript featureset to target.\r","esnext").option("-b, --bundle","Bundle dependencies into entrypoints.\r",!1).option("-d, --dev","Build development runtime.\r",!1).option("-r, --runtime-only","Do not emit type declarations, only build JS runtime.\r",!1).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.
6
+ For programmatic use alongside { stdin: ... }.`).description("Builds TS files to output in dist/.").action(async i=>{await B(i)}),o.command("create <name>").option("--react","Create React component library with Next.js").description("Create a new project.").action(C),o.command("normalize [files]").description(`Rewrites import specifiers in files to ESM-compliant paths.
7
+ (default: dist/**/*.js)`).action(async({files:i})=>{await A(i)}),o.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(T),o.parse(process.argv);
@@ -0,0 +1,11 @@
1
+ import type { GetFormatHook as ModuleGetFormatHook, LoadHook as ModuleLoadHook, ResolveHook as ModuleResolveHook, TransformHook as ModuleTransformSourceHook } from "./types";
2
+ export declare const resolve: ModuleResolveHook;
3
+ export declare const load: ModuleLoadHook;
4
+ /**
5
+ * @deprecated As of Node 17.
6
+ */
7
+ export declare const getFormat: ModuleGetFormatHook;
8
+ /**
9
+ * @deprecated As of Node 17.
10
+ */
11
+ export declare const transformSource: ModuleTransformSourceHook;
@@ -0,0 +1,22 @@
1
+ export declare type Promisable<T> = Promise<T> | T;
2
+ export declare type ModuleSource = string | SharedArrayBuffer | Uint8Array;
3
+ export declare type ModuleFormat = "builtin" | "commonjs" | "json" | "module" | "wasm";
4
+ export declare type ResolveHook = (specifier: string, context: {
5
+ conditions: string[];
6
+ parentURL?: string;
7
+ }, fallback: ResolveHook) => Promisable<{
8
+ url: string;
9
+ format?: ModuleFormat;
10
+ }>;
11
+ export declare type GetFormatHook = (url: string, context: object, fallback: GetFormatHook) => Promisable<{
12
+ format: ModuleFormat;
13
+ }>;
14
+ export declare type TransformHook = (source: ModuleSource, context: Record<"url" | "format", string>, fallback: TransformHook) => Promisable<{
15
+ source: ModuleSource;
16
+ }>;
17
+ export declare type LoadHook = (url: string, context: {
18
+ format?: ModuleFormat;
19
+ }, fallback: LoadHook) => Promisable<{
20
+ format: ModuleFormat;
21
+ source: ModuleSource;
22
+ }>;
@@ -0,0 +1,4 @@
1
+ declare global {
2
+ const PACKAGE_JSON: Record<string, unknown>;
3
+ }
4
+ export * from "../loader/types";
@@ -0,0 +1,5 @@
1
+ export declare const getWorkingDirs: () => {
2
+ cwd: string;
3
+ srcDir: string;
4
+ outDir: string;
5
+ };
@@ -0,0 +1,2 @@
1
+ export declare const getPackageJsonFile: () => Promise<string>;
2
+ export declare const getPackageJson: () => Promise<any>;
@@ -0,0 +1,28 @@
1
+ export declare const DEVELOPMENT_MODE: boolean;
2
+ export declare const isTs: RegExp;
3
+ export declare const isJs: RegExp;
4
+ export declare const isTsxOrJsx: RegExp;
5
+ export declare const isJsOrTs: RegExp;
6
+ export declare const BASE_CONFIG: {
7
+ format: string;
8
+ charset: string;
9
+ sourcemap: string;
10
+ target: string;
11
+ minify: boolean;
12
+ };
13
+ export declare type ModuleLoaders = {
14
+ [extension: string]: {
15
+ [configKey: string]: unknown;
16
+ };
17
+ };
18
+ export declare const MODULE_LOADERS: ModuleLoaders;
19
+ export declare const POSSIBLE_EXTENSIONS: string[];
20
+ /**
21
+ * Force a Unix-like path.
22
+ */
23
+ export declare const normalizeSpecifier: (specifier: string) => string;
24
+ export declare const fileExists: (fileUrl: string) => string | void;
25
+ export declare const fileExistsAny: (fileUrls: string[]) => string | void;
26
+ export declare const checkTsExtensions: (specifier: string) => string | void;
27
+ export declare const checkJsExtension: (specifier: string) => string | void;
28
+ export declare const checkExtensions: (specifier: string) => string;
@@ -0,0 +1 @@
1
+ export declare const readStdin: () => Promise<string>;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@tsmodule/tsmodule",
3
3
  "platform": "node",
4
4
  "type": "module",
5
- "version": "27.0.1",
5
+ "version": "28.0.0",
6
6
  "repository": "tsmodule/tsmodule",
7
7
  "description": "TypeScript Module loader and compiler",
8
8
  "license": "MIT",
@@ -48,12 +48,12 @@
48
48
  "@typescript-eslint/eslint-plugin": "^5.14.0",
49
49
  "@typescript-eslint/parser": "^5.14.0",
50
50
  "ava": "^4.1.0",
51
- "await-shell": "^31.0.0",
51
+ "await-shell": "^32.0.0",
52
52
  "chalk": "^5.0.1",
53
53
  "commander": "^9.0.0",
54
54
  "create-debug-logger": "^3.0.0",
55
55
  "esbuild": "^0.14.25",
56
- "eslint": "^8.10.0",
56
+ "eslint": "^8.11.0",
57
57
  "fast-glob": "^3.2.10",
58
58
  "fs-extra": "^10.0.1",
59
59
  "glob": "^7.2.0",