diff --git a/package.json b/package.json index 7607470..b842206 100644 --- a/package.json +++ b/package.json @@ -2,10 +2,19 @@ "name": "fastify-bugsnag", "version": "3.0.0", "description": "Fastify plugin for Bugsnag", - "main": "dist/index.js", - "types": "dist/index.d.ts", + "type": "commonjs", + "main": "dist/cjs/index.js", + "types": "dist/cjs/index.d.ts", + "exports": { + "require": "./dist/cjs/index.js", + "import": "./dist/esm/index.js", + "default": "./dist/cjs/index.js" + }, "scripts": { - "build": "tsc -p ./tsconfig.build.json", + "prebuild": "rimraf dist", + "build": "npm run build:cjs && npm run build:esm", + "build:cjs": "tsc -p ./tsconfig.build.cjs.json", + "build:esm": "tsc -p ./tsconfig.build.esm.json", "lint": "ts-standard --verbose | snazzy", "lint:fix": "ts-standard --fix | snazzy", "prepublish": "npm run build", @@ -50,6 +59,7 @@ "@types/node": "^18.16.3", "@types/tap": "^15.0.7", "fastify": "^4.17.0", + "rimraf": "^5.0.1", "snazzy": "^9.0.0", "tap": "^16.2.0", "ts-node": "^10.8.0", diff --git a/tsconfig.build.cjs.json b/tsconfig.build.cjs.json new file mode 100644 index 0000000..06234dd --- /dev/null +++ b/tsconfig.build.cjs.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.build.json", + "compilerOptions": { + "outDir": "dist/cjs", + }, + "exclude": [ + "node_modules", + "test/**/*.ts" + ] +} diff --git a/tsconfig.build.esm.json b/tsconfig.build.esm.json new file mode 100644 index 0000000..5529719 --- /dev/null +++ b/tsconfig.build.esm.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.build.json", + "compilerOptions": { + "outDir": "dist/esm", + "module": "esnext" + } +} diff --git a/tsconfig.build.json b/tsconfig.build.json index 066773c..ef457cd 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -1,10 +1,10 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "./dist", - "noEmit": false + "noEmit": false, }, - "include": [ - "./src/**/*.ts" + "exclude": [ + "node_modules", + "test/**/*.ts" ] } diff --git a/tsconfig.json b/tsconfig.json index 8ac7a24..038b771 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,11 +11,10 @@ ] }, "include": [ - "./src/**/*.ts", - "./test/**/*.ts" + "src/**/*.ts", + "test/**/*.ts" ], "exclude": [ - "dist", "node_modules" ] }