Skip to content
Open
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
27 changes: 27 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
node_modules
demo/
.test-output/

# Output
.output
.vercel
.netlify
.wrangler
/.svelte-kit
/build
/dist

# OS
.DS_Store
Thumbs.db

# Env
.env
.env.*
!.env.example
!.env.test

# Vite
vite.config.js.timestamp-*
vite.config.ts.timestamp-*

48 changes: 48 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Contributing Guide

Cheatsheet: [All official add-ons source code](https://github.com/sveltejs/cli/tree/main/packages/sv/src/addons)

---

Some convenient scripts are provided to help develop the add-on.

```sh
## create a new minimal project in the `demo` directory
npm run demo-create

## add your current add-on to the demo project
npm run demo-add

## run the tests
npm run test
```

## Key things to note

Your `add-on` should:

- export a function that returns a `defineAddon` object.
- have a `package.json` with an `exports` field that points to the main entry point of the add-on.

## Building

Your add-on is bundled with [tsdown](https://tsdown.dev/) into a single file in `dist/`. This bundles everything except `sv` (which is a peer dependency provided at runtime).

```sh
npm run build
```

## Publishing

When you're ready to publish your add-on to npm:

```sh
npm login
npm publish
```

> `prepublishOnly` will automatically run the build before publishing.

## Things to be aware of

Community add-ons must have `sv` as a `peerDependency` and should **not** have any `dependencies`. Everything else (including `@sveltejs/sv-utils`) is bundled at build time by tsdown.
9 changes: 9 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"strict": true,
"skipLibCheck": true,
"checkJs": true,
"module": "NodeNext",
"moduleResolution": "NodeNext"
}
}
42 changes: 42 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "@msw/sveltekit",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"name": "@msw/sveltekit",
"name": "@msw/sv",

Like this you can do : npx add @msw if you keep your name you will have to do npx add @msw/sveltekit

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we talked about it with @kettanaito but he prefers this as it's more explicit

"description": "sv add-on for Mock Service Worker",
"version": "0.0.1",
"type": "module",
"license": "MIT",
"scripts": {
"demo-create": "sv create demo --types ts --template minimal --no-add-ons --no-install",
"demo-add": "pnpm build && sv add file:../ --cwd demo --no-git-check --no-install",
"demo-add:ci": "pnpm build && sv add file:../=environments:browser,node --cwd demo --no-git-check --no-download-check --no-install",
"build": "tsdown",
"prepublishOnly": "npm run build",
"test": "vitest run"
},
"files": [
"dist"
],
"exports": {
".": {
"default": "./dist/index.mjs"
}
},
"publishConfig": {
"access": "public"
},
"peerDependencies": {
"sv": "^0.13.0"
},
"devDependencies": {
"@playwright/test": "^1.59.1",
"@sveltejs/sv-utils": "latest",
"@types/node": "^25.5.2",
"sv": "latest",
"tsdown": "^0.21.7",
"vitest": "^4.1.3"
},
"keywords": [
"sv-add",
"svelte",
"sveltekit"
]
}
Loading