Skip to content

Commit 57a5c62

Browse files
authored
feat: Add ESM (#206)
1 parent 1ce0c7c commit 57a5c62

File tree

4 files changed

+42
-25
lines changed

4 files changed

+42
-25
lines changed

package-lock.json

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+9-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
},
1414
"main": "lib/index.js",
1515
"types": "lib/index.d.ts",
16+
"module": "lib/esm/index.js",
17+
"exports": {
18+
"require": "./lib/index.js",
19+
"import": "./lib/esm/index.js"
20+
},
1621
"files": [
1722
"lib/**/*"
1823
],
@@ -26,7 +31,9 @@
2631
"format:es": "npm run lint:es -- --fix",
2732
"format:prettier": "npm run prettier -- --write",
2833
"prettier": "prettier '**/*.{ts,md,json,yml}'",
29-
"build": "tsc",
34+
"build": "npm run build:cjs && npm run build:esm",
35+
"build:cjs": "tsc --sourceRoot https://raw.githubusercontent.com/fb55/nth-check/$(git rev-parse HEAD)/src/",
36+
"build:esm": "npm run build:cjs -- --module esnext --target es2019 --outDir lib/esm && echo '{\"type\":\"module\"}' > lib/esm/package.json",
3037
"prepare": "npm run build"
3138
},
3239
"repository": {
@@ -46,6 +53,7 @@
4653
"boolbase": "^1.0.0"
4754
},
4855
"devDependencies": {
56+
"@types/boolbase": "^1.0.1",
4957
"@types/jest": "^27.5.0",
5058
"@types/node": "^17.0.35",
5159
"@typescript-eslint/eslint-plugin": "^5.25.0",

src/declarations/boolbase.d.ts

-4
This file was deleted.

tsconfig.json

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
{
22
"compilerOptions": {
33
/* Basic Options */
4-
"target": "es5" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
5-
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
6-
// "lib": [], /* Specify library files to be included in the compilation. */
7-
"declaration": true /* Generates corresponding '.d.ts' file. */,
8-
"declarationMap": true /* Generates a sourcemap for each corresponding '.d.ts' file. */,
9-
// "sourceMap": true, /* Generates corresponding '.map' file. */
10-
"outDir": "lib" /* Redirect output structure to the directory. */,
11-
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
4+
"target": "es5",
5+
"module": "commonjs",
6+
"lib": ["ES2015.Core"],
7+
"declaration": true,
8+
"declarationMap": true,
9+
"sourceMap": true,
10+
"outDir": "lib",
1211

1312
/* Strict Type-Checking Options */
14-
"strict": true /* Enable all strict type-checking options. */,
13+
"strict": true,
1514

1615
/* Additional Checks */
17-
"noUnusedLocals": true /* Report errors on unused locals. */,
18-
"noUnusedParameters": true /* Report errors on unused parameters. */,
19-
"noImplicitReturns": true /* Report error when not all code paths in function return a value. */,
20-
"noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */,
16+
"forceConsistentCasingInFileNames": true,
17+
"importsNotUsedAsValues": "error",
18+
"isolatedModules": true,
19+
"noFallthroughCasesInSwitch": true,
20+
"noImplicitOverride": true,
21+
"noImplicitReturns": true,
22+
"noPropertyAccessFromIndexSignature": true,
23+
"noUnusedLocals": true,
24+
"noUnusedParameters": true,
2125

2226
/* Module Resolution Options */
23-
"baseUrl": "./" /* Base directory to resolve non-absolute module names. */,
24-
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
25-
"resolveJsonModule": true,
26-
27-
"paths": {
28-
"*": ["src/declarations/*", "*"]
29-
}
27+
"esModuleInterop": true,
28+
"moduleResolution": "node",
29+
"resolveJsonModule": true
3030
},
3131
"include": ["src"],
3232
"exclude": [

0 commit comments

Comments
 (0)