Skip to content

Commit

Permalink
build: output ESM
Browse files Browse the repository at this point in the history
BREAKING CHANGE: switch package to ESM instead of CommonJS
  • Loading branch information
wolfy1339 committed Feb 17, 2024
1 parent 6918a32 commit 75a350d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"publishConfig": {
"access": "public"
},
"type": "module",
"description": "Error class for Octokit request errors",
"scripts": {
"build": "node scripts/build.mjs && tsc -p tsconfig.json",
Expand All @@ -27,7 +28,7 @@
"once": "^1.4.0"
},
"devDependencies": {
"@octokit/tsconfig": "^2.0.0",
"@octokit/tsconfig": "^3.0.0",
"@types/jest": "^29.0.0",
"@types/node": "^20.0.0",
"@types/once": "^1.4.0",
Expand Down
18 changes: 13 additions & 5 deletions scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async function main() {
bundle: true,
platform: "node",
target: "node18",
format: "cjs",
format: "esm",
...sharedOptions,
}),
// Build an ESM browser bundle
Expand Down Expand Up @@ -74,10 +74,18 @@ async function main() {
{
...pkg,
files: ["dist-*/**", "bin/**"],
main: "dist-node/index.js",
browser: "dist-web/index.js",
types: "dist-types/index.d.ts",
module: "dist-src/index.js",
exports: {
".": {
node: {
types: "./dist-types/index.d.ts",
import: "./dist-node/index.js",
},
browser: {
types: "./dist-types/index.d.ts",
import: "./dist-web/index.js",
}
}
},
sideEffects: false,
unpkg: "dist-web/index.js",
},
Expand Down

0 comments on commit 75a350d

Please sign in to comment.