diff --git a/package.json b/package.json index 64ac827..59df183 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,9 @@ "name": "@hawk.so/javascript", "type": "commonjs", "version": "3.2.11", + "workspaces": [ + "packages/*" + ], "description": "JavaScript errors tracking for Hawk.so", "files": [ "dist" diff --git a/packages/svelte/README.md b/packages/svelte/README.md new file mode 100644 index 0000000..04d8a6f --- /dev/null +++ b/packages/svelte/README.md @@ -0,0 +1,23 @@ +# Hawk JavaScript Catcher: Svelte Integration + +Hawk Error Tracker integration for Svelte applications. + +## Usage + +Install package: + +```shell +npm install @hawk.so/javascript --save +``` + +Svelte is supported out of the box. Initialize HawkCatcher in app's client hooks. + +Create or update `src/hooks.client.ts`: + +```ts +import HawkCatcher from '@hawk.so/javascript'; + +new HawkCatcher({ + token: 'YOUR_INTEGRATION_TOKEN' +}); +``` diff --git a/packages/svelte/package.json b/packages/svelte/package.json new file mode 100644 index 0000000..e48bd16 --- /dev/null +++ b/packages/svelte/package.json @@ -0,0 +1,14 @@ +{ + "name": "@hawk.so/svelte", + "version": "1.0.0", + "description": "Svelte/SvelteKit integration for Hawk Error Tracker", + "main": "./dist/hawk-svelte.umd.js", + "module": "./dist/hawk-svelte.mjs", + "types": "dist/index.d.ts", + "scripts": { + "build": "vite build" + }, + "dependencies": { + "@hawk.so/javascript": "file:../.." + } +} diff --git a/packages/svelte/src/index.ts b/packages/svelte/src/index.ts new file mode 100644 index 0000000..43ad792 --- /dev/null +++ b/packages/svelte/src/index.ts @@ -0,0 +1,9 @@ +/** + * @hawk.so/javascript-svelte + * Svelte/SvelteKit integration for Hawk.so JavaScript error tracker + */ + +// Just verification that main sources may be used in current workspace +// TODO: should be replaced with actual code during further implementation +export * from '@hawk.so/javascript'; +export { default } from '@hawk.so/javascript'; diff --git a/packages/svelte/tsconfig.json b/packages/svelte/tsconfig.json new file mode 100644 index 0000000..56896f0 --- /dev/null +++ b/packages/svelte/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "dist", + "rootDir": "src" + }, + "include": [ + "src/**/*" + ] +} diff --git a/packages/svelte/vite.config.ts b/packages/svelte/vite.config.ts new file mode 100644 index 0000000..d57bc1f --- /dev/null +++ b/packages/svelte/vite.config.ts @@ -0,0 +1,23 @@ +import path from 'path'; +import dts from 'vite-plugin-dts'; +import { defineConfig } from 'vite'; + +export default defineConfig(() => { + return { + build: { + lib: { + entry: path.resolve(__dirname, 'src', 'index.ts'), + name: 'HawkSvelte', + fileName: 'hawk-svelte', + }, + rollupOptions: { + external: ['svelte', '@hawk.so/javascript'], + }, + }, + plugins: [ + dts({ + tsconfigPath: './tsconfig.json', + }), + ], + }; +}); diff --git a/yarn.lock b/yarn.lock index 3aa494e..bdaf15e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -316,6 +316,13 @@ minimatch "^3.0.4" strip-json-comments "^3.1.1" +"@hawk.so/javascript@file:.": + version "3.2.11" + dependencies: + "@hawk.so/types" "^0.1.36" + error-stack-parser "^2.1.4" + vite-plugin-dts "^4.2.4" + "@hawk.so/types@^0.1.36": version "0.1.36" resolved "https://registry.yarnpkg.com/@hawk.so/types/-/types-0.1.36.tgz#234b0e4c81bf5f50b1208910d45fc4ffb62e8ae1"