Skip to content

Commit

Permalink
feat: package is now ESM (#392)
Browse files Browse the repository at this point in the history
* feat: package is now ESM

BREAKING CHANGE: package is now ESM

* fix(docs): update for ESM
  • Loading branch information
wolfy1339 authored Mar 4, 2024
1 parent d6e62a5 commit a2ca8bd
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 59 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ It does not require any configuration, but instead reads [the `GITHUB_TOKEN` env
Install with <code>npm install @octokit/auth-action</code>

```js
const { createActionAuth } = require("@octokit/auth-action");
// or: import { createActionAuth } from "@octokit/auth-action";
import { createActionAuth } from "@octokit/auth-action";

const auth = createActionAuth();
const authentication = await auth();
Expand Down
62 changes: 27 additions & 35 deletions package-lock.json

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

17 changes: 11 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
},
"version": "0.0.0-development",
"description": "GitHub API token authentication for GitHub Actions",
"type": "module",
"scripts": {
"build": "node scripts/build.mjs && tsc -p tsconfig.json",
"lint": "prettier --check '{src,test}/**/*.{ts,md}' README.md *.json",
"lint:fix": "prettier --write '{src,test}/**/*.{ts,md}' README.md *.json",
"pretest": "npm run -s lint",
"test": "jest --coverage",
"test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest --coverage",
"semantic-release": "semantic-release"
},
"repository": "github:octokit/auth-action.js",
Expand All @@ -24,12 +25,12 @@
"author": "Gregor Martynus (https://github.com/gr2m)",
"license": "MIT",
"dependencies": {
"@octokit/auth-token": "^4.0.0",
"@octokit/types": "^12.0.0"
"@octokit/auth-token": "^5.0.0",
"@octokit/types": "^12.6.0"
},
"devDependencies": {
"@octokit/request": "^8.0.2",
"@octokit/tsconfig": "^2.0.0",
"@octokit/request": "^9.0.1",
"@octokit/tsconfig": "^3.0.0",
"@types/jest": "^29.0.0",
"esbuild": "^0.20.0",
"fetch-mock": "npm:@gr2m/fetch-mock@9.11.0-pull-request-644.1",
Expand All @@ -40,11 +41,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 Down
23 changes: 8 additions & 15 deletions scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,6 @@ async function main() {

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

// Build the a CJS Node.js bundle
await esbuild.build({
entryPoints,
outdir: "pkg/dist-node",
bundle: true,
platform: "node",
target: "node14",
format: "cjs",
...sharedOptions,
}),

// Copy the README, LICENSE to the pkg folder
await copyFile("LICENSE", "pkg/LICENSE");
await copyFile("README.md", "pkg/README.md");
Expand All @@ -66,11 +55,15 @@ async function main() {
JSON.stringify(
{
...pkg,
files: ["dist-*/**", "bin/**"],
main: "dist-node/index.js",
module: "dist-web/index.js",
files: ["dist-*/**"],
main: "dist-src/index.js",
types: "dist-types/index.d.ts",
source: "dist-src/index.js",
exports: {
".": {
types: "./dist-types/index.d.ts",
import: "./dist-src/index.js",
}
},
sideEffects: false,
},
null,
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": [
Expand Down

0 comments on commit a2ca8bd

Please sign in to comment.