Skip to content

Commit 784e7e9

Browse files
niemyjskiclaude
andcommitted
Export bundles as package entry points and update Next.js example
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1bb49af commit 784e7e9

File tree

8 files changed

+40
-20
lines changed

8 files changed

+40
-20
lines changed

example/nextjs/app/api/demo/route.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { after } from "next/server";
22

3-
import { Exceptionless, KnownEventDataKeys, startup } from "../../../lib/exceptionless-server.js";
3+
import { startup } from "../../../lib/exceptionless-server.js";
44
import { buildRequestContextFromRequest } from "../../../lib/next-request.js";
55

66
export async function POST(request) {
@@ -12,7 +12,7 @@ export async function POST(request) {
1212
throw new Error("Route handler crash from the Exceptionless Next.js demo");
1313
}
1414

15-
await startup();
15+
const { Exceptionless, KnownEventDataKeys } = await startup();
1616

1717
const builder = Exceptionless.createLog("nextjs.route", "Route handler log from the demo page", "info").addTags("route-handler");
1818

@@ -21,6 +21,7 @@ export async function POST(request) {
2121
await builder.submit();
2222

2323
after(async () => {
24+
const { Exceptionless } = await startup();
2425
await Exceptionless.processQueue();
2526
});
2627

example/nextjs/instrumentation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ export async function onRequestError(error, request, context) {
1414
return;
1515
}
1616

17-
const { Exceptionless, KnownEventDataKeys, startup, toError } = await import("./lib/exceptionless-server.js");
17+
const { startup } = await import("./lib/exceptionless-server.js");
1818
const digest = typeof error === "object" && error !== null && "digest" in error ? error.digest : undefined;
1919

20-
await startup();
20+
const { Exceptionless, KnownEventDataKeys, toError } = await startup();
2121

2222
const builder = Exceptionless.createUnhandledException(toError(error), `nextjs.${context.routeType}`).addTags("on-request-error");
2323

example/nextjs/lib/exceptionless-browser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Exceptionless, KnownEventDataKeys } from "../../../packages/browser/dist/index.bundle.js";
1+
import { Exceptionless, KnownEventDataKeys } from "@exceptionless/browser";
22

33
export { Exceptionless };
44

example/nextjs/lib/exceptionless-server.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
import { Exceptionless, KnownEventDataKeys, toError } from "../../../packages/node/dist/index.bundle.js";
1+
import { ExceptionlessClient, KnownEventDataKeys, toError } from "@exceptionless/core";
22

3-
export { Exceptionless, KnownEventDataKeys, toError };
3+
export { KnownEventDataKeys, toError };
4+
5+
export const Exceptionless = new ExceptionlessClient();
46

57
let startupPromise;
68

7-
export function startup() {
8-
startupPromise ??= Exceptionless.startup((config) => {
9+
export async function startup() {
10+
startupPromise ??= (async () => {
11+
await Exceptionless.startup((config) => {
912
if (process.env.EXCEPTIONLESS_API_KEY ?? process.env.NEXT_PUBLIC_EXCEPTIONLESS_API_KEY) {
1013
config.apiKey = process.env.EXCEPTIONLESS_API_KEY ?? process.env.NEXT_PUBLIC_EXCEPTIONLESS_API_KEY;
1114
}
@@ -50,7 +53,9 @@ export function startup() {
5053
return Promise.resolve();
5154
}
5255
});
53-
});
56+
57+
return { Exceptionless, KnownEventDataKeys, toError };
58+
})();
5459

5560
return startupPromise;
5661
}

packages/browser/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,16 @@
2424
},
2525
"license": "Apache-2.0",
2626
"type": "module",
27-
"main": "dist/index.js",
27+
"main": "dist/index.bundle.js",
2828
"types": "dist/index.d.ts",
2929
"unpkg": "dist/index.bundle.min.js",
3030
"jsdelivr": "dist/index.bundle.min.js",
3131
"exports": {
32-
".": "./dist/index.js",
32+
".": {
33+
"types": "./dist/index.d.ts",
34+
"source": "./src/index.ts",
35+
"default": "./dist/index.bundle.js"
36+
},
3337
"./package.json": "./package.json"
3438
},
3539
"scripts": {

packages/core/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,16 @@
2424
},
2525
"license": "Apache-2.0",
2626
"type": "module",
27-
"main": "dist/index.js",
27+
"main": "dist/index.bundle.js",
2828
"types": "dist/index.d.ts",
2929
"unpkg": "dist/index.bundle.min.js",
3030
"jsdelivr": "dist/index.bundle.min.js",
3131
"exports": {
32-
".": "./dist/index.js",
32+
".": {
33+
"types": "./dist/index.d.ts",
34+
"source": "./src/index.ts",
35+
"default": "./dist/index.bundle.js"
36+
},
3337
"./package.json": "./package.json"
3438
},
3539
"scripts": {

packages/node/package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@
2424
},
2525
"license": "Apache-2.0",
2626
"type": "module",
27-
"main": "dist/index.js",
27+
"main": "dist/index.bundle.js",
2828
"types": "dist/index.d.ts",
29-
"unpkg": "dist/index.bundle.min.js",
30-
"jsdelivr": "dist/index.bundle.min.js",
3129
"exports": {
32-
".": "./dist/index.js",
30+
".": {
31+
"types": "./dist/index.d.ts",
32+
"source": "./src/index.ts",
33+
"default": "./dist/index.bundle.js"
34+
},
3335
"./package.json": "./package.json"
3436
},
3537
"engines": {

packages/react/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,16 @@
2424
},
2525
"license": "Apache-2.0",
2626
"type": "module",
27-
"main": "dist/index.js",
27+
"main": "dist/index.bundle.js",
2828
"types": "dist/index.d.ts",
2929
"unpkg": "dist/index.bundle.min.js",
3030
"jsdelivr": "dist/index.bundle.min.js",
3131
"exports": {
32-
".": "./dist/index.js",
32+
".": {
33+
"types": "./dist/index.d.ts",
34+
"source": "./src/index.ts",
35+
"default": "./dist/index.bundle.js"
36+
},
3337
"./package.json": "./package.json"
3438
},
3539
"scripts": {

0 commit comments

Comments
 (0)