Compare commits

..

9 Commits

Author SHA1 Message Date
Richard Harris
c99b787632 -> v0.26.1 2019-05-05 11:44:53 -04:00
Rich Harris
99a25308fc Merge pull request #663 from sveltejs/skipped-segments
Handle skipped segments
2019-05-05 11:44:08 -04:00
Richard Harris
c0ada5c52f handle skipped segments 2019-05-05 11:36:02 -04:00
Richard Harris
d51e1a0af8 failing test for skipped segments 2019-05-05 10:49:38 -04:00
Rich Harris
49f8b2c4bd Update 10-exporting.md 2019-05-04 10:58:26 -04:00
Rich Harris
2754ba0ee4 Merge pull request #655 from zigomir/patch-1
Fix template
2019-05-04 10:34:10 -04:00
ziga
1ad27573c6 Need to use branch
- fix port
2019-05-02 20:41:11 -04:00
ziga
f10b941c4e Fix template 2019-05-02 20:37:11 -04:00
Conduitry
6ca869a3b1 update links in readme 2019-05-02 10:11:24 -04:00
9 changed files with 71 additions and 47 deletions

View File

@@ -1,5 +1,9 @@
# sapper changelog
## 0.26.1
* Handle skipped segments ([#663](https://github.com/sveltejs/sapper/pull/663))
## 0.26.0
* Update to Svelte 3

View File

@@ -1,11 +1,11 @@
# sapper
[Military-grade progressive web apps, powered by Svelte.](https://sapper.svelte.technology)
[Military-grade progressive web apps, powered by Svelte.](https://sapper.svelte.dev)
## What is Sapper?
Sapper is a framework for building high-performance universal web apps. [Read the guide](https://sapper.svelte.technology/guide) or the [introductory blog post](https://svelte.technology/blog/sapper-towards-the-ideal-web-app-framework) to learn more.
Sapper is a framework for building high-performance universal web apps. [Read the guide](https://sapper.svelte.dev/docs) or the [introductory blog post](https://svelte.dev/blog/sapper-towards-the-ideal-web-app-framework) to learn more.
## Get started
@@ -74,4 +74,4 @@ npm run test
## License
[LIL](LICENSE)
[LIL](LICENSE)

41
package-lock.json generated
View File

@@ -1986,8 +1986,7 @@
"ansi-regex": {
"version": "2.1.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"aproba": {
"version": "1.2.0",
@@ -2008,14 +2007,12 @@
"balanced-match": {
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@@ -2030,20 +2027,17 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"core-util-is": {
"version": "1.0.2",
@@ -2160,8 +2154,7 @@
"inherits": {
"version": "2.0.3",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"ini": {
"version": "1.3.5",
@@ -2173,7 +2166,6 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@@ -2188,7 +2180,6 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@@ -2196,14 +2187,12 @@
"minimist": {
"version": "0.0.8",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"minipass": {
"version": "2.3.5",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
@@ -2222,7 +2211,6 @@
"version": "0.5.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
@@ -2303,8 +2291,7 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"object-assign": {
"version": "4.1.1",
@@ -2316,7 +2303,6 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
@@ -2402,8 +2388,7 @@
"safe-buffer": {
"version": "5.1.2",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"safer-buffer": {
"version": "2.1.2",
@@ -2439,7 +2424,6 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
@@ -2459,7 +2443,6 @@
"version": "3.0.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
@@ -2503,14 +2486,12 @@
"wrappy": {
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"yallist": {
"version": "3.0.3",
"bundled": true,
"dev": true,
"optional": true
"dev": true
}
}
},

View File

@@ -1,6 +1,6 @@
{
"name": "sapper",
"version": "0.26.0",
"version": "0.26.1",
"description": "Military-grade apps, engineered by Svelte",
"bin": {
"sapper": "./sapper"

View File

@@ -288,14 +288,22 @@ export async function hydrate_target(target: Target): Promise<{
let l = 1;
try {
let segment_dirty = false;
branch = await Promise.all(route.parts.map(async (part, i) => {
const segment = segments[i];
if (current_branch[i] && current_branch[i].segment !== segment) segment_dirty = true;
props.segments[l] = segments[i + 1]; // TODO make this less confusing
if (!part) return null;
if (!part) return { segment };
const j = l++;
const segment = segments[i];
if (!session_dirty && current_branch[i] && current_branch[i].segment === segment && current_branch[i].part === part.i) return current_branch[i];
if (!session_dirty && !segment_dirty && current_branch[i] && current_branch[i].part === part.i) {
return current_branch[i];
}
segment_dirty = false;
const { default: component, preload } = await load_component(components[part.i]);

View File

@@ -44,7 +44,7 @@ You can also add a script to your package.json...
When you run `sapper export`, Sapper first builds a production version of your app, as though you had run `sapper build`, and copies the contents of your `assets` folder to the destination. It then starts the server, and navigates to the root of your app. From there, it follows any `<a>` elements it finds, and captures any data served by the app.
Because of this, any pages you want to be included in the exported site must be reachable by `<a>` elements. Additionally, any non-page routes should be requested in `preload`, *not* in `oncreate` or elsewhere.
Because of this, any pages you want to be included in the exported site must be reachable by `<a>` elements. Additionally, any non-page routes should be requested in `preload`, *not* in `onMount` or elsewhere.
### When not to export
@@ -60,4 +60,4 @@ Because `sapper export` writes to the filesystem, it isn't possible to have two
The solution is to rename one of the routes to avoid conflict — for example, `src/routes/foo-bar.js`. (Note that you would also need to update any code that fetches data from `/foo/bar` to reference `/foo-bar` instead.)
For *pages*, we skirt around this problem by writing `export/foo/index.html` instead of `export/foo`.
For *pages*, we skirt around this problem by writing `export/foo/index.html` instead of `export/foo`.

View File

@@ -49,13 +49,16 @@
<div style="grid-area: start; display: flex; flex-direction: column; min-width: 0" slot="how">
<pre class="language-bash" style="margin: 0 0 1em 0; min-width: 0; min-height: 0">
npx degit sveltejs/template my-svelte-project
cd my-svelte-project
# for Rollup
npx degit sveltejs/sapper-template#rollup my-app
# for webpack
npx degit sveltejs/sapper-template#webpack my-app
cd my-app
npm install
npm run dev & open http://localhost:5000
npm run dev & open http://localhost:3000
</pre>
<p class="cta"><a rel="prefetch" href="docs">Learn Sapper</a></p>
</div>
</Blurb>
</Blurb>

View File

@@ -0,0 +1,14 @@
<script context="module">
export function preload({ params }) {
return params;
}
</script>
<script>
export let one;
export let two;
</script>
<h1>{one}:{two}</h1>
<a href="skipped/y/1">skipped/y/1</a>

View File

@@ -282,7 +282,7 @@ describe('basics', function() {
assert.equal(await title(), 'bar');
});
it('navigates to ...rest', async () => {
it('navigates to ...rest', async () => {
await page.goto(`${base}/abc/xyz`);
await start();
@@ -298,8 +298,8 @@ describe('basics', function() {
await page.evaluate(() => document.body.textContent),
'xyz,abc,qwe'
);
});
});
it('navigates between dynamic routes with same segments', async () => {
await page.goto(`${base}/dirs/bar/xyz`);
await start();
@@ -310,7 +310,7 @@ describe('basics', function() {
await wait(50);
assert.equal(await title(), 'B page');
});
it('runs server route handlers before page handlers, if they match', async () => {
const json = await get(`${base}/middleware`, {
headers: {
@@ -324,4 +324,18 @@ describe('basics', function() {
assert.ok(html.body.indexOf('<h1>HTML</h1>') !== -1);
});
it('invalidates page when a segment is skipped', async () => {
await page.goto(`${base}/skipped/x/1`);
await start();
await prefetchRoutes();
await page.click('a[href="skipped/y/1"]');
await wait(50);
assert.equal(
await title(),
'y:1'
);
});
});