From 92fe6cbfff4e3f15f78b137976e2b55a828c64aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20B=C3=B6hm?= <188768+fb55@users.noreply.github.com> Date: Sun, 22 May 2022 20:42:49 +0100 Subject: [PATCH 1/3] feat: Add ESM --- package.json | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index f9ad20cd..56921b05 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,11 @@ }, "main": "lib/index.js", "types": "lib/index.d.ts", + "module": "lib/esm/index.js", + "exports": { + "require": "./lib/index.js", + "import": "./lib/esm/index.js" + }, "files": [ "lib/**/*" ], @@ -26,7 +31,9 @@ "format:es": "npm run lint:es -- --fix", "format:prettier": "npm run prettier -- --write", "prettier": "prettier '**/*.{ts,md,json,yml}'", - "build": "tsc", + "build": "npm run build:cjs && npm run build:esm", + "build:cjs": "tsc --sourceRoot https://raw.githubusercontent.com/fb55/nth-check/$(git rev-parse HEAD)/src/", + "build:esm": "npm run build:cjs -- --module esnext --target es2019 --outDir lib/esm && echo '{\"type\":\"module\"}' > lib/esm/package.json", "prepare": "npm run build" }, "repository": { From 5632e7da5348090372360da837bb21aa16243460 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20B=C3=B6hm?= <188768+fb55@users.noreply.github.com> Date: Sun, 22 May 2022 20:46:15 +0100 Subject: [PATCH 2/3] Use @types/boolbase --- package-lock.json | 13 +++++++++++++ package.json | 1 + src/declarations/boolbase.d.ts | 4 ---- 3 files changed, 14 insertions(+), 4 deletions(-) delete mode 100644 src/declarations/boolbase.d.ts diff --git a/package-lock.json b/package-lock.json index bc97e126..231743b6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "boolbase": "^1.0.0" }, "devDependencies": { + "@types/boolbase": "^1.0.1", "@types/jest": "^27.5.0", "@types/node": "^17.0.35", "@typescript-eslint/eslint-plugin": "^5.25.0", @@ -1075,6 +1076,12 @@ "@babel/types": "^7.3.0" } }, + "node_modules/@types/boolbase": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@types/boolbase/-/boolbase-1.0.1.tgz", + "integrity": "sha512-ulr2ZqSiEEwtehELPYJjIleXEebz101NzmGn0CWg19+Ud8OoEnJOUJRnfo5F6KUV+x+Pngz1uaesjhINx6mwlQ==", + "dev": true + }, "node_modules/@types/graceful-fs": { "version": "4.1.5", "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.5.tgz", @@ -5950,6 +5957,12 @@ "@babel/types": "^7.3.0" } }, + "@types/boolbase": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@types/boolbase/-/boolbase-1.0.1.tgz", + "integrity": "sha512-ulr2ZqSiEEwtehELPYJjIleXEebz101NzmGn0CWg19+Ud8OoEnJOUJRnfo5F6KUV+x+Pngz1uaesjhINx6mwlQ==", + "dev": true + }, "@types/graceful-fs": { "version": "4.1.5", "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.5.tgz", diff --git a/package.json b/package.json index 56921b05..fecde85e 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,7 @@ "boolbase": "^1.0.0" }, "devDependencies": { + "@types/boolbase": "^1.0.1", "@types/jest": "^27.5.0", "@types/node": "^17.0.35", "@typescript-eslint/eslint-plugin": "^5.25.0", diff --git a/src/declarations/boolbase.d.ts b/src/declarations/boolbase.d.ts deleted file mode 100644 index a4dffcf6..00000000 --- a/src/declarations/boolbase.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -declare module "boolbase" { - export function trueFunc(...args: unknown[]): true; - export function falseFunc(...args: unknown[]): false; -} From 1bd41b5603e6612683497411bcc0653cfc086a37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20B=C3=B6hm?= <188768+fb55@users.noreply.github.com> Date: Sun, 22 May 2022 20:46:18 +0100 Subject: [PATCH 3/3] Update tsconfig.json --- tsconfig.json | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 8b90f661..9ae3922f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,32 +1,32 @@ { "compilerOptions": { /* Basic Options */ - "target": "es5" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */, - "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */, - // "lib": [], /* Specify library files to be included in the compilation. */ - "declaration": true /* Generates corresponding '.d.ts' file. */, - "declarationMap": true /* Generates a sourcemap for each corresponding '.d.ts' file. */, - // "sourceMap": true, /* Generates corresponding '.map' file. */ - "outDir": "lib" /* Redirect output structure to the directory. */, - // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + "target": "es5", + "module": "commonjs", + "lib": ["ES2015.Core"], + "declaration": true, + "declarationMap": true, + "sourceMap": true, + "outDir": "lib", /* Strict Type-Checking Options */ - "strict": true /* Enable all strict type-checking options. */, + "strict": true, /* Additional Checks */ - "noUnusedLocals": true /* Report errors on unused locals. */, - "noUnusedParameters": true /* Report errors on unused parameters. */, - "noImplicitReturns": true /* Report error when not all code paths in function return a value. */, - "noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */, + "forceConsistentCasingInFileNames": true, + "importsNotUsedAsValues": "error", + "isolatedModules": true, + "noFallthroughCasesInSwitch": true, + "noImplicitOverride": true, + "noImplicitReturns": true, + "noPropertyAccessFromIndexSignature": true, + "noUnusedLocals": true, + "noUnusedParameters": true, /* Module Resolution Options */ - "baseUrl": "./" /* Base directory to resolve non-absolute module names. */, - "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, - "resolveJsonModule": true, - - "paths": { - "*": ["src/declarations/*", "*"] - } + "esModuleInterop": true, + "moduleResolution": "node", + "resolveJsonModule": true }, "include": ["src"], "exclude": [