Skip to content

Commit 3c4c198

Browse files
Rich Harrisbenmccann
Rich Harris
andauthored
Vite (#409)
* Powered by Vite. Issues remain * Fix esbuild version conflict in HN example by removing snowpack config * Enable hot reload option * Add layout css * Get layout to show up in SSR * More path fixes. CSR works now! * Bump snowpack to reduce esbuild version conflicts * get a few tests passing * Fix * [WIP] Vite prod builds (#1) * WIP vite prod builds * prettier * HN example working, at least * fix some stuff * update config files * various * simplify * simplify * oops * fix find_layout * remove logging * fix vite base path * make vite a peer dependency * let vite serve static assets * get SSR CSS working * remove unused code * rename CLI * simplify configs * tweak relationship between different packages * simplify app-utils * update tests to remove app startup crashes in prod * fix lockfile * tweak some file locations etc, get some more tests passing * get tests passing * update lockfile * update lockfile * get all tests passing, locally at least * remove snowpack-related stuff * add vite-plugin-svelte to monorepo * lint * dont remove styles, it breaks stuff. TODO investigate * Upgrade vite * fix some sourcemap stuff * remove vite-plugin-svelte from workspace until things settle down more * fix lockfile * gloss over import.meta transform bug for now * hack around vite bugs until 2.0.4 * only lint src files * remove source-map-support, it was causing weird stuff to happen * ensure renderer waits for layout/error styles * i really dont understand this lockfile bollocks * Upgrade to vite 2.0.4 * add fork of @svitejs/vite-plugin-svelte back to monorepo * lint * make run in node 12 * ffffuuuuuuu * Fix file path * specify vite 2.0.4 everywhere * add some logging to try and diagnose CI test failures * fix output directories * remove logging Co-authored-by: Ben McCann <[email protected]> * update lockfile * remove merge conflict artifact * fix unrelated typo * restore alias * remove some obsolete deps Co-authored-by: Ben McCann <[email protected]>
1 parent 55ccb31 commit 3c4c198

File tree

111 files changed

+2890
-2311
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+2890
-2311
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,32 @@
1-
------
1+
---
2+
23
Before filing an issue we'd appreciate it if you could take a moment to ensure
34
there isn't already an open issue or pull-request.
4-
-----
5+
6+
---
57

68
If there's an existing issue, please add a :+1: reaction to the description of
79
the issue. One way we prioritize issues is by the number of :+1: reactions on
810
their descriptions. Please DO NOT add `+1` or :+1: comments.
911

1012
### Feature requests and proposals
13+
1114
We're excited to hear how we can make SvelteKit better. Please add as much detail
1215
as you can on your use case. To propose an implementation of a large feature or
1316
change, please create an [RFC](https://github.com/sveltejs/rfcs).
1417

1518
### Bugs
19+
1620
If you're filing an issue about a bug please include as much information
1721
as you can, including the following.
1822

19-
- The output of `npx envinfo --system --npmPackages svelte,@sveltejs/kit,@sveltejs/snowpack-config --binaries --browsers`
23+
- The output of `npx envinfo --system --npmPackages svelte,@sveltejs/kit --binaries --browsers`
2024
- Your browser
2125
- Your adapter (e.g. Node, static, Vercel, Begin, etc...)
2226

23-
- *Repeatable steps to reproduce the issue*
27+
- _Repeatable steps to reproduce the issue_
2428

2529
* We recommend creating a small repo that illustrates the problem.
2630
* Reproductions should be small, self-contained, correct examples – http://sscce.org.
2731

28-
Thanks for being part of SvelteKit!
29-
-------
32+
## Thanks for being part of SvelteKit!

documentation/docs/01-structure.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ If you take a look inside a new SvelteKit project, you'll see some files that Sv
1515
│ └ app.html
1616
├ static
1717
│ ├ # your files here
18-
snowpack.config.cjs
19-
svelte.config.cjs
18+
svelte.config.cjs
19+
vite.config.js
2020
```
2121

2222
### package.json
@@ -73,10 +73,10 @@ Sapper doesn't serve these files — you'd typically use [sirv](https://github.c
7373

7474
> Note that the default behaviour of the service worker is to cache all assets from the static directory, so if you have more than 50mb of files here, you will start to exceed the cache limit for service-workers in some browsers, which can cause the service worker to stop loading. In this instance, it is advisable to customise what files are cached by editing the service-worker yourself.
7575
76-
### snowpack.config.cjs
77-
78-
This is the [Snowpack configuration file](https://www.snowpack.dev/reference/configuration) for your project.
79-
8076
### svelte.config.cjs
8177

8278
This file contains SvelteKit options as well as options for `svelte-preprocess`.
79+
80+
### vite.config.js
81+
82+
This is the [Vite configuration file](https://vitejs.dev/config/) for your project.

examples/hn.svelte.dev/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"devDependencies": {
1212
"@sveltejs/adapter-netlify": "workspace:*",
1313
"@sveltejs/kit": "workspace:*",
14-
"@sveltejs/snowpack-config": "workspace:*",
1514
"svelte": "^3.32.1"
1615
}
1716
}

examples/hn.svelte.dev/snowpack.config.cjs

Lines changed: 0 additions & 10 deletions
This file was deleted.

examples/hn.svelte.dev/src/components/Nav.svelte

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
<img alt="Svelte Hacker News logo" class="icon" src="/favicon.png">
77

88
<ul>
9-
<li><a rel="prefetch" href="/top/1" class:selected={section === "top"}>top</a></li>
10-
<li><a rel="prefetch" href="/new/1" class:selected={section === "new"}>new</a></li>
11-
<li><a rel="prefetch" href="/show/1" class:selected={section === "show"}>show</a></li>
12-
<li><a rel="prefetch" href="/ask/1" class:selected={section === "ask"}>ask</a></li>
13-
<li><a rel="prefetch" href="/jobs/1" class:selected={section === "jobs"}>jobs</a></li>
9+
<li><a sveltekit:prefetch href="/top/1" class:selected={section === "top"}>top</a></li>
10+
<li><a sveltekit:prefetch href="/new/1" class:selected={section === "new"}>new</a></li>
11+
<li><a sveltekit:prefetch href="/show/1" class:selected={section === "show"}>show</a></li>
12+
<li><a sveltekit:prefetch href="/ask/1" class:selected={section === "ask"}>ask</a></li>
13+
<li><a sveltekit:prefetch href="/jobs/1" class:selected={section === "jobs"}>jobs</a></li>
1414

15-
<li class="about"><a rel="prefetch" href="/about" class:selected={section === "about"}>about</a></li>
15+
<li class="about"><a sveltekit:prefetch href="/about" class:selected={section === "about"}>about</a></li>
1616
</ul>
1717
</nav>
1818

examples/hn.svelte.dev/src/routes/$error.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<script>
2+
import { dev } from '$app/env';
3+
24
export let status;
35
export let error;
46
5-
const dev = process.env.NODE_ENV === 'development';
67
const offline = typeof navigator !== 'undefined' && navigator.onLine === false;
78
89
const title = offline ? 'Offline' : status;

examples/hn.svelte.dev/src/routes/[list]/_ItemSummary.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
{:else}
1414
<p>
1515
{item.points} points by
16-
<a rel="prefetch" href="/user/{item.user}">{item.user}</a> {item.time_ago}
17-
| <a rel="prefetch" href="/item/{item.id}">{item.comments_count} {item.comments_count === 1 ? 'comment' : 'comments'}</a>
16+
<a sveltekit:prefetch href="/user/{item.user}">{item.user}</a> {item.time_ago}
17+
| <a sveltekit:prefetch href="/item/{item.id}">{item.comments_count} {item.comments_count === 1 ? 'comment' : 'comments'}</a>
1818
</p>
1919
{/if}
2020

examples/hn.svelte.dev/src/routes/item/_Comment.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{#if !comment.deleted}
88
<article class="comment" class:hidden>
99
<div class="meta-bar" on:click="{() => hidden = !hidden}">
10-
<span class="meta"><a rel="prefetch" href="/user/{comment.user}">{comment.user}</a> {comment.time_ago}</span>
10+
<span class="meta"><a sveltekit:prefetch href="/user/{comment.user}">{comment.user}</a> {comment.time_ago}</span>
1111
</div>
1212

1313
<div class="body">
@@ -36,12 +36,12 @@
3636
.meta-bar {
3737
padding: 1em 0;
3838
cursor: pointer;
39-
background: 100% 50% no-repeat url(/icons/fold.svg);
39+
background: 100% 50% no-repeat url(./_icons/fold.svg);
4040
background-size: 1em 1em;
4141
}
4242
4343
.hidden .meta-bar {
44-
background-image: url(/icons/unfold.svg);
44+
background-image: url(./_icons/unfold.svg);
4545
}
4646
4747
.comment .children {

examples/hn.svelte.dev/vite.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { resolve } from 'path';
2+
3+
export default {
4+
resolve: {
5+
alias: {
6+
$components: resolve('src/components')
7+
}
8+
}
9+
};

examples/realworld.svelte.dev/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"devDependencies": {
1212
"@sveltejs/adapter-node": "workspace:*",
1313
"@sveltejs/kit": "workspace:*",
14-
"@sveltejs/snowpack-config": "workspace:*",
1514
"marked": "^1.2.8",
1615
"svelte": "^3.32.1"
1716
},

examples/realworld.svelte.dev/snowpack.config.cjs

Lines changed: 0 additions & 15 deletions
This file was deleted.

examples/realworld.svelte.dev/src/routes/$error.svelte

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<script>
2+
import { dev } from '$app/env';
23
import Layout from './$layout.svelte';
34
45
export let error, status;
5-
6-
let dev = import.meta.env.MODE === 'development';
76
</script>
87

98
<svelte:head>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { resolve } from 'path';
2+
3+
export default {
4+
resolve: {
5+
alias: {
6+
$common: resolve('src/common'),
7+
$components: resolve('src/components')
8+
}
9+
}
10+
};

examples/sandbox/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"devDependencies": {
1212
"@sveltejs/adapter-node": "workspace:*",
1313
"@sveltejs/kit": "workspace:*",
14-
"@sveltejs/snowpack-config": "workspace:*",
1514
"svelte": "^3.32.1"
1615
}
1716
}

examples/sandbox/snowpack.config.cjs

Lines changed: 0 additions & 10 deletions
This file was deleted.

examples/sandbox/vite.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { resolve } from 'path';
2+
3+
export default {
4+
resolve: {
5+
alias: {
6+
$components: resolve('src/components')
7+
}
8+
}
9+
};

examples/svelte-kit-demo/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"@sveltejs/adapter-node": "workspace:*",
1313
"@sveltejs/adapter-static": "workspace:*",
1414
"@sveltejs/kit": "workspace:*",
15-
"@sveltejs/snowpack-config": "workspace:*",
1615
"svelte": "^3.32.1"
1716
}
1817
}

examples/svelte-kit-demo/snowpack.config.cjs

Lines changed: 0 additions & 10 deletions
This file was deleted.

examples/svelte-kit-demo/src/components/Nav.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
</script>
44

55
<nav>
6-
<a href="/" rel="prefetch" class:active={path === '/'}>home</a>
7-
<a href="/about" rel="prefetch" class:active={path === '/about'}>about</a>
8-
<a href="/blog" rel="prefetch" class:active={path === '/blog'}>blog</a>
6+
<a href="/" sveltekit:prefetch class:active={path === '/'}>home</a>
7+
<a href="/about" sveltekit:prefetch class:active={path === '/about'}>about</a>
8+
<a href="/blog" sveltekit:prefetch class:active={path === '/blog'}>blog</a>
99
</nav>
1010

1111
<style>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { resolve } from 'path';
2+
3+
export default {
4+
resolve: {
5+
alias: {
6+
$components: resolve('src/components')
7+
}
8+
}
9+
};

packages/app-utils/.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
11
.DS_Store
22
node_modules
3-
4-
/files
5-
/http
6-
/renderer

packages/app-utils/src/files/index.js renamed to packages/app-utils/files/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import * as fs from 'fs';
2-
import * as path from 'path';
1+
import fs from 'fs';
2+
import path from 'path';
33

44
export function mkdirp(dir) {
55
try {
@@ -10,6 +10,10 @@ export function mkdirp(dir) {
1010
}
1111
}
1212

13+
export function rimraf(path) {
14+
(fs.rmSync || fs.rmdirSync)(path, { recursive: true, force: true });
15+
}
16+
1317
export function copy(from, to, filter = () => true) {
1418
if (!filter(path.basename(from))) return [];
1519

packages/app-utils/package.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@
22
"name": "@sveltejs/app-utils",
33
"version": "1.0.0-next.1",
44
"scripts": {
5-
"clean": "node rimraf.js files http renderer",
6-
"dev": "npm run clean && rollup -cw",
7-
"build": "npm run clean && rollup -c",
85
"lint": "eslint --ignore-path .gitignore \"**/*.{ts,js,svelte}\" && npm run check-format",
96
"format": "prettier --write . --config ../../.prettierrc --ignore-path .gitignore",
107
"check-format": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore",
11-
"prepublishOnly": "npm run build",
128
"test": "uvu"
139
},
1410
"dependencies": {
@@ -34,7 +30,6 @@
3430
},
3531
"files": [
3632
"files",
37-
"http",
38-
"renderer"
33+
"http"
3934
]
4035
}

packages/app-utils/rimraf.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

packages/app-utils/rollup.config.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

packages/create-svelte/cli/modifications/add_css.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { bold, green } from 'kleur/colors';
2-
import { add_svelte_prepocess_to_config, update_component, update_package_json } from './utils';
2+
import { add_svelte_preprocess_to_config, update_component, update_package_json } from './utils';
33

44
export default async function add_css(cwd, which) {
55
if (which === 'css') {
@@ -11,7 +11,7 @@ export default async function add_css(cwd, which) {
1111
});
1212
update_component(cwd, 'src/components/Counter.svelte', [['<style>', '<style lang="less">']]);
1313
update_component(cwd, 'src/routes/index.svelte', [['<style>', '<style lang="less">']]);
14-
add_svelte_prepocess_to_config(cwd);
14+
add_svelte_preprocess_to_config(cwd);
1515
console.log(
1616
bold(
1717
green(
@@ -27,7 +27,7 @@ export default async function add_css(cwd, which) {
2727
});
2828
update_component(cwd, 'src/components/Counter.svelte', [['<style>', '<style lang="scss">']]);
2929
update_component(cwd, 'src/routes/index.svelte', [['<style>', '<style lang="scss">']]);
30-
add_svelte_prepocess_to_config(cwd);
30+
add_svelte_preprocess_to_config(cwd);
3131
console.log(
3232
bold(
3333
green(

0 commit comments

Comments
 (0)