Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

14 changes: 11 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
"publishConfig": {
"access": "public"
},
"type": "module",
"version": "0.0.0-development",
"description": "Universal library to retrieve GitHub’s identity URL for the OAuth web flow",
"scripts": {
"build": "node scripts/build.mjs && tsc -p tsconfig.json",
"lint": "prettier --check '{src,test}/**/*' README.md package.json",
"lint:fix": "prettier --write '{src,test}/**/*' README.md package.json",
"pretest": "npm run -s lint",
"test": "jest --coverage"
"test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest --coverage"
},
"repository": "github:octokit/oauth-authorization-url.js",
"files": [
Expand All @@ -24,7 +25,7 @@
"author": "Gregor Martynus (https://github.com/gr2m)",
"license": "MIT",
"devDependencies": {
"@octokit/tsconfig": "^2.0.0",
"@octokit/tsconfig": "^3.0.0",
"@types/jest": "^29.0.0",
"esbuild": "^0.20.0",
"glob": "^10.2.6",
Expand All @@ -34,11 +35,15 @@
"typescript": "^5.0.0"
},
"jest": {
"extensionsToTreatAsEsm": [
".ts"
],
"transform": {
"^.+\\.(ts|tsx)$": [
"ts-jest",
{
"tsconfig": "test/tsconfig.test.json"
"tsconfig": "test/tsconfig.test.json",
"useESM": true
}
]
},
Expand All @@ -49,6 +54,9 @@
"functions": 100,
"lines": 100
}
},
"moduleNameMapper": {
"^(.+)\\.jsx?$": "$1"
}
},
"release": {
Expand Down
36 changes: 8 additions & 28 deletions scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,6 @@ async function main() {

const entryPoints = ["./pkg/dist-src/index.js"];

await Promise.all([
// Build the a CJS Node.js bundle
esbuild.build({
entryPoints,
outdir: "pkg/dist-node",
bundle: true,
platform: "node",
target: "node18",
format: "cjs",
...sharedOptions,
}),
// Build an ESM browser bundle
esbuild.build({
entryPoints,
outdir: "pkg/dist-web",
bundle: true,
platform: "browser",
format: "esm",
...sharedOptions,
}),
]);

// Copy the README, LICENSE to the pkg folder
await copyFile("LICENSE", "pkg/LICENSE");
await copyFile("README.md", "pkg/README.md");
Expand All @@ -73,13 +51,15 @@ async function main() {
JSON.stringify(
{
...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",
files: ["dist-*/**"],
exports: {
".": {
types: "./dist-types/index.d.ts",
import: "./dist-src/index.js",
},
},
sideEffects: false,
unpkg: "dist-web/index.js"
unpkg: "dist-src/index.js"
},
null,
2
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import type {
GitHubAppOptions,
OAuthAppResult,
GitHubAppResult,
} from "./types";
} from "./types.js";
export type {
ClientType,
OAuthAppOptions,
GitHubAppOptions,
OAuthAppResult,
GitHubAppResult,
} from "./types";
} from "./types.js";

export function oauthAuthorizationUrl(options: OAuthAppOptions): OAuthAppResult;
export function oauthAuthorizationUrl(
Expand Down
3 changes: 2 additions & 1 deletion test/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { oauthAuthorizationUrl } from "../src/index";
import { oauthAuthorizationUrl } from "../src/index.js";
import { jest } from "@jest/globals";

beforeAll(() => {
Math.random = jest.fn(() => 0.123);
Expand Down
3 changes: 1 addition & 2 deletions test/tsconfig.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"emitDeclarationOnly": false,
"noEmit": true,
"verbatimModuleSyntax": false
"noEmit": true
},
"include": ["src/**/*"]
}