Trim the fat

This commit is contained in:
garronej 2021-08-01 02:43:03 +02:00
parent d20579dd26
commit 971e028503
12 changed files with 225 additions and 2858 deletions

View file

@ -9,12 +9,7 @@
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",
"scripts": { "scripts": {
"test": "node dist/test/", "test": "echo DODO",
"cdn:bundle:.js": "simplifyify dist/index.js -s #{REPO_NAME_NO_DASHES}# -o dist/bundle.js --debug --bundle",
"cdn:bundle:.min.js": "terser dist/bundle.js -cmo dist/bundle.min.js",
"cdn:bundle": "npm run cdn:bundle:.js && npm run cdn:bundle:.min.js",
"cdn:esm": "tsc -p tsconfig.esm.json",
"cdn": "npm run cdn:bundle && npm run cdn:esm",
"build": "tsc && npm run cdn", "build": "tsc && npm run cdn",
"lint:check": "eslint . --ext .ts,.tsx", "lint:check": "eslint . --ext .ts,.tsx",
"lint": "npm run lint:check -- --fix", "lint": "npm run lint:check -- --fix",
@ -47,17 +42,14 @@
"keywords": [], "keywords": [],
"homepage": "https://github.com/#{USER_OR_ORG}#/#{REPO_NAME}#", "homepage": "https://github.com/#{USER_OR_ORG}#/#{REPO_NAME}#",
"devDependencies": { "devDependencies": {
"@types/node": "^15.3.1", "@types/node": "^16.4.9",
"@typescript-eslint/eslint-plugin": "^4.24.0", "@typescript-eslint/eslint-plugin": "^4.28.5",
"@typescript-eslint/parser": "^4.24.0", "@typescript-eslint/parser": "^4.28.5",
"eslint": "^7.26.0", "eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0", "eslint-config-prettier": "^8.3.0",
"evt": "^1.9.14",
"husky": "^4.3.8", "husky": "^4.3.8",
"lint-staged": "^11.0.0", "lint-staged": "^11.1.1",
"prettier": "^2.3.0", "prettier": "^2.3.2",
"simplifyify": "^8.0.4", "typescript": "^4.3.5"
"terser": "^5.7.0",
"typescript": "^4.2.4"
} }
} }

View file

@ -1,2 +1,2 @@
export { myFunction } from "./myFunction"; export * from "./myFunction";
export { myObject } from "./myObject"; export * from "./myObject";

View file

@ -1,3 +1,3 @@
export function myFunction() { export function myFunction() {
return Promise.resolve(["a", "b", "c"]); return ["a", "b", "c"];
} }

View file

@ -1,3 +1 @@
import { toUpperCase } from "./tools/toUpperCase"; export const myObject = { "p": "foo" };
export const myObject = { "p": toUpperCase("foo") };

View file

@ -1,3 +0,0 @@
import { getProjectRoot } from "../tools/getProjectRoot";
console.log(`Project root path: ${getProjectRoot()} does it seems right ? If yes then PASS`);

View file

@ -1,41 +0,0 @@
//This will not run on deno, we need a separate test runner for Deno (./mod.ts).
import * as child_process from "child_process";
import * as path from "path";
import { Deferred } from "evt/tools/Deferred";
const names = ["myFunction", "myObject", "getProjectRoot"];
(async () => {
if (!!process.env.FORK) {
process.once("unhandledRejection", error => {
throw error;
});
require(process.env.FORK);
return;
}
for (const name of names) {
console.log(`Running: ${name}`);
const dExitCode = new Deferred<number>();
child_process
.fork(__filename, undefined, {
"env": { "FORK": path.join(__dirname, name) },
})
.on("message", console.log)
.once("exit", code => dExitCode.resolve(code ?? 1));
const exitCode = await dExitCode.pr;
if (exitCode !== 0) {
console.log(`${name} exited with error code: ${exitCode}`);
process.exit(exitCode);
}
console.log("\n");
}
})();

View file

@ -1,16 +0,0 @@
import { myFunction } from "..";
import { getPromiseAssertionApi } from "evt/tools/testing";
const { mustResolve } = getPromiseAssertionApi({
"takeIntoAccountArraysOrdering": true,
});
(async () => {
await mustResolve({
"promise": myFunction(),
"expectedData": ["a", "b", "c"],
"delay": 0,
});
console.log("PASS");
})();

View file

@ -1,7 +0,0 @@
import { assert } from "evt/tools/typeSafety";
import * as inDepth from "evt/tools/inDepth";
import { myObject } from "..";
assert(inDepth.same(myObject, { "p": "FOO" }));
console.log("PASS");

View file

@ -1,19 +0,0 @@
import * as fs from "fs";
import * as path from "path";
function getProjectRootRec(dirPath: string): string {
if (fs.existsSync(path.join(dirPath, "package.json"))) {
return dirPath;
}
return getProjectRootRec(path.join(dirPath, ".."));
}
let result: string | undefined = undefined;
export function getProjectRoot(): string {
if (result !== undefined) {
return result;
}
return (result = getProjectRootRec(__dirname));
}

View file

@ -1,3 +0,0 @@
export function toUpperCase(str: string): string {
return str.toUpperCase();
}

View file

@ -1,8 +0,0 @@
{
"extends": "./tsconfig.json",
"include": ["src/index.ts"],
"compilerOptions": {
"module": "es2015",
"outDir": "dist/zz_esm/"
}
}

2952
yarn.lock

File diff suppressed because it is too large Load diff