@tsmodule/tsmodule 28.0.0 → 28.1.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.
@@ -1 +1 @@
1
- import a from"chalk";import{createShell as c}from"await-shell";import d from"ora";import{createTemplate as n}from"./lib/createTemplate.js";import{rewritePkgJson as l}from"./lib/rewritePkgJson.js";globalThis.SHELL_OPTIONS={stdio:["ignore","ignore","inherit"]};const w=async(e,{react:o=!1})=>{const i=c(),s=d(`Creating new module ${a.blueBright(e)}.`).start();await n("default",e),o&&await n("react",e),await l(e),s.succeed("Project created."),process.chdir(e);const r=[],t=["@tsmodule/tsmodule"];o?(r.push("react","react-dom"),t.push("@types/react","@types/react-dom","next","eslint","eslint-config-next","tailwindcss","postcss","postcss-import","autoprefixer")):t.push("@types/node"),r.length&&await i.run(`yarn add ${r.join(" ")}`),t.length&&await i.run(`yarn add -D ${t.join(" ")}`),s.succeed("Dependencies installed."),await i.run("git init"),s.succeed("Git initialized.")};export{w as create};
1
+ import a from"chalk";import{createShell as c}from"await-shell";import d from"ora";import{copyTemplate as n}from"./lib/createTemplate.js";import{rewritePkgJson as l}from"./lib/rewritePkgJson.js";globalThis.SHELL_OPTIONS={stdio:["ignore","ignore","inherit"]};const w=async(e,{react:o=!1})=>{const i=c(),s=d(`Creating new module ${a.blueBright(e)}.`).start();await n("default",e),o&&await n("react",e),await l(e),s.succeed("Project created."),process.chdir(e);const r=[],t=["@tsmodule/tsmodule"];o?(r.push("react","react-dom"),t.push("@types/react","@types/react-dom","next","eslint","eslint-config-next","tailwindcss","postcss","postcss-import","autoprefixer")):t.push("@types/node"),r.length&&await i.run(`yarn add ${r.join(" ")}`),t.length&&await i.run(`yarn add -D ${t.join(" ")}`),s.succeed("Dependencies installed."),await i.run("git init"),s.succeed("Git initialized.")};export{w as create};
@@ -1 +1 @@
1
- import{fileURLToPath as m,URL as p}from"url";import{copy as s}from"fs-extra";import{resolve as a}from"path";const f=async(t,e)=>{const o=process.cwd(),r=new p(`../../../../templates/${t}`,import.meta.url);await s(m(r),a(o,e))};export{f as createTemplate};
1
+ import{fileURLToPath as m,URL as p}from"url";import{copy as s}from"fs-extra";import{resolve as c}from"path";const w=async(t,e)=>{const r=process.cwd(),o=new p(`../../../../templates/${t}`,import.meta.url);await s(m(o),c(r,e),{overwrite:!0,recursive:!0})};export{w as copyTemplate};
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
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.
2
+ var r="@tsmodule/tsmodule",s="node",a="module",d="28.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
4
  Run TS directly: ${t.bold("tsmodule src/index.ts")}
5
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.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@tsmodule/tsmodule",
3
3
  "platform": "node",
4
4
  "type": "module",
5
- "version": "28.0.0",
5
+ "version": "28.1.0",
6
6
  "repository": "tsmodule/tsmodule",
7
7
  "description": "TypeScript Module loader and compiler",
8
8
  "license": "MIT",
@@ -1,5 +1,30 @@
1
- This is a TS module. Build it with tsmodule via:
1
+ # `tsmodule` library
2
2
 
3
- ```shell
3
+ This is a [`tsmodule`](https://github.com/tsmodule/tsmodule) library. By
4
+ default, it is assumed to be a Node program, but this can be adjusted via the
5
+ `platform` field in package.json.
6
+
7
+ #### Develop
8
+
9
+ Rebuild on changes with `tsmodule dev` or the `yarn dev` script:
10
+
11
+ ```bash
12
+ yarn dev
13
+ # calls `tsmodule dev`
14
+ ```
15
+
16
+ #### Export and publish
17
+
18
+ To export your component library, use `tsmodule build` or the `yarn build`
19
+ script:
20
+
21
+ ```bash
4
22
  yarn build
23
+ # calls `tsmodule build`
24
+ ```
25
+
26
+ You can then publish to NPM:
27
+
28
+ ```bash
29
+ yarn publish
5
30
  ```
@@ -0,0 +1,30 @@
1
+ # `tsmodule` component library
2
+
3
+ This is a [`tsmodule`](https://github.com/tsmodule/tsmodule) component library
4
+ developed and previewed with Next.js.
5
+
6
+ #### Develop
7
+
8
+ To start the Next server and develop your components, use `next dev` or the
9
+ `yarn dev` script:
10
+
11
+ ```bash
12
+ yarn dev
13
+ # calls `next dev`
14
+ ```
15
+
16
+ #### Export and publish
17
+
18
+ To export your component library, use `tsmodule build` or the `yarn export`
19
+ script:
20
+
21
+ ```bash
22
+ yarn export
23
+ # calls `tsmodule build`
24
+ ```
25
+
26
+ You can then publish to NPM:
27
+
28
+ ```bash
29
+ yarn publish
30
+ ```
@@ -1,17 +0,0 @@
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 +0,0 @@
1
- export declare const emitTsDeclarations: (files: string[]) => void;
@@ -1,3 +0,0 @@
1
- export declare const create: (name: string, { react }: {
2
- react?: boolean;
3
- }) => Promise<void>;
@@ -1 +0,0 @@
1
- export declare const createTemplate: (template: string, projectName: string) => Promise<void>;
@@ -1 +0,0 @@
1
- export declare const rewritePkgJson: (projectName: string) => Promise<void>;
@@ -1 +0,0 @@
1
- export declare const dev: () => Promise<void>;
@@ -1 +0,0 @@
1
- export declare const execute: () => Promise<void>;
@@ -1,19 +0,0 @@
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>;
@@ -1,13 +0,0 @@
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 {};
package/dist/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,11 +0,0 @@
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;
@@ -1,22 +0,0 @@
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
- }>;
@@ -1,4 +0,0 @@
1
- declare global {
2
- const PACKAGE_JSON: Record<string, unknown>;
3
- }
4
- export * from "../loader/types";
@@ -1,5 +0,0 @@
1
- export declare const getWorkingDirs: () => {
2
- cwd: string;
3
- srcDir: string;
4
- outDir: string;
5
- };
@@ -1,2 +0,0 @@
1
- export declare const getPackageJsonFile: () => Promise<string>;
2
- export declare const getPackageJson: () => Promise<any>;
@@ -1,28 +0,0 @@
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;
@@ -1 +0,0 @@
1
- export declare const readStdin: () => Promise<string>;