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 # sapper changelog
## 0.26.1
* Handle skipped segments ([#663](https://github.com/sveltejs/sapper/pull/663))
## 0.26.0 ## 0.26.0
* Update to Svelte 3 * Update to Svelte 3

View File

@@ -1,11 +1,11 @@
# sapper # 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? ## 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 ## Get started

41
package-lock.json generated
View File

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

View File

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

View File

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

View File

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

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'); assert.equal(await title(), 'bar');
}); });
it('navigates to ...rest', async () => { it('navigates to ...rest', async () => {
await page.goto(`${base}/abc/xyz`); await page.goto(`${base}/abc/xyz`);
await start(); await start();
@@ -298,7 +298,7 @@ describe('basics', function() {
await page.evaluate(() => document.body.textContent), await page.evaluate(() => document.body.textContent),
'xyz,abc,qwe' 'xyz,abc,qwe'
); );
}); });
it('navigates between dynamic routes with same segments', async () => { it('navigates between dynamic routes with same segments', async () => {
await page.goto(`${base}/dirs/bar/xyz`); await page.goto(`${base}/dirs/bar/xyz`);
@@ -324,4 +324,18 @@ describe('basics', function() {
assert.ok(html.body.indexOf('<h1>HTML</h1>') !== -1); 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'
);
});
}); });