@tsmodule/tsmodule 11.0.0 → 12.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/dist/commands/build/index.d.ts +11 -11
- package/dist/commands/build/lib/emitTsDeclarations.d.ts +1 -1
- package/dist/commands/create/index.d.ts +1 -1
- package/dist/commands/dev/index.d.ts +1 -1
- package/dist/commands/dev/index.js +2 -2
- package/dist/commands/execute/index.d.ts +1 -1
- package/dist/commands/normalize/index.d.ts +19 -19
- package/dist/commands/normalize/lib/typescriptApi.d.ts +13 -13
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/loader/index.d.ts +11 -11
- package/dist/loader/types.d.ts +22 -22
- package/dist/types/index.d.ts +4 -4
- package/dist/utils/index.d.ts +27 -27
- package/dist/utils/pkgJson.d.ts +1 -1
- package/package.json +3 -2
- package/template/src/index.ts +0 -0
@@ -1,11 +1,11 @@
|
|
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, dev, fast }: {
|
8
|
-
files?: string;
|
9
|
-
dev?: boolean;
|
10
|
-
fast?: boolean;
|
11
|
-
}) => Promise<void>;
|
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, dev, fast }: {
|
8
|
+
files?: string;
|
9
|
+
dev?: boolean;
|
10
|
+
fast?: boolean;
|
11
|
+
}) => Promise<void>;
|
@@ -1 +1 @@
|
|
1
|
-
export declare const emitTsDeclarations: (files: string[]) => void;
|
1
|
+
export declare const emitTsDeclarations: (files: string[]) => void;
|
@@ -1 +1 @@
|
|
1
|
-
export declare const create: (name: string) => Promise<void>;
|
1
|
+
export declare const create: (name: string) => Promise<void>;
|
@@ -1 +1 @@
|
|
1
|
-
export declare const dev: () => Promise<void>;
|
1
|
+
export declare const dev: () => Promise<void>;
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import{relative as a,resolve as m}from"path";import{build as o}from"../build/index.js";import e from"chalk";import{log as l}from"create-debug-logger";import p from"ora";import
|
1
|
+
import{relative as a,resolve as m}from"path";import{build as o}from"../build/index.js";import e from"chalk";import{log as l}from"create-debug-logger";import p from"ora";import d from"node-watch";import{shell as u}from"await-shell";const s=()=>{console.clear()},i=r=>{l(`
|
2
2
|
`,e.gray(`Built ${e.bold(r)}.`),`
|
3
|
-
`,e.blue(new Date().toLocaleString()))}
|
3
|
+
`,e.blue(new Date().toLocaleString()))},B=async()=>{const r=process.cwd();await u("clear"),s(),await o({dev:!0}),i("src/**/*"),d(m(r,"src"),{recursive:!0,persistent:!0}).on("change",async(f,t)=>{s();const c=Date.now();await o({dev:!0,files:t});const n=Date.now()-c;p(e.blueBright(`Dev refresh finished in ${e.bold(`${n}ms`)}.`)).succeed(),i(a(r,t))})};export{B as dev};
|
@@ -1 +1 @@
|
|
1
|
-
export declare const execute: () => void;
|
1
|
+
export declare const execute: () => void;
|
@@ -1,19 +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>;
|
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 +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 {};
|
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
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
#!/usr/bin/env node
|
2
|
-
export {};
|
1
|
+
#!/usr/bin/env node
|
2
|
+
export {};
|
package/dist/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
-
var r="@tsmodule/tsmodule",d="module",m="
|
2
|
+
var r="@tsmodule/tsmodule",d="module",m="12.0.0",a="tsmodule/tsmodule",s="TypeScript Module loader and compiler",l="MIT",c={tsmodule:"dist/index.js"},p={".":"./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"}],b=["dist/","template/"],v={node:">=14"},g={bootstrap:"node bootstrap.js",bootload:"node --no-warnings --loader ./dist/loader/index.js src/index.ts build -f",prebuild:"yarn bootstrap && yarn bootload && yarn link -f",build:"tsmodule build",dev:"tsmodule dev",lint:"eslint --fix src",prepare:"yarn build -f",prepublishOnly:"yarn build && yarn test",test:"ava --no-worker-threads"},h={"@types/cross-spawn":"^6.0.2","@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","await-shell":"^14.0.1",chalk:"^5.0.0",chokidar:"^3.5.3",commander:"^8.3.0","create-debug-logger":"^1.10.1","cross-spawn":"^7.0.3",esbuild:"^0.14.0",eslint:"^8.6.0","fast-glob":"^3.2.10","fs-extra":"^10.0.0","node-watch":"^0.7.3",ora:"^6.0.1",path:"^0.12.7",react:"^17.0.2",typescript:"^4.5.5"},S=["esm","loader","typescript","loader hook","require hook","experimental-loader"],w={timeout:"10 minutes",files:["test/**/*.test.ts"],extensions:{ts:"module"},nodeArguments:["--no-warnings","--loader=@tsmodule/tsmodule"]},T={"@types/fs-extra":"^9.0.13"},t={name:r,type:d,version:m,repository:a,description:s,license:l,bin:c,exports:p,types:u,contributors:f,files:b,engines:v,scripts:g,dependencies:h,keywords:S,ava:w,devDependencies:T};import e from"chalk";import{Command as y}from"commander";import{build as B}from"./commands/build/index.js";import{create as A}from"./commands/create/index.js";import{dev as C}from"./commands/dev/index.js";import{execute as E}from"./commands/execute/index.js";import{normalizeImportSpecifiers as R}from"./commands/normalize/index.js";const{version:j}=t,i=new y;i.name(e.white(e.bold("tsmodule"))).usage(e.white(e.bold("<file | command> [options]"))).description(e.blueBright(`A tool for building TypeScript modules.
|
3
3
|
|
4
4
|
Run TS directly: ${e.bold("tsmodule src/index.ts")}
|
5
5
|
Use a command: ${e.bold("tsmodule build")}`)).version(String(j)),i.command("dev").description("Build and watch for changes.").action(C),i.command("build").option("--files <files>","The files to build (default: all)").option("-d, --dev","Build development version").option("-f, --fast","Do not emit type declarations, only transform to JS").description("Builds TS files to output in dist/.").action(B),i.command("create <name>").description("Create a new project.").action(A),i.command("normalize [files]").description(`Rewrites import specifiers in files to ESM-compliant paths.
|
package/dist/loader/index.d.ts
CHANGED
@@ -1,11 +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;
|
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;
|
package/dist/loader/types.d.ts
CHANGED
@@ -1,22 +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
|
-
}>;
|
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
|
+
}>;
|
package/dist/types/index.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
declare global {
|
2
|
-
const PACKAGE_JSON: Record<string, unknown>;
|
3
|
-
}
|
4
|
-
export * from "../loader/types";
|
1
|
+
declare global {
|
2
|
+
const PACKAGE_JSON: Record<string, unknown>;
|
3
|
+
}
|
4
|
+
export * from "../loader/types";
|
package/dist/utils/index.d.ts
CHANGED
@@ -1,27 +1,27 @@
|
|
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 BASE_CONFIG: {
|
6
|
-
format: string;
|
7
|
-
charset: string;
|
8
|
-
sourcemap: string;
|
9
|
-
target: string;
|
10
|
-
minify: boolean;
|
11
|
-
};
|
12
|
-
export declare type ModuleLoaders = {
|
13
|
-
[extension: string]: {
|
14
|
-
[configKey: string]: unknown;
|
15
|
-
};
|
16
|
-
};
|
17
|
-
export declare const MODULE_LOADERS: ModuleLoaders;
|
18
|
-
export declare const POSSIBLE_EXTENSIONS: string[];
|
19
|
-
/**
|
20
|
-
* Force a Unix-like path.
|
21
|
-
*/
|
22
|
-
export declare const normalizeSpecifier: (specifier: string) => string;
|
23
|
-
export declare const fileExists: (fileUrl: string) => string | void;
|
24
|
-
export declare const fileExistsAny: (fileUrls: string[]) => string | void;
|
25
|
-
export declare const checkTsExtensions: (specifier: string) => string | void;
|
26
|
-
export declare const checkJsExtension: (specifier: string) => string | void;
|
27
|
-
export declare const checkExtensions: (specifier: string) => string;
|
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 BASE_CONFIG: {
|
6
|
+
format: string;
|
7
|
+
charset: string;
|
8
|
+
sourcemap: string;
|
9
|
+
target: string;
|
10
|
+
minify: boolean;
|
11
|
+
};
|
12
|
+
export declare type ModuleLoaders = {
|
13
|
+
[extension: string]: {
|
14
|
+
[configKey: string]: unknown;
|
15
|
+
};
|
16
|
+
};
|
17
|
+
export declare const MODULE_LOADERS: ModuleLoaders;
|
18
|
+
export declare const POSSIBLE_EXTENSIONS: string[];
|
19
|
+
/**
|
20
|
+
* Force a Unix-like path.
|
21
|
+
*/
|
22
|
+
export declare const normalizeSpecifier: (specifier: string) => string;
|
23
|
+
export declare const fileExists: (fileUrl: string) => string | void;
|
24
|
+
export declare const fileExistsAny: (fileUrls: string[]) => string | void;
|
25
|
+
export declare const checkTsExtensions: (specifier: string) => string | void;
|
26
|
+
export declare const checkJsExtension: (specifier: string) => string | void;
|
27
|
+
export declare const checkExtensions: (specifier: string) => string;
|
package/dist/utils/pkgJson.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export declare const getPackageJsonFile: () => Promise<string>;
|
1
|
+
export declare const getPackageJsonFile: () => Promise<string>;
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@tsmodule/tsmodule",
|
3
3
|
"type": "module",
|
4
|
-
"version": "
|
4
|
+
"version": "12.0.0",
|
5
5
|
"repository": "tsmodule/tsmodule",
|
6
6
|
"description": "TypeScript Module loader and compiler",
|
7
7
|
"license": "MIT",
|
@@ -46,7 +46,7 @@
|
|
46
46
|
"@typescript-eslint/eslint-plugin": "^5.9.1",
|
47
47
|
"@typescript-eslint/parser": "^5.9.1",
|
48
48
|
"ava": "^4.0.1",
|
49
|
-
"await-shell": "^
|
49
|
+
"await-shell": "^14.0.1",
|
50
50
|
"chalk": "^5.0.0",
|
51
51
|
"chokidar": "^3.5.3",
|
52
52
|
"commander": "^8.3.0",
|
@@ -56,6 +56,7 @@
|
|
56
56
|
"eslint": "^8.6.0",
|
57
57
|
"fast-glob": "^3.2.10",
|
58
58
|
"fs-extra": "^10.0.0",
|
59
|
+
"node-watch": "^0.7.3",
|
59
60
|
"ora": "^6.0.1",
|
60
61
|
"path": "^0.12.7",
|
61
62
|
"react": "^17.0.2",
|
package/template/src/index.ts
CHANGED
File without changes
|