diff --git a/package.json b/package.json index 3eeffe2..2b4bece 100644 --- a/package.json +++ b/package.json @@ -2,12 +2,30 @@ "name": "drand-client", "version": "1.2.6", "description": "A client to the drand randomness beacon network.", - "main": "index.js", - "types": "index.d.ts", + "source": "src/index.ts", + "main": "./build/cjs/index.js", + "module": "./build/esm/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": { + "require": { + "types": "./build/index.d.ts", + "default": "./build/cjs/index.js" + }, + "import": { + "types": "./build/index.d.ts", + "default": "./build/esm/index.js" + } + } + }, + "files": [ + "build", + "src" + ], "scripts": { "clean": "rm -rf ./build/* && rm -rf lib/version.ts", "precompile": "node -p \"'export const LIB_VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" > lib/version.ts", - "compile": "npm run precompile && tsc --project tsconfig.json", + "compile": "npm run precompile && tsc --project tsconfig.json && tsc --project tsconfig-cjs.json", "publish:github": "npm publish --registry https://npm.pkg.github.com", "test": "jest --verbose ./test/**.test.ts", "lint": "eslint ./{lib,test}/*.ts", diff --git a/tsconfig-cjs.json b/tsconfig-cjs.json new file mode 100644 index 0000000..b0b32a6 --- /dev/null +++ b/tsconfig-cjs.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "CommonJS", + "outDir": "./build/cjs" + } +} diff --git a/tsconfig.json b/tsconfig.json index d598155..973873f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,9 +1,9 @@ { "compilerOptions": { - "module": "commonjs", + "module": "esnext", "target": "esnext", "sourceMap": true, - "outDir": "./build", + "outDir": "./build/esm", "moduleResolution": "node", "allowJs": true, "esModuleInterop": true,