@tsmodule/tsmodule 14.0.0 → 15.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,3 +1,3 @@
1
- import{build as w}from"esbuild";import{existsSync as k,readFileSync as x,writeFileSync as F}from"fs";import{extname as O,isAbsolute as B,resolve as p}from"path";import c from"chalk";import{env as h}from"process";import j from"fs/promises";import D from"fast-glob";import o from"ora";import{createDebugLogger as J,log as d}from"create-debug-logger";import{isTs as u,isTsxOrJsx as m}from"../../utils/index.js";import{emitTsDeclarations as P}from"./lib/emitTsDeclarations.js";import{getPackageJsonFile as C}from"../../utils/pkgJson.js";import{normalizeImportSpecifiers as G}from"../normalize/index.js";const E=t=>{d(c.bgBlue(c.white(` ${t} `)))},W=async({files:t="src/**/*",dev:r=!1,fast:f=!1})=>{h.NODE_ENV=r?"development":"production";const s=J(W);s.log("Building",{files:t,dev:r,fast:f}),E(`${c.bold("TS Module")} [${h.NODE_ENV}]`);const N=await C(),i=process.cwd(),g={absWorkingDir:i,outbase:"src",outdir:"dist",assetNames:"[name].js",logLevel:r?"warning":"error",charset:"utf8",format:"esm",target:"esnext",minify:!r,define:{PACKAGE_JSON:N}},b=p(i,"src"),n=p(i,"dist");if(B(t)){const e=t.replace(b,n).replace(u,".js").replace(m,".js");s.log("Cleaning emitted file:",{outfile:e}),await j.rm(e,{force:!0})}else s.log("Cleaning old output:",{outDir:n}),await j.rm(n,{force:!0,recursive:!0});console.log();const l=D.sync(t,{cwd:i}).filter(e=>O(e)!==".d.ts").map(e=>p(e)),y=l.filter(e=>u.test(e)).filter(e=>!m.test(e));s.log("Compiling TS files:",{tsFiles:y}),await w({...g,entryPoints:y.filter(e=>!e.endsWith(".d.ts"))}),o("Built TS files.").succeed();const S=l.filter(e=>m.test(e));if(s.log("Compiling TSX files:",{tsxFiles:S}),await w({...g,entryPoints:S.filter(e=>!e.endsWith(".d.ts")),jsxFactory:"createElement",banner:{js:`import { createElement } from "react";
2
- `}}),o("Built TSX files.").succeed(),process.env.NO_REWRITES)return;const T=t.replace(b,n).replace(/^(\.\/)?src\//,"dist/").replace(u,".js").replace(m,".js");if(await G(T),o("Normalized import specifiers.").succeed(),console.log(),r||f)return;E("Running post-build setup."),d(`Generating type declarations.
3
- This might take a moment.`),P(l),o(`Generated delcarations for ${l.length} files.`).succeed();let a;k("dist/package.json")?a=JSON.parse(x("dist/package.json","utf-8")):a={},a.type="module",F("dist/package.json",JSON.stringify(a,null,2)),o('Forced "type": "module" in output.').succeed(),d(c.green("Build complete."))};export{E as bannerLog,W as build};
1
+ import{build as T}from"esbuild";import{existsSync as O,readFileSync as k,writeFileSync as x}from"fs";import{extname as B,isAbsolute as D,resolve as C,resolve as d}from"path";import m from"chalk";import{copy as P}from"fs-extra";import{env as h}from"process";import J from"fs/promises";import W from"fast-glob";import l from"ora";import{createDebugLogger as $,log as g}from"create-debug-logger";import{isJsOrTs as v,isTs as p,isTsxOrJsx as a}from"../../utils/index.js";import{emitTsDeclarations as G}from"./lib/emitTsDeclarations.js";import{getPackageJsonFile as _}from"../../utils/pkgJson.js";import{normalizeImportSpecifiers as A}from"../normalize/index.js";const E=t=>{g(m.bgBlue(m.white(` ${t} `)))},L=async({files:t="src/**/*",dev:o=!1,fast:y=!1})=>{h.NODE_ENV=o?"development":"production";const s=$(L);s.log("Building",{files:t,dev:o,fast:y}),E(`${m.bold("TS Module")} [${h.NODE_ENV}]`);const F=await _(),r=process.cwd(),S={absWorkingDir:r,outbase:"src",outdir:"dist",assetNames:"[name].js",logLevel:o?"warning":"error",charset:"utf8",format:"esm",target:"esnext",minify:!o,define:{PACKAGE_JSON:F}},f=d(r,"src"),i=d(r,"dist");if(D(t)){const e=t.replace(f,i).replace(p,".js").replace(a,".js");s.log("Cleaning emitted file:",{outfile:e}),await J.rm(e,{force:!0})}else s.log("Cleaning old output:",{outDir:i}),await J.rm(i,{force:!0,recursive:!0});console.log();const n=W.sync(t,{cwd:r}).filter(e=>B(e)!==".d.ts").map(e=>d(e)),j=n.filter(e=>p.test(e)).filter(e=>!a.test(e));s.log("Compiling TS files:",{tsFiles:j}),await T({...S,entryPoints:j.filter(e=>!e.endsWith(".d.ts"))}),l("Built TS files.").succeed();const b=n.filter(e=>a.test(e));s.log("Compiling TSX files:",{tsxFiles:b}),await T({...S,entryPoints:b.filter(e=>!e.endsWith(".d.ts")),jsxFactory:"createElement",banner:{js:`import { createElement } from "react";
2
+ `}}),l("Built TSX files.").succeed();const N=n.filter(e=>!v.test(e));if(s.log("Copying non-JS/TS files."),await Promise.all(N.map(async e=>{const w=C(r,e).replace(f,i).replace(p,".js").replace(a,".js");s.log("Copying non-source file:",{file:e,outfile:w}),await P(e,w)})),process.env.NO_REWRITES)return;const u=t.replace(f,i).replace(/^(\.\/)?src\//,"dist/").replace(p,".js").replace(a,".js");if(await A(u.endsWith(".js")?u:`${u}.js`),l("Normalized import specifiers.").succeed(),console.log(),o||y)return;E("Running post-build setup."),g(`Generating type declarations.
3
+ This might take a moment.`),G(n),l(`Generated delcarations for ${n.length} files.`).succeed();let c;O("dist/package.json")?c=JSON.parse(k("dist/package.json","utf-8")):c={},c.type="module",x("dist/package.json",JSON.stringify(c,null,2)),l('Forced "type": "module" in output.').succeed(),g(m.green("Build complete."))};export{E as bannerLog,L as build};
@@ -1 +1 @@
1
- import{fileURLToPath as d,URL as m}from"url";import g from"chalk";import{copy as f}from"fs-extra";import s from"fs/promises";import u from"ora";import{resolve as a}from"path";import{shell as n}from"await-shell";const S=async t=>{const i=process.cwd(),e=u(`Creating new module ${g.blueBright(t)}.`).start(),c=new m("../../../template",import.meta.url);await f(d(c),a(i,t));const o=a(i,t,"package.json"),l=await s.readFile(o,"utf-8"),r=JSON.parse(l);r.name=t,await s.writeFile(o,JSON.stringify(r,null,2)),e.succeed("Project created."),process.chdir(t);const p=["@tsmodule/tsmodule"];globalThis.SHELL_OPTIONS={stdio:["ignore","ignore","inherit"]},e.start("Installing dependencies."),await n(`yarn add -D ${p.join(" ")}`),e.succeed("Dependencies installed."),e.start("Initializing git."),await n("git init"),e.succeed("Git initialized.")};export{S as create};
1
+ import o from"chalk";import c from"ora";import{shell as r}from"await-shell";import{createTemplate as a}from"./lib/createTemplate.js";import{rewritePkgJson as d}from"./lib/rewritePkgJson.js";globalThis.SHELL_OPTIONS={stdio:["ignore","ignore","inherit"]};const h=async(e,{react:s=!1})=>{const t=c(`Creating new module ${o.blueBright(e)}.`).start();await a("default",e),s&&await a("react",e),await d(e),t.succeed("Project created."),process.chdir(e);const i=[],n=["@tsmodule/tsmodule"];s&&(i.push("react","react-dom"),n.push("next","eslint-config-next","tailwindcss","postcss","autoprefixer")),t.start("Installing dependencies."),i.length&&await r(`yarn add ${i.join(" ")}`),n.length&&await r(`yarn add -D ${n.join(" ")}`),t.succeed("Dependencies installed."),t.start("Initializing git."),await r("git init"),t.succeed("Git initialized.")};export{h as create};
@@ -0,0 +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};
@@ -0,0 +1 @@
1
+ import o from"fs/promises";import{resolve as t}from"path";const p=async s=>{const a=t(process.cwd(),s,"package.json"),n=await o.readFile(a,"utf-8"),e=JSON.parse(n);e.name=s,await o.writeFile(a,JSON.stringify(e,null,2))};export{p as rewritePkgJson};
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- var r="@tsmodule/tsmodule",d="module",m="14.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/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":"^16.0.0",chalk:"^5.0.0",commander:"^8.3.0","create-debug-logger":"^1.10.1",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.
2
+ var r="@tsmodule/tsmodule",a="module",m="15.1.0",d="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",pretest:"yarn build -f",test:"ava --no-worker-threads"},h={"@types/node":"^17.0.15","@types/react":"^17.0.39","@types/react-dom":"^17.0.11","@typescript-eslint/eslint-plugin":"^5.9.1","@typescript-eslint/parser":"^5.9.1",ava:"^4.0.1","await-shell":"^16.0.0",chalk:"^5.0.0",commander:"^8.3.0","create-debug-logger":"^1.10.1",esbuild:"^0.14.0",eslint:"^8.8.0","fast-glob":"^3.2.10","fs-extra":"^10.0.0","node-watch":"^0.7.3",ora:"^6.0.1",path:"^0.12.7",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"]},y={"@types/fs-extra":"^9.0.13"},t={name:r,type:a,version:m,repository:d,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:y};import e from"chalk";import{Command as T}from"commander";import{build as B}from"./commands/build/index.js";import{create as C}from"./commands/create/index.js";import{dev as R}from"./commands/dev/index.js";import{execute as j}from"./commands/execute/index.js";import{normalizeImportSpecifiers as x}from"./commands/normalize/index.js";const{version:A}=t,i=new T;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
- 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.
6
- (default: dist/**/*.js)`).action(async({files:n})=>{await R(n)}),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(E),i.parse(process.argv);
5
+ Use a command: ${e.bold("tsmodule build")}`)).version(String(A)),i.command("dev").description("Build and watch for changes.").action(R),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>").option("--react","Create React component library with Next.js").description("Create a new project.").action(C),i.command("normalize [files]").description(`Rewrites import specifiers in files to ESM-compliant paths.
6
+ (default: dist/**/*.js)`).action(async({files:n})=>{await x(n)}),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);
@@ -1 +1 @@
1
- import{existsSync as i}from"fs";import{fileURLToPath as c}from"url";import{posix as p}from"path";import{sep as x}from"path";const O=!1,h=/\.[mc]?tsx?(?=\?|$)/,S=/\.([mc])?js$/,L=/\.([mc])?[tj]sx$/,e={format:"esm",charset:"utf8",sourcemap:"inline",target:"node16",minify:!1},a={".mts":{...e,loader:"ts"},".jsx":{...e,loader:"jsx"},".tsx":{...e,loader:"tsx"},".cts":{...e,loader:"ts"},".ts":{...e,loader:"ts"},".json":{...e,loader:"json"}},n=Object.keys(a),M=s=>s.split(x).join(p.sep),l=s=>{const t=c(s);if(i(t))return s},r=s=>{for(const t of s)if(l(t))return t},m=s=>{const t=n.filter(o=>o.includes("ts")).concat([".js"]);return r(t.map(o=>s+o))},f=s=>{const t=n.filter(o=>o.includes("js")).concat([".js"]);return r(t.map(o=>s+o))},y=s=>{const t=f(s);if(t)return t;const o=m(s);if(o)return o};export{e as BASE_CONFIG,O as DEVELOPMENT_MODE,a as MODULE_LOADERS,n as POSSIBLE_EXTENSIONS,y as checkExtensions,f as checkJsExtension,m as checkTsExtensions,l as fileExists,r as fileExistsAny,S as isJs,h as isTs,L as isTsxOrJsx,M as normalizeSpecifier};
1
+ import{existsSync as i}from"fs";import{fileURLToPath as c}from"url";import{posix as x}from"path";import{sep as p}from"path";const O=!1,h=/\.[mc]?tsx?(?=\?|$)/,S=/\.([mc])?js$/,L=/\.([mc])?[tj]sx$/,M=/\.([mc])?[tj]sx?$/,e={format:"esm",charset:"utf8",sourcemap:"inline",target:"node16",minify:!1},a={".mts":{...e,loader:"ts"},".jsx":{...e,loader:"jsx"},".tsx":{...e,loader:"tsx"},".cts":{...e,loader:"ts"},".ts":{...e,loader:"ts"},".json":{...e,loader:"json"}},n=Object.keys(a),T=s=>s.split(p).join(x.sep),l=s=>{const t=c(s);if(i(t))return s},r=s=>{for(const t of s)if(l(t))return t},m=s=>{const t=n.filter(o=>o.includes("ts")).concat([".js"]);return r(t.map(o=>s+o))},f=s=>{const t=n.filter(o=>o.includes("js")).concat([".js"]);return r(t.map(o=>s+o))},y=s=>{const t=f(s);if(t)return t;const o=m(s);if(o)return o};export{e as BASE_CONFIG,O as DEVELOPMENT_MODE,a as MODULE_LOADERS,n as POSSIBLE_EXTENSIONS,y as checkExtensions,f as checkJsExtension,m as checkTsExtensions,l as fileExists,r as fileExistsAny,S as isJs,M as isJsOrTs,h as isTs,L as isTsxOrJsx,T as normalizeSpecifier};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tsmodule/tsmodule",
3
3
  "type": "module",
4
- "version": "14.0.0",
4
+ "version": "15.1.0",
5
5
  "repository": "tsmodule/tsmodule",
6
6
  "description": "TypeScript Module loader and compiler",
7
7
  "license": "MIT",
@@ -37,11 +37,13 @@
37
37
  "lint": "eslint --fix src",
38
38
  "prepare": "yarn build -f",
39
39
  "prepublishOnly": "yarn build && yarn test",
40
+ "pretest": "yarn build -f",
40
41
  "test": "ava --no-worker-threads"
41
42
  },
42
43
  "dependencies": {
43
- "@types/node": "17.0.8",
44
- "@types/react": "17.0.38",
44
+ "@types/node": "^17.0.15",
45
+ "@types/react": "^17.0.39",
46
+ "@types/react-dom": "^17.0.11",
45
47
  "@typescript-eslint/eslint-plugin": "^5.9.1",
46
48
  "@typescript-eslint/parser": "^5.9.1",
47
49
  "ava": "^4.0.1",
@@ -50,13 +52,12 @@
50
52
  "commander": "^8.3.0",
51
53
  "create-debug-logger": "^1.10.1",
52
54
  "esbuild": "^0.14.0",
53
- "eslint": "^8.6.0",
55
+ "eslint": "^8.8.0",
54
56
  "fast-glob": "^3.2.10",
55
57
  "fs-extra": "^10.0.0",
56
58
  "node-watch": "^0.7.3",
57
59
  "ora": "^6.0.1",
58
60
  "path": "^0.12.7",
59
- "react": "^17.0.2",
60
61
  "typescript": "^4.5.5"
61
62
  },
62
63
  "keywords": [
@@ -1,11 +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, dev, fast }: {
8
- files?: string;
9
- dev?: boolean;
10
- fast?: boolean;
11
- }) => Promise<void>;
@@ -1 +0,0 @@
1
- export declare const emitTsDeclarations: (files: string[]) => void;
@@ -1 +0,0 @@
1
- export declare const create: (name: 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
- }>;
package/dist/package.json DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "type": "module"
3
- }
@@ -1,4 +0,0 @@
1
- declare global {
2
- const PACKAGE_JSON: Record<string, unknown>;
3
- }
4
- export * from "../loader/types";
@@ -1,27 +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 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 +0,0 @@
1
- export declare const getPackageJsonFile: () => Promise<string>;
@@ -1,52 +0,0 @@
1
- {
2
- "extends": [
3
- "plugin:@typescript-eslint/recommended"
4
- ],
5
- "parser": "@typescript-eslint/parser",
6
- "plugins": ["@typescript-eslint"],
7
- "rules": {
8
-
9
- "no-console": "error",
10
- "no-trailing-spaces": "error",
11
- "max-len": [1, 80, 2, {
12
- "ignorePattern": "^import\\s.+\\sfrom\\s.+;$",
13
- "ignoreUrls": true,
14
- "ignoreStrings": true,
15
- "ignoreTemplateLiterals": true,
16
- "ignoreRegExpLiterals": true
17
- }],
18
-
19
- "@typescript-eslint/type-annotation-spacing": ["error"],
20
-
21
- "@typescript-eslint/ban-ts-comment": [
22
- "error",
23
- {
24
- "ts-nocheck": "allow-with-description",
25
- "ts-ignore": "allow-with-description"
26
- }
27
- ],
28
-
29
- "indent": "off",
30
- "@typescript-eslint/indent": ["error", 2],
31
-
32
- "semi": "off",
33
- "@typescript-eslint/semi": ["error", "always"],
34
-
35
- "quotes": "off",
36
- "@typescript-eslint/quotes": ["error", "double"],
37
-
38
- "object-curly-spacing": "off",
39
- "@typescript-eslint/object-curly-spacing": ["error", "always"],
40
-
41
- "sort-imports": [
42
- "warn",
43
- {
44
- "ignoreCase": false,
45
- "ignoreDeclarationSort": false,
46
- "ignoreMemberSort": true,
47
- "memberSyntaxSortOrder": ["none", "all", "multiple", "single"],
48
- "allowSeparatedGroups": true
49
- }
50
- ]
51
- }
52
- }
@@ -1,30 +0,0 @@
1
- name: CI
2
-
3
- on:
4
- push:
5
- branches:
6
- - '**'
7
- pull_request:
8
- branches:
9
- - '**'
10
-
11
- jobs:
12
- test:
13
- name: Node ${{ matrix.nodejs }} on ${{ matrix.os }}
14
- runs-on: ${{ matrix.os }}
15
- timeout-minutes: 10
16
- strategy:
17
- matrix:
18
- nodejs: [14, 16, "lts/*"]
19
- os: [ubuntu-latest, windows-latest, macos-latest]
20
- steps:
21
- - uses: actions/checkout@v2
22
- - uses: actions/setup-node@v2
23
- with:
24
- node-version: ${{ matrix.nodejs }}
25
-
26
- - name: Install and link
27
- run: yarn install --frozen-lockfile && yarn build
28
-
29
- - name: Test
30
- run: yarn test
@@ -1,10 +0,0 @@
1
- node_modules
2
-
3
- # Potential Firebase / GCP credentials.
4
- service-account.json
5
-
6
- # Emitted output.
7
- dist/
8
-
9
- # Incremental TS build info.
10
- *.tsbuildinfo
@@ -1,5 +0,0 @@
1
- This is a TS module. Build it with tsmodule via:
2
-
3
- ```shell
4
- yarn build
5
- ```
@@ -1,33 +0,0 @@
1
- {
2
- "name": "template",
3
- "type": "module",
4
- "version": "0.0.1",
5
- "license": "MIT",
6
- "types": "dist/index.d.ts",
7
- "files": [
8
- "dist"
9
- ],
10
- "exports": {
11
- "./package.json": "./package.json",
12
- ".": "./dist/index.js",
13
- "./*": "./dist/*/index.js"
14
- },
15
- "scripts": {
16
- "build": "tsmodule build",
17
- "test": "ava",
18
- "lint": "eslint src --fix"
19
- },
20
- "ava": {
21
- "timout": 240000,
22
- "files": [
23
- "test/**/*.test.ts"
24
- ],
25
- "extensions": {
26
- "ts": "module"
27
- },
28
- "nodeArguments": [
29
- "--no-warnings",
30
- "--loader=@tsmodule/tsmodule"
31
- ]
32
- }
33
- }
@@ -1,4 +0,0 @@
1
- export const helloWorld = () => {
2
- // eslint-disable-next-line no-console
3
- console.log("Hello World!");
4
- };
@@ -1,7 +0,0 @@
1
- import test from "ava";
2
-
3
- test("two plus two should equal four", (t) => {
4
- if (2 + 2 === 4) {
5
- t.pass();
6
- }
7
- });
@@ -1,41 +0,0 @@
1
- {
2
- "include": [
3
- "*env.d.ts",
4
- "src/**/*"
5
- ],
6
- "exclude": [
7
- "node_modules",
8
- "test/**"
9
- ],
10
- "compilerOptions": {
11
- "moduleResolution": "Node",
12
- "target": "ESNext",
13
- "module": "ESNext",
14
- "lib": [
15
- "DOM",
16
- "DOM.Iterable",
17
- "ESNext"
18
- ],
19
- "jsx": "preserve",
20
- "rootDir": "src",
21
- "outDir": "dist",
22
- "allowJs": true,
23
- "importHelpers": true,
24
- "esModuleInterop": true,
25
- "allowSyntheticDefaultImports": true,
26
- "strict": true,
27
- "noUnusedLocals": true,
28
- "noUnusedParameters": true,
29
- "noImplicitReturns": true,
30
- "noFallthroughCasesInSwitch": true,
31
- "skipLibCheck": true,
32
- "resolveJsonModule": true,
33
- "declaration": true,
34
- "sourceMap": true,
35
- "checkJs": true,
36
- "noEmit": false,
37
- "forceConsistentCasingInFileNames": true,
38
- "isolatedModules": true,
39
- "incremental": false
40
- }
41
- }