# svelte-runner

> Run svelte components. Zero configuration necessary.

Latest version **1.0.0** (published 2020-12-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install svelte-runner
pnpm add svelte-runner
yarn add svelte-runner
bun add svelte-runner
```

Provides the command `svelte-runner`.

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2020-12-01 |
| First published | 2020-12-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 36 |
| Unpacked size | 31.8 KB |
| Known vulnerabilities | 0 (+7 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Vehmloewff |
| Maintainers | vehmloewff |
| Keywords | svelte, runner, component |

## Links

- npm: https://www.npmjs.com/package/svelte-runner
- Repository: https://github.com/Vehmloewff/svelte-runner
- npm.io page: https://npm.io/package/svelte-runner

## Dependencies (36)

- [ws](https://npm.io/package/ws.md) ^7.4.0
- [pug](https://npm.io/package/pug.md) ^3.0.0
- [less](https://npm.io/package/less.md) ^3.12.2
- [open](https://npm.io/package/open.md) ^7.3.0
- [acorn](https://npm.io/package/acorn.md) ^8.0.4
- [tslib](https://npm.io/package/tslib.md) ^2.0.3
- [nollup](https://npm.io/package/nollup.md) ^0.13.13
- [rollup](https://npm.io/package/rollup.md) ^2.33.3
- [stylus](https://npm.io/package/stylus.md) ^0.54.8
- [svelte](https://npm.io/package/svelte.md) ^3.29.7
- [express](https://npm.io/package/express.md) ^4.17.1
- [sugarss](https://npm.io/package/sugarss.md) ^3.0.3
- [zip-tap](https://npm.io/package/zip-tap.md) ^1.0.6
- [prettier](https://npm.io/package/prettier.md) ^2.2.0
- [commander](https://npm.io/package/commander.md) ^6.2.0
- [path-type](https://npm.io/package/path-type.md) ^4.0.0
- [bufferutil](https://npm.io/package/bufferutil.md) ^4.0.2
- [http-proxy](https://npm.io/package/http-proxy.md) ^1.18.1
- [typescript](https://npm.io/package/typescript.md) ^4.1.2
- [path-exists](https://npm.io/package/path-exists.md) ^4.0.0
- [coffeescript](https://npm.io/package/coffeescript.md) ^2.5.1
- [utf-8-validate](https://npm.io/package/utf-8-validate.md) ^5.0.3
- [builtin-modules](https://npm.io/package/builtin-modules.md) ^3.1.0
- [zip-tap-reporter](https://npm.io/package/zip-tap-reporter.md) ^2.0.1
- [svelte-preprocess](https://npm.io/package/svelte-preprocess.md) ^4.6.1
- [@rollup/plugin-json](https://npm.io/package/@rollup/plugin-json.md) ^4.1.0
- [postcss-load-config](https://npm.io/package/postcss-load-config.md) ^3.0.0
- [rollup-plugin-svelte](https://npm.io/package/rollup-plugin-svelte.md) ^6.1.1
- [rollup-plugin-terser](https://npm.io/package/rollup-plugin-terser.md) ^7.0.2
- [rollup-plugin-command](https://npm.io/package/rollup-plugin-command.md) ^1.1.3
- [@rollup/plugin-sucrase](https://npm.io/package/@rollup/plugin-sucrase.md) ^3.1.0
- [@rollup/plugin-virtual](https://npm.io/package/@rollup/plugin-virtual.md) ^2.0.3
- [@rollup/plugin-commonjs](https://npm.io/package/@rollup/plugin-commonjs.md) ^15.1.0
- [rollup-plugin-svelte-hot](https://npm.io/package/rollup-plugin-svelte-hot.md) ^0.11.2
- [@rollup/plugin-typescript](https://npm.io/package/@rollup/plugin-typescript.md) ^6.1.0
- [@rollup/plugin-node-resolve](https://npm.io/package/@rollup/plugin-node-resolve.md) ^10.0.0

## Recent versions

- 1.0.0 (latest) — 2020-12-01

## README

# Svelte Runner

Run svelte components. Zero configuration necessary.

## Quick start

```
yarn global add svelte-runner
svelte-runner dev
```

Bundles `App.svelte` and all it's dependencies. It then serves up the bundled code on port `3000`, using HMR to instantly update the app when the source code is updated.

Want more customization than that? Don't worry, check out the docs. Customization is by no means overlooked.

## Why?

There's more than one reason...

I love things to be simple and efficient. Why not accomplish the work that is generally done by multiple configuration files in one cli command? It's also a lot easier to update one dependency, than to have to continually track `nollup`, `rollup`, `typescript`, `svelte`, `svelte-hmr`, etc., while always having to worry about their compatibility to each other.

NodeJS is not the only language that I use. Keeping away from project root configurations for multiple frameworks across multiple languages is a high priority for me.

Ships to a single binary. It would be chore indeed to name all the benefits of this.

## CLI Usage

```
Usage: svelte-runner [options] [command]

Options:
  -V, --version                output the version number
  -e, --entry-file <file>      Initial file.  Code should be svelte, js, or ts (default: "App.svelte")
  -i, --icon <imageFile>       Path to the favicon
  -t, --title <string>         Title of the app
  -o, --open                   Open the app in default browser
  -p, --port <number>          Port to start the app on (default: "3000")
  --host <host>                Host to bind to (default: "localhost")
  --real-favicon <fileOrJSON>  Json options for real-favicon
  --headers <fileOrTags>       Extra tags to be inserted into the <head> of the template
  --template <stringOrFile>    Custom template (index.html)
  --static-map <fileOrJSON>    Static map.  https://github.com/Vehmloewff/svelte-runner#static-map
  --add-script <file>          Path to an additional js file to be inserted into the app's head
  -h, --help                   display help for command

Commands:
  dev [options]                Serves the app in a development environment
  prod [options]               Serves up the app in a production environment
  help [command]               display help for command
```

## Programmatic Usage

```sh
yarn add svelte-runner -D
```

```ts
import { dev, prod } from 'svelte-runner'

await dev(coreOptions, devOptions)
// or
await prod(coreOptions, prodOptions)
```

For more information on what the options are, check out [`src/types.ts`](src/types.ts).

## Static Map

Static maps tell `svelte-runner` how to serve up static content.

```json
{
	"/api/**": {
		"proxy": {
			"host": "localhost",
			"port": "8080"
		}
	},
	"/**": {
		"searchIn": "assets"
	},
	"GET /**": {
		"serve": "template"
	}
}
```

When a request comes in, `svelte-runner` will follow these steps:

-   If the path matches `/_sr-gen/main.js`, the compiled and bundled svelte code will be served. Otherwise
-   If the path matches `/_sr-gen/main.css`, the bundled css code will be served.
-   If the path matches the first pattern, `/api/**`, the request will be relayed to `localhost:8080`.
-   If the path matches the second pattern, `/**`, ask the folder `assets` if it contains a file whose path represents the part of the path represented by the wildcard (`**`). If a matching file is not found, continue.
-   If the method of the request is `GET`, serve up the app template (`index.html`).

## Known issues

-   "Additional watch scripts" support with live reloading does not work at present.

---
_Source: https://npm.io/package/svelte-runner · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
