Skip to content

Target ES2021 and ESM Node18 (fetch built in) #125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 28, 2023
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
10 changes: 5 additions & 5 deletions example/svelte-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
},
"devDependencies": {
"@sveltejs/adapter-auto": "^2.0.0",
"@sveltejs/kit": "^1.7.1",
"svelte": "^3.54.0",
"svelte-check": "^3.0.1",
"typescript": "^4.9.3",
"vite": "^4.0.0"
"@sveltejs/kit": "^1.8.8",
"svelte": "^3.55.1",
"svelte-check": "^3.0.4",
"typescript": "^4.9.5",
"vite": "^4.1.4"
},
"type": "module",
"publishConfig": {
Expand Down
3 changes: 2 additions & 1 deletion example/svelte-kit/src/hooks.client.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Exceptionless } from "@exceptionless/browser";
import { toError } from "@exceptionless/core";

Exceptionless.startup(c => {
c.apiKey = "LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw";
Expand All @@ -11,5 +12,5 @@ Exceptionless.startup(c => {
/** @type {import('@sveltejs/kit').HandleClientError} */
export async function handleError({ error, event }) {
console.log('client error handler');
await Exceptionless.submitException(error);
await Exceptionless.submitException(toError(error));
}
3 changes: 2 additions & 1 deletion example/svelte-kit/src/hooks.server.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { toError } from "@exceptionless/core";
import { Exceptionless } from "@exceptionless/node";

Exceptionless.startup(c => {
Expand All @@ -11,5 +12,5 @@ Exceptionless.startup(c => {
/** @type {import('@sveltejs/kit').HandleServerError} */
export async function handleError({ error, event }) {
console.log('server error handler');
await Exceptionless.submitException(error);
await Exceptionless.submitException(toError(error));
}
2,731 changes: 1,310 additions & 1,421 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
"example/*"
],
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.52.0",
"@typescript-eslint/parser": "^5.52.0",
"eslint": "^8.34.0",
"@typescript-eslint/eslint-plugin": "^5.54.0",
"@typescript-eslint/parser": "^5.54.0",
"eslint": "^8.35.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-eslint-plugin": "^5.0.8",
"eslint-plugin-import": "^2.27.5",
Expand Down
6 changes: 3 additions & 3 deletions packages/angularjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@
"./package.json": "./package.json"
},
"scripts": {
"build": "tsc -p tsconfig.json && esbuild src/index.ts --bundle --sourcemap --target=es2017 --format=esm --outfile=dist/index.bundle.js && esbuild src/index.ts --bundle --minify --sourcemap --target=es2017 --format=esm --outfile=dist/index.bundle.min.js",
"watch": "tsc -p ../core/tsconfig.json -w --preserveWatchOutput & tsc -p tsconfig.json -w --preserveWatchOutput & esbuild src/index.ts --bundle --sourcemap --target=es2017 --format=esm --watch --outfile=dist/index.bundle.js"
"build": "tsc -p tsconfig.json && esbuild src/index.ts --bundle --sourcemap --target=es2021 --format=esm --outfile=dist/index.bundle.js && esbuild src/index.ts --bundle --minify --sourcemap --target=es2021 --format=esm --outfile=dist/index.bundle.min.js",
"watch": "tsc -p ../core/tsconfig.json -w --preserveWatchOutput & tsc -p tsconfig.json -w --preserveWatchOutput & esbuild src/index.ts --bundle --sourcemap --target=es2021 --format=esm --watch --outfile=dist/index.bundle.js"
},
"sideEffects": false,
"publishConfig": {
"access": "public"
},
"devDependencies": {
"@types/angular": "^1.8.4",
"esbuild": "^0.17.8"
"esbuild": "^0.17.10"
},
"dependencies": {
"@exceptionless/browser": "2.0.0-dev"
Expand Down
6 changes: 3 additions & 3 deletions packages/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
"testEnvironment": "jsdom"
},
"scripts": {
"build": "tsc -p tsconfig.json && esbuild src/index.ts --bundle --sourcemap --target=es2017 --format=esm --outfile=dist/index.bundle.js && esbuild src/index.ts --bundle --minify --sourcemap --target=es2017 --format=esm --outfile=dist/index.bundle.min.js",
"watch": "tsc -p ../core/tsconfig.json -w --preserveWatchOutput & tsc -p tsconfig.json -w --preserveWatchOutput & esbuild src/index.ts --bundle --sourcemap --target=es2017 --format=esm --watch --outfile=dist/index.bundle.js",
"build": "tsc -p tsconfig.json && esbuild src/index.ts --bundle --sourcemap --target=es2021 --format=esm --outfile=dist/index.bundle.js && esbuild src/index.ts --bundle --minify --sourcemap --target=es2021 --format=esm --outfile=dist/index.bundle.min.js",
"watch": "tsc -p ../core/tsconfig.json -w --preserveWatchOutput & tsc -p tsconfig.json -w --preserveWatchOutput & esbuild src/index.ts --bundle --sourcemap --target=es2021 --format=esm --watch --outfile=dist/index.bundle.js",
"test": "jest"
},
"sideEffects": false,
Expand All @@ -55,7 +55,7 @@
},
"devDependencies": {
"@jest/globals": "^29.4.3",
"esbuild": "^0.17.8",
"esbuild": "^0.17.10",
"jest": "^29.4.3",
"jest-environment-jsdom": "^29.4.3",
"jest-ts-webcompat-resolver": "^1.0.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
"testEnvironment": "jsdom"
},
"scripts": {
"build": "tsc -p tsconfig.json && esbuild src/index.ts --bundle --sourcemap --target=es2017 --format=esm --outfile=dist/index.bundle.js && esbuild src/index.ts --bundle --minify --sourcemap --target=es2017 --format=esm --outfile=dist/index.bundle.min.js",
"watch": "tsc -p tsconfig.json -w --preserveWatchOutput & esbuild src/index.ts --bundle --sourcemap --target=es2017 --format=esm --watch --outfile=dist/index.bundle.js",
"build": "tsc -p tsconfig.json && esbuild src/index.ts --bundle --sourcemap --target=es2021 --format=esm --outfile=dist/index.bundle.js && esbuild src/index.ts --bundle --minify --sourcemap --target=es2021 --format=esm --outfile=dist/index.bundle.min.js",
"watch": "tsc -p tsconfig.json -w --preserveWatchOutput & esbuild src/index.ts --bundle --sourcemap --target=es2021 --format=esm --watch --outfile=dist/index.bundle.js",
"test": "jest"
},
"sideEffects": false,
Expand All @@ -55,7 +55,7 @@
},
"devDependencies": {
"@jest/globals": "^29.4.3",
"esbuild": "^0.17.8",
"esbuild": "^0.17.10",
"jest": "^29.4.3",
"jest-environment-jsdom": "^29.4.3",
"jest-ts-webcompat-resolver": "^1.0.0",
Expand Down
14 changes: 8 additions & 6 deletions packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
".": "./dist/index.js",
"./package.json": "./package.json"
},
"engines": {
"node": ">=18"
},
"jest": {
"moduleFileExtensions": [
"js",
Expand All @@ -45,27 +48,26 @@
"testEnvironment": "node"
},
"scripts": {
"build": "tsc -p tsconfig.json && esbuild src/index.ts --bundle --sourcemap --platform=node --target=node12 --format=cjs --outfile=dist/index.bundle.js",
"watch": "tsc -p ../core/tsconfig.json -w --preserveWatchOutput & tsc -p tsconfig.json -w --preserveWatchOutput & esbuild src/index.ts --bundle --platform=node --sourcemap --target=node12 --format=cjs --watch --outfile=dist/index.bundle.js",
"build": "tsc -p tsconfig.json && esbuild src/index.ts --bundle --sourcemap --platform=node --format=esm --outfile=dist/index.bundle.js",
"watch": "tsc -p ../core/tsconfig.json -w --preserveWatchOutput & tsc -p tsconfig.json -w --preserveWatchOutput & esbuild src/index.ts --bundle --platform=node --sourcemap --format=esm --watch --outfile=dist/index.bundle.js",
"test": "jest"
},
"sideEffects": false,
"publishConfig": {
"access": "public"
},
"devDependencies": {
"@types/node": "^18.13.0",
"@jest/globals": "^29.4.3",
"@types/node": "^18.14.2",
"@types/node-localstorage": "^1.3.0",
"@types/stack-trace": "^0.0.30",
"@jest/globals": "^29.4.3",
"esbuild": "^0.17.8",
"esbuild": "^0.17.10",
"jest": "^29.4.3",
"jest-ts-webcompat-resolver": "^1.0.0",
"ts-jest": "^29.0.5"
},
"dependencies": {
"@exceptionless/core": "2.0.0-dev",
"node-fetch": "^3.3.0",
"node-localstorage": "^2.2.1",
"stack-trace": "^1.0.0-pre2"
}
Expand Down
14 changes: 3 additions & 11 deletions packages/node/src/NodeExceptionlessClient.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import {
Configuration,
DefaultSubmissionClient,
ExceptionlessClient,
LocalStorage,
SimpleErrorPlugin
} from "@exceptionless/core";

import { LocalStorage as LocalStoragePolyfill } from "node-localstorage";
import fetch from "node-fetch";

import { NodeErrorPlugin } from "./plugins/NodeErrorPlugin.js";
import { NodeEnvironmentInfoPlugin } from "./plugins/NodeEnvironmentInfoPlugin.js";
Expand All @@ -21,15 +19,9 @@ export class NodeExceptionlessClient extends ExceptionlessClient {
const config = this.config;

if (configurationOrApiKey && !this._initialized) {
if (!globalThis?.localStorage) {
const storage = new LocalStorage(undefined, new LocalStoragePolyfill(process.cwd() + '/.exceptionless'));
config.useLocalStorage = () => storage;
config.services.storage = storage;
}

if (!globalThis?.fetch) {
config.services.submissionClient = new DefaultSubmissionClient(config, fetch as (input: RequestInfo | URL, init?: RequestInit | undefined) => Promise<Response>);
}
const storage = new LocalStorage(undefined, new LocalStoragePolyfill(process.cwd() + '/.exceptionless'));
config.useLocalStorage = () => storage;
config.services.storage = storage;

config.addPlugin(new NodeEnvironmentInfoPlugin());
config.addPlugin(new NodeGlobalHandlerPlugin());
Expand Down
3 changes: 3 additions & 0 deletions packages/node/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"lib": [
"ES2021"
],
"outDir": "dist",
"rootDir": "src",
"types": [
Expand Down
6 changes: 3 additions & 3 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"./package.json": "./package.json"
},
"scripts": {
"build": "tsc -p tsconfig.json && esbuild src/index.ts --bundle --sourcemap --target=es2017 --format=esm --outfile=dist/index.bundle.js && esbuild src/index.ts --bundle --minify --sourcemap --target=es2017 --format=esm --outfile=dist/index.bundle.min.js",
"watch": "tsc -p ../core/tsconfig.json -w --preserveWatchOutput & tsc -p tsconfig.json -w --preserveWatchOutput & esbuild src/index.ts --bundle --sourcemap --target=es2017 --format=esm --watch --outfile=dist/index.bundle.js"
"build": "tsc -p tsconfig.json && esbuild src/index.ts --bundle --sourcemap --target=es2021 --format=esm --outfile=dist/index.bundle.js && esbuild src/index.ts --bundle --minify --sourcemap --target=es2021 --format=esm --outfile=dist/index.bundle.min.js",
"watch": "tsc -p ../core/tsconfig.json -w --preserveWatchOutput & tsc -p tsconfig.json -w --preserveWatchOutput & esbuild src/index.ts --bundle --sourcemap --target=es2021 --format=esm --watch --outfile=dist/index.bundle.js"
},
"sideEffects": false,
"publishConfig": {
Expand All @@ -44,7 +44,7 @@
"@jest/globals": "^29.4.3",
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"esbuild": "^0.17.8",
"esbuild": "^0.17.10",
"jest": "^29.4.3",
"jest-ts-webcompat-resolver": "^1.0.0",
"ts-jest": "^29.0.5"
Expand Down
6 changes: 3 additions & 3 deletions packages/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@
"./package.json": "./package.json"
},
"scripts": {
"build": "tsc -p tsconfig.json && esbuild src/index.ts --bundle --sourcemap --target=es2017 --format=esm --outfile=dist/index.bundle.js && esbuild src/index.ts --bundle --minify --sourcemap --target=es2017 --format=esm --outfile=dist/index.bundle.min.js",
"watch": "tsc -p tsconfig.json -w --preserveWatchOutput & && esbuild src/index.ts --bundle --sourcemap --target=es2017 --format=esm --watch --outfile=dist/index.bundle.js &"
"build": "tsc -p tsconfig.json && esbuild src/index.ts --bundle --sourcemap --target=es2021 --format=esm --outfile=dist/index.bundle.js && esbuild src/index.ts --bundle --minify --sourcemap --target=es2021 --format=esm --outfile=dist/index.bundle.min.js",
"watch": "tsc -p tsconfig.json -w --preserveWatchOutput & && esbuild src/index.ts --bundle --sourcemap --target=es2021 --format=esm --watch --outfile=dist/index.bundle.js &"
},
"sideEffects": false,
"publishConfig": {
"access": "public"
},
"devDependencies": {
"esbuild": "^0.17.8"
"esbuild": "^0.17.10"
},
"dependencies": {
"@exceptionless/browser": "2.0.0-dev"
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"target": "ES2019",
"target": "ES2021",
"useUnknownInCatchVariables": true
}
}