mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-14 12:04:39 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dd6c51567a | ||
|
|
01ff84f241 | ||
|
|
329c113723 | ||
|
|
2ad10b380f | ||
|
|
e6314cde96 | ||
|
|
b64e25a177 |
@@ -1,5 +1,13 @@
|
|||||||
# sapper changelog
|
# sapper changelog
|
||||||
|
|
||||||
|
## 0.8.2
|
||||||
|
|
||||||
|
* Rename `preloadRoutes` to `prefetchRoutes` ([#166](https://github.com/sveltejs/sapper/issues/166))
|
||||||
|
|
||||||
|
## 0.8.1
|
||||||
|
|
||||||
|
* Add `sapper start` command, for running an app built with `sapper build` ([#163](https://github.com/sveltejs/sapper/issues/163))
|
||||||
|
|
||||||
## 0.8.0
|
## 0.8.0
|
||||||
|
|
||||||
* Update to webpack 4
|
* Update to webpack 4
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sapper",
|
"name": "sapper",
|
||||||
"version": "0.8.0",
|
"version": "0.8.2",
|
||||||
"description": "Military-grade apps, engineered by Svelte",
|
"description": "Military-grade apps, engineered by Svelte",
|
||||||
"main": "middleware.js",
|
"main": "middleware.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import * as path from 'path';
|
||||||
|
import * as child_process from 'child_process';
|
||||||
import mri from 'mri';
|
import mri from 'mri';
|
||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
import help from './help.md';
|
import help from './help.md';
|
||||||
@@ -28,36 +30,60 @@ const [cmd] = opts._;
|
|||||||
|
|
||||||
const start = Date.now();
|
const start = Date.now();
|
||||||
|
|
||||||
if (cmd === 'build') {
|
switch (cmd) {
|
||||||
process.env.NODE_ENV = 'production';
|
case 'build':
|
||||||
process.env.SAPPER_DEST = opts._[1] || 'build';
|
process.env.NODE_ENV = 'production';
|
||||||
|
process.env.SAPPER_DEST = opts._[1] || 'build';
|
||||||
|
|
||||||
build()
|
build()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const elapsed = Date.now() - start;
|
const elapsed = Date.now() - start;
|
||||||
console.error(`built in ${elapsed}ms`); // TODO beautify this, e.g. 'built in 4.7 seconds'
|
console.error(`built in ${elapsed}ms`); // TODO beautify this, e.g. 'built in 4.7 seconds'
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.error(err ? err.details || err.stack || err.message || err : 'Unknown error');
|
console.error(err ? err.details || err.stack || err.message || err : 'Unknown error');
|
||||||
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'export':
|
||||||
|
process.env.NODE_ENV = 'production';
|
||||||
|
|
||||||
|
const export_dir = opts._[1] || 'export';
|
||||||
|
|
||||||
|
build()
|
||||||
|
.then(() => exporter(export_dir))
|
||||||
|
.then(() => {
|
||||||
|
const elapsed = Date.now() - start;
|
||||||
|
console.error(`extracted in ${elapsed}ms`); // TODO beautify this, e.g. 'built in 4.7 seconds'
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error(err ? err.details || err.stack || err.message || err : 'Unknown error');
|
||||||
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'dev':
|
||||||
|
dev();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'upgrade':
|
||||||
|
upgrade();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'start':
|
||||||
|
const dir = path.resolve(opts._[1] || 'build');
|
||||||
|
|
||||||
|
child_process.fork(`${dir}/server.js`, [], {
|
||||||
|
cwd: process.cwd(),
|
||||||
|
env: Object.assign({
|
||||||
|
NODE_ENV: 'production',
|
||||||
|
SAPPER_DEST: dir
|
||||||
|
}, process.env)
|
||||||
});
|
});
|
||||||
} else if (cmd === 'export') {
|
|
||||||
process.env.NODE_ENV = 'production';
|
|
||||||
|
|
||||||
const export_dir = opts._[1] || 'export';
|
break;
|
||||||
|
|
||||||
build()
|
default:
|
||||||
.then(() => exporter(export_dir))
|
console.log(`unrecognized command ${cmd} — try \`sapper --help\` for more information`);
|
||||||
.then(() => {
|
|
||||||
const elapsed = Date.now() - start;
|
|
||||||
console.error(`extracted in ${elapsed}ms`); // TODO beautify this, e.g. 'built in 4.7 seconds'
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
console.error(err ? err.details || err.stack || err.message || err : 'Unknown error');
|
|
||||||
});
|
|
||||||
} else if (cmd === 'dev') {
|
|
||||||
dev();
|
|
||||||
} else if (cmd === 'upgrade') {
|
|
||||||
upgrade();
|
|
||||||
} else {
|
|
||||||
console.log(`unrecognized command ${cmd} — try \`sapper --help\` for more information`);
|
|
||||||
}
|
}
|
||||||
@@ -266,7 +266,7 @@ export function goto(href: string, opts = { replaceState: false }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function preloadRoutes(pathnames: string[]) {
|
export function prefetchRoutes(pathnames: string[]) {
|
||||||
if (!routes) throw new Error(`You must call init() first`);
|
if (!routes) throw new Error(`You must call init() first`);
|
||||||
|
|
||||||
return routes
|
return routes
|
||||||
@@ -282,3 +282,6 @@ export function preloadRoutes(pathnames: string[]) {
|
|||||||
return promise.then(route.load);
|
return promise.then(route.load);
|
||||||
}, Promise.resolve());
|
}, Promise.resolve());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// remove this in 0.9
|
||||||
|
export { prefetchRoutes as preloadRoutes };
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import { init, preloadRoutes } from '../../../runtime.js';
|
import { init, prefetchRoutes } from '../../../runtime.js';
|
||||||
import { routes } from './manifest/client.js';
|
import { routes } from './manifest/client.js';
|
||||||
|
|
||||||
window.init = () => {
|
window.init = () => {
|
||||||
return init(document.querySelector('#sapper'), routes);
|
return init(document.querySelector('#sapper'), routes);
|
||||||
};
|
};
|
||||||
|
|
||||||
window.preloadRoutes = preloadRoutes;
|
window.prefetchRoutes = prefetchRoutes;
|
||||||
@@ -23,8 +23,8 @@ Nightmare.action('init', function(done) {
|
|||||||
this.evaluate_now(() => window.init(), done);
|
this.evaluate_now(() => window.init(), done);
|
||||||
});
|
});
|
||||||
|
|
||||||
Nightmare.action('preloadRoutes', function(done) {
|
Nightmare.action('prefetchRoutes', function(done) {
|
||||||
this.evaluate_now(() => window.preloadRoutes(), done);
|
this.evaluate_now(() => window.prefetchRoutes(), done);
|
||||||
});
|
});
|
||||||
|
|
||||||
function run(env) {
|
function run(env) {
|
||||||
@@ -159,7 +159,7 @@ function run(env) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('navigates to a new page without reloading', () => {
|
it('navigates to a new page without reloading', () => {
|
||||||
return capture(() => nightmare.goto(base).init().preloadRoutes())
|
return capture(() => nightmare.goto(base).init().prefetchRoutes())
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return capture(() => nightmare.click('a[href="/about"]'));
|
return capture(() => nightmare.click('a[href="/about"]'));
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user