Skip to content

Commit a2b4169

Browse files
authored
feat: v10 (#473)
* feat: output ESM for NodeJS BREAKING CHANGE: output ESM instead of CJS * fix(build): remove separate browser bundle
1 parent 24da8ec commit a2b4169

File tree

5 files changed

+62
-40
lines changed

5 files changed

+62
-40
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ Node
4848
Install with <code>npm install @octokit/endpoint</code>
4949

5050
```js
51-
const { endpoint } = require("@octokit/endpoint");
52-
// or: import { endpoint } from "@octokit/endpoint";
51+
import { endpoint } from "@octokit/endpoint";
5352
```
5453

5554
</td></tr>

package-lock.json

Lines changed: 38 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "@octokit/endpoint",
33
"version": "0.0.0-development",
4+
"type": "module",
45
"publishConfig": {
56
"access": "public"
67
},
@@ -10,7 +11,7 @@
1011
"lint": "prettier --check '{scripts,src,test}/**/*' README.md package.json",
1112
"lint:fix": "prettier --write '{scripts,src,test}/**/*' README.md package.json",
1213
"pretest": "npm run -s lint",
13-
"test": "jest --coverage"
14+
"test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest --coverage"
1415
},
1516
"repository": "github:octokit/endpoint.js",
1617
"keywords": [
@@ -22,7 +23,7 @@
2223
"author": "Gregor Martynus (https://github.com/gr2m)",
2324
"license": "MIT",
2425
"devDependencies": {
25-
"@octokit/tsconfig": "^2.0.0",
26+
"@octokit/tsconfig": "^3.0.0",
2627
"@types/jest": "^29.0.0",
2728
"@types/node": "^20.10.0",
2829
"esbuild": "^0.20.0",
@@ -36,7 +37,7 @@
3637
},
3738
"dependencies": {
3839
"@octokit/types": "^12.0.0",
39-
"universal-user-agent": "^6.0.0"
40+
"universal-user-agent": "^7.0.2"
4041
},
4142
"release": {
4243
"branches": [
@@ -71,11 +72,15 @@
7172
]
7273
},
7374
"jest": {
75+
"extensionsToTreatAsEsm": [
76+
".ts"
77+
],
7478
"transform": {
7579
"^.+\\.(ts|tsx)$": [
7680
"ts-jest",
7781
{
78-
"tsconfig": "test/tsconfig.test.json"
82+
"tsconfig": "test/tsconfig.test.json",
83+
"useESM": true
7984
}
8085
]
8186
},

scripts/build.mjs

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -35,27 +35,14 @@ async function main() {
3535

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

38-
await Promise.all([
39-
// Build the a CJS Node.js bundle
40-
esbuild.build({
41-
entryPoints,
42-
outdir: "pkg/dist-node",
43-
bundle: true,
44-
platform: "node",
45-
target: "node18",
46-
format: "cjs",
47-
...sharedOptions,
48-
}),
49-
// Build an ESM browser bundle
50-
esbuild.build({
51-
entryPoints,
52-
outdir: "pkg/dist-web",
53-
bundle: true,
54-
platform: "browser",
55-
format: "esm",
56-
...sharedOptions,
57-
}),
58-
]);
38+
await esbuild.build({
39+
entryPoints,
40+
outdir: "pkg/dist-bundle",
41+
bundle: true,
42+
platform: "neutral",
43+
format: "esm",
44+
...sharedOptions,
45+
});
5946

6047
// Copy the README, LICENSE to the pkg folder
6148
await copyFile("LICENSE", "pkg/LICENSE");
@@ -74,10 +61,12 @@ async function main() {
7461
{
7562
...pkg,
7663
files: ["dist-*/**", "bin/**"],
77-
main: "dist-node/index.js",
78-
browser: "dist-web/index.js",
79-
types: "dist-types/index.d.ts",
80-
module: "dist-src/index.js",
64+
exports: {
65+
".": {
66+
types: "./dist-types/index.d.ts",
67+
import: "./dist-bundle/index.js",
68+
},
69+
},
8170
sideEffects: false,
8271
},
8372
null,

test/tsconfig.test.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"compilerOptions": {
44
"emitDeclarationOnly": false,
55
"noEmit": true,
6-
"verbatimModuleSyntax": false,
76
"allowImportingTsExtensions": true
87
},
98
"include": ["src/**/*"]

0 commit comments

Comments
 (0)