Skip to content

Commit

Permalink
fix: add esm/cjs support
Browse files Browse the repository at this point in the history
  • Loading branch information
amilajack committed May 21, 2024
1 parent ca3397e commit a4873d1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
17 changes: 15 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,26 @@
"Amila Welihinda <[email protected]> (https://github.com/amilajack)",
"John Tran <[email protected]> (https://github.com/jooohhn)"
],
"main": "lib/index.js",
"main": "./lib/cjs/src/index.js",
"types": "./lib/cjs/src/index.d.ts",
"exports": {
".": {
"import": {
"types": "./lib/esm//src/index.d.mts",
"default": "./lib/esm/src/index.js"
},
"require": {
"types": "./lib/cjs/src/index.d.ts",
"default": "./lib/cjs/src/index.js"
}
}
},
"files": [
"lib"
],
"scripts": {
"benchmarks": "ts-node-transpile-only test/benchmarks.ts",
"build": "rm -rf lib && tsc --project tsconfig.build.json",
"build": "rm -rf lib && tsc --project tsconfig.build.json && tsc --project tsconfig.esm.json",
"lint": "eslint --ignore-path .gitignore --ext .js,.ts .",
"spec": "jest --testPathIgnorePatterns test/e2e-repo.spec.ts /benchmarks-tmp",
"spec:e2e": "jest test/e2e-repo.spec.ts",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"rootDir": "./src"
"outDir": "lib/cjs"
},
"include": ["src"]
}
8 changes: 8 additions & 0 deletions tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.build.json",
"compilerOptions": {
"module": "NodeNext",
"moduleResolution": "NodeNext",
"outDir": "lib/esm"
}
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "@tsconfig/node16",
"compilerOptions": {
"outDir": "lib",
"outDir": "lib/esm",
"declaration": true,
"resolveJsonModule": true,
"esModuleInterop": true
Expand Down

0 comments on commit a4873d1

Please sign in to comment.