Skip to content

Commit

Permalink
feat(examples): add svelte (#1458)
Browse files Browse the repository at this point in the history
A basic svelte example. 

Replaces #1184 and #244

**NOTE**: There is no shared `ts-config` package here because of how svelte sets up it's ts-config inheritance. The base config is auto generated in a set location (`.svelte-kit`). There are a few open issues about adjusting this for better monorepo support (relevant issues: sveltejs/kit#4052, microsoft/TypeScript#29118 (comment))
  • Loading branch information
tknickman authored Jun 29, 2022
1 parent 601bb52 commit 0120432
Show file tree
Hide file tree
Showing 39 changed files with 488 additions and 9 deletions.
8 changes: 4 additions & 4 deletions examples/basic/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Turborepo starter

This is an official starter turborepo.
This is an official starter Turborepo.

## What's inside?

This turborepo includes the following packages/apps:
This Turborepo includes the following packages/apps:

### Apps and Packages

Expand All @@ -18,7 +18,7 @@ Each package/app is 100% [TypeScript](https://www.typescriptlang.org/).

### Utilities

This turborepo has some additional tools already setup for you:
This Turborepo has some additional tools already setup for you:

- [TypeScript](https://www.typescriptlang.org/) for static type checking
- [ESLint](https://eslint.org/) for code linting
Expand Down Expand Up @@ -59,7 +59,7 @@ npx turbo login

This will authenticate the Turborepo CLI with your [Vercel account](https://vercel.com/docs/concepts/personal-accounts/overview).

Next, you can link your Turborepo to your Remote Cache by running the following command from the root of your turborepo:
Next, you can link your Turborepo to your Remote Cache by running the following command from the root of your Turborepo:

```
npx turbo link
Expand Down
2 changes: 1 addition & 1 deletion examples/kitchen-sink/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Each package and app is 100% [TypeScript](https://www.typescriptlang.org/).

### Utilities

This turborepo has some additional tools already setup for you:
This Turborepo has some additional tools already setup for you:

- [TypeScript](https://www.typescriptlang.org/) for static type checking
- [ESLint](https://eslint.org/) for code linting
Expand Down
2 changes: 1 addition & 1 deletion examples/with-changesets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Each package and app is 100% [TypeScript](https://www.typescriptlang.org/).

### Utilities

This turborepo has some additional tools already setup for you:
This Turborepo has some additional tools already setup for you:

- [TypeScript](https://www.typescriptlang.org/) for static type checking
- [ESLint](https://eslint.org/) for code linting
Expand Down
6 changes: 3 additions & 3 deletions examples/with-pnpm/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Turborepo starter with pnpm

This is an official starter turborepo.
This is an official starter Turborepo.

## What's inside?

This turborepo uses [pnpm](https://pnpm.io) as a packages manager. It includes the following packages/apps:
This Turborepo uses [pnpm](https://pnpm.io) as a packages manager. It includes the following packages/apps:

### Apps and Packages

Expand All @@ -18,7 +18,7 @@ Each package/app is 100% [TypeScript](https://www.typescriptlang.org/).

### Utilities

This turborepo has some additional tools already setup for you:
This Turborepo has some additional tools already setup for you:

- [TypeScript](https://www.typescriptlang.org/) for static type checking
- [ESLint](https://eslint.org/) for code linting
Expand Down
5 changes: 5 additions & 0 deletions examples/with-svelte/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
root: true,
// This tells ESLint to load the config from the package `eslint-config-custom`
extends: ['custom']
};
30 changes: 30 additions & 0 deletions examples/with-svelte/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
node_modules
.pnp
.pnp.js

# testing
coverage

# svelte
.svelte-kit

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local

# turbo
.turbo
13 changes: 13 additions & 0 deletions examples/with-svelte/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.DS_Store
.svelte-kit
node_modules
/build
/package
.env
.env.*
!.env.example

# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock
6 changes: 6 additions & 0 deletions examples/with-svelte/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100,
"svelteStrictMode": true
}
24 changes: 24 additions & 0 deletions examples/with-svelte/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Turborepo Svelte starter

This is an official starter Turborepo.

## What's inside?

This Turborepo includes the following packages/apps:

### Apps and Packages

- `docs`: a [svelte-kit](https://kit.svelte.dev/) app
- `web`: another [svelte-kit](https://kit.svelte.dev/) app
- `ui`: a stub Svelte component library shared by both `web` and `docs` applications
- `eslint-config-custom`: `eslint` configurations (includes `eslint-plugin-svelte` and `eslint-config-prettier`)

Each package/app is 100% [TypeScript](https://www.typescriptlang.org/).

### Utilities

This Turborepo has some additional tools already setup for you:

- [TypeScript](https://www.typescriptlang.org/) for static type checking
- [ESLint](https://eslint.org/) for code linting
- [Prettier](https://prettier.io) for code formatting
13 changes: 13 additions & 0 deletions examples/with-svelte/apps/docs/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example

# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock
4 changes: 4 additions & 0 deletions examples/with-svelte/apps/docs/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: ['custom']
};
8 changes: 8 additions & 0 deletions examples/with-svelte/apps/docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
38 changes: 38 additions & 0 deletions examples/with-svelte/apps/docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# create-svelte

Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte).

## Creating a project

If you're seeing this, you've probably already done this step. Congrats!

```bash
# create a new project in the current directory
npm init svelte

# create a new project in my-app
npm init svelte my-app
```

## Developing

Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:

```bash
npm run dev

# or start the server and open the app in a new browser tab
npm run dev -- --open
```

## Building

To create a production version of your app:

```bash
npm run build
```

You can preview the production build with `npm run preview`.

> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
29 changes: 29 additions & 0 deletions examples/with-svelte/apps/docs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "docs",
"version": "0.0.0",
"scripts": {
"dev": "svelte-kit dev --p 3001",
"build": "svelte-kit build",
"package": "svelte-kit package",
"preview": "svelte-kit preview",
"prepare": "svelte-kit sync",
"check": "svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --check --ignore-path=../../.prettierignore . && eslint .",
"format": "prettier --write --ignore-path=../../.prettierignore ."
},
"dependencies": {
"ui": "*"
},
"devDependencies": {
"@sveltejs/adapter-auto": "latest",
"@sveltejs/kit": "latest",
"eslint-config-custom": "*",
"svelte": "^3.44.0",
"svelte-check": "^2.7.1",
"svelte-preprocess": "^4.10.6",
"tslib": "^2.3.1",
"typescript": "^4.7.2"
},
"type": "module"
}
11 changes: 11 additions & 0 deletions examples/with-svelte/apps/docs/src/app.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/// <reference types="@sveltejs/kit" />

// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
// and what to do when importing types
declare namespace App {
// interface Locals {}
// interface Platform {}
// interface Session {}
// interface Stuff {}
}
12 changes: 12 additions & 0 deletions examples/with-svelte/apps/docs/src/app.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
%sveltekit.head%
</head>
<body>
<div>%sveltekit.body%</div>
</body>
</html>
8 changes: 8 additions & 0 deletions examples/with-svelte/apps/docs/src/routes/index.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<script lang="ts">
import { MyCounterButton } from 'ui';
</script>

<h1>Docs</h1>
<MyCounterButton />

<p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p>
Binary file added examples/with-svelte/apps/docs/static/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions examples/with-svelte/apps/docs/svelte.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import adapter from '@sveltejs/adapter-auto';
import preprocess from 'svelte-preprocess';

/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://github.com/sveltejs/svelte-preprocess
// for more information about preprocessors
preprocess: preprocess(),

kit: {
adapter: adapter()
}
};

export default config;
13 changes: 13 additions & 0 deletions examples/with-svelte/apps/docs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true
}
}
13 changes: 13 additions & 0 deletions examples/with-svelte/apps/web/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example

# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock
3 changes: 3 additions & 0 deletions examples/with-svelte/apps/web/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['custom']
};
8 changes: 8 additions & 0 deletions examples/with-svelte/apps/web/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
38 changes: 38 additions & 0 deletions examples/with-svelte/apps/web/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# create-svelte

Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte).

## Creating a project

If you're seeing this, you've probably already done this step. Congrats!

```bash
# create a new project in the current directory
npm init svelte

# create a new project in my-app
npm init svelte my-app
```

## Developing

Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:

```bash
npm run dev

# or start the server and open the app in a new browser tab
npm run dev -- --open
```

## Building

To create a production version of your app:

```bash
npm run build
```

You can preview the production build with `npm run preview`.

> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
Loading

0 comments on commit 0120432

Please sign in to comment.