Skip to content

Commit

Permalink
feat: package is now ESM
Browse files Browse the repository at this point in the history
BREAKING CHANGE: package is now ESM
  • Loading branch information
wolfy1339 committed Feb 25, 2024
1 parent 990930e commit f970e0d
Show file tree
Hide file tree
Showing 7 changed files with 208 additions and 318 deletions.
473 changes: 172 additions & 301 deletions package-lock.json

Large diffs are not rendered by default.

23 changes: 14 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"publishConfig": {
"access": "public"
},
"type": "module",
"version": "0.0.0-development",
"description": "GitHub Apps toolset for Node.js",
"main": "index.js",
Expand All @@ -11,23 +12,23 @@
"lint": "prettier --check {src,test}/* *.md package.json",
"lint:fix": "prettier --write {src,test}/* *.md package.json",
"pretest": "npm run -s lint",
"test": "jest --coverage",
"test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest --coverage",
"test:typescript": "npx tsc --allowImportingTsExtensions --noEmit --declaration --noUnusedLocals --esModuleInterop --strict --target es2020 --moduleResolution node16 --module node16 test/typescript-validate.ts"
},
"repository": "github:octokit/app.js",
"author": "Gregor Martynus (https://github.com/gr2m)",
"license": "MIT",
"dependencies": {
"@octokit/auth-app": "^6.0.0",
"@octokit/auth-unauthenticated": "^5.0.0",
"@octokit/core": "^5.0.0",
"@octokit/oauth-app": "^6.0.0",
"@octokit/auth-app": "^7.0.0-beta.3",
"@octokit/auth-unauthenticated": "^6.0.0",
"@octokit/core": "^6.0.0",
"@octokit/oauth-app": "^7.0.0",
"@octokit/plugin-paginate-rest": "^9.0.0",
"@octokit/types": "^12.0.0",
"@octokit/webhooks": "^12.0.4"
"@octokit/types": "^12.6.0",
"@octokit/webhooks": "^13.0.0"
},
"devDependencies": {
"@octokit/tsconfig": "^2.0.0",
"@octokit/tsconfig": "^3.0.0",
"@types/jest": "^29.0.0",
"@types/node": "^20.0.0",
"esbuild": "^0.20.0",
Expand All @@ -45,11 +46,15 @@
"node": ">= 18"
},
"jest": {
"extensionsToTreatAsEsm": [
".ts"
],
"transform": {
"^.+\\.(ts|tsx)$": [
"ts-jest",
{
"tsconfig": "test/tsconfig.test.json"
"tsconfig": "test/tsconfig.test.json",
"useESM": true
}
]
},
Expand Down
24 changes: 18 additions & 6 deletions scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ async function main() {
outdir: "pkg/dist-node",
bundle: true,
platform: "node",
target: "node14",
format: "cjs",
target: "node18",
format: "esm",
...sharedOptions,
}),
// Build an ESM browser bundle
Expand Down Expand Up @@ -78,10 +78,22 @@ async function main() {
{
...pkg,
files: ["dist-*/**", "bin/**"],
main: "dist-node/index.js",
module: "dist-web/index.js",
types: "dist-types/index.d.ts",
source: "dist-src/index.js",
exports: {
".": {
node: {
types: "./dist-types/index.d.ts",
import: "./dist-node/index.js",
},
browser: {
types: "./dist-types/web.d.ts",
import: "./dist-web/index.js",
},
default: {
types: "./dist-types/index.d.ts",
import: "./dist-node/index.js",
},
},
},
sideEffects: false,
},
null,
Expand Down
1 change: 1 addition & 0 deletions test/log.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const CLIENT_ID = "0123";
const CLIENT_SECRET = "0123secret";
const WEBHOOK_SECRET = "secret";

import { jest } from "@jest/globals";
import { App } from "../src/index.ts";

describe("app.log", () => {
Expand Down
3 changes: 2 additions & 1 deletion test/node-middleware.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { createServer } from "node:http";

// import without types
const express = require("express");
// @ts-ignore
const express = (await import("express")).default as any;

import { App, createNodeMiddleware } from "../src/index.ts";

Expand Down
1 change: 1 addition & 0 deletions test/octokit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const BEARER =
"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOi0zMCwiZXhwIjo1NzAsImlzcyI6MX0.q3foRa78U3WegM5PrWLEh5N0bH1SD62OqW66ZYzArp95JBNiCbo8KAlGtiRENCIfBZT9ibDUWy82cI4g3F09mdTq3bD1xLavIfmTksIQCz5EymTWR5v6gL14LSmQdWY9lSqkgUG0XCFljWUglEP39H4yeHbFgdjvAYg3ifDS12z9oQz2ACdSpvxPiTuCC804HkPVw8Qoy0OSXvCkFU70l7VXCVUxnuhHnk8-oCGcKUspmeP6UdDnXk-Aus-eGwDfJbU2WritxxaXw6B4a3flTPojkYLSkPBr6Pi0H2-mBsW_Nvs0aLPVLKobQd4gqTkosX3967DoAG8luUMhrnxe8Q";

import { App } from "../src/index.ts";
import { jest } from "@jest/globals";

describe("app.octokit", () => {
let app: InstanceType<typeof App>;
Expand Down
1 change: 0 additions & 1 deletion test/tsconfig.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"compilerOptions": {
"emitDeclarationOnly": false,
"noEmit": true,
"verbatimModuleSyntax": false,
"allowImportingTsExtensions": true
},
"include": ["src/**/*"]
Expand Down

0 comments on commit f970e0d

Please sign in to comment.