mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-16 12:54:38 +00:00
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a70e88b1f4 | ||
|
|
2758382c68 | ||
|
|
dd7f1ff99c | ||
|
|
45142cd037 | ||
|
|
ceb1caf1de | ||
|
|
7e263a3076 | ||
|
|
ec88d4a430 | ||
|
|
909ea72108 | ||
|
|
cd09d75d99 | ||
|
|
0e3abe489a | ||
|
|
a5d141d2f1 | ||
|
|
87eae6164b | ||
|
|
97e00f5a9c | ||
|
|
bd55558b5e | ||
|
|
25dc4b3a4c | ||
|
|
72c27b78a3 | ||
|
|
25809ec409 | ||
|
|
3220c522d7 |
21
CHANGELOG.md
21
CHANGELOG.md
@@ -1,5 +1,26 @@
|
|||||||
# sapper changelog
|
# sapper changelog
|
||||||
|
|
||||||
|
## 0.10.6
|
||||||
|
|
||||||
|
* Fix error reporting in `sapper start`
|
||||||
|
|
||||||
|
## 0.10.5
|
||||||
|
|
||||||
|
* Fix missing service worker ([#231](https://github.com/sveltejs/sapper/pull/231))
|
||||||
|
|
||||||
|
## 0.10.4
|
||||||
|
|
||||||
|
* Upgrade chokidar, this time with a fix ([#227](https://github.com/sveltejs/sapper/pull/227))
|
||||||
|
|
||||||
|
## 0.10.3
|
||||||
|
|
||||||
|
* Downgrade chokidar ([#212](https://github.com/sveltejs/sapper/issues/212))
|
||||||
|
|
||||||
|
## 0.10.2
|
||||||
|
|
||||||
|
* Attach `store` to error pages
|
||||||
|
* Fix sorting edge case ([#215](https://github.com/sveltejs/sapper/pull/215))
|
||||||
|
|
||||||
## 0.10.1
|
## 0.10.1
|
||||||
|
|
||||||
* Fix server-side `fetch` paths ([#207](https://github.com/sveltejs/sapper/pull/207))
|
* Fix server-side `fetch` paths ([#207](https://github.com/sveltejs/sapper/pull/207))
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sapper",
|
"name": "sapper",
|
||||||
"version": "0.10.1",
|
"version": "0.10.6",
|
||||||
"description": "Military-grade apps, engineered by Svelte",
|
"description": "Military-grade apps, engineered by Svelte",
|
||||||
"main": "dist/middleware.ts.js",
|
"main": "dist/middleware.ts.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cheerio": "^1.0.0-rc.2",
|
"cheerio": "^1.0.0-rc.2",
|
||||||
"chokidar": "^2.0.2",
|
"chokidar": "^2.0.3",
|
||||||
"clorox": "^1.0.3",
|
"clorox": "^1.0.3",
|
||||||
"cookie": "^0.3.1",
|
"cookie": "^0.3.1",
|
||||||
"devalue": "^1.0.1",
|
"devalue": "^1.0.1",
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ export async function dev(opts: { port: number, open: boolean }) {
|
|||||||
|
|
||||||
const hot_update_server = create_hot_update_server(dev_port);
|
const hot_update_server = create_hot_update_server(dev_port);
|
||||||
|
|
||||||
watch_files(`${locations.routes()}/**/*`, ['add', 'unlink'], () => {
|
watch_files(locations.routes(), ['add', 'unlink'], () => {
|
||||||
const routes = create_routes();
|
const routes = create_routes();
|
||||||
create_main_manifests({ routes, dev_port });
|
create_main_manifests({ routes, dev_port });
|
||||||
});
|
});
|
||||||
@@ -311,7 +311,8 @@ function watch_files(pattern: string, events: string[], callback: () => void) {
|
|||||||
|
|
||||||
const watcher = chokidar.watch(pattern, {
|
const watcher = chokidar.watch(pattern, {
|
||||||
persistent: true,
|
persistent: true,
|
||||||
ignoreInitial: true
|
ignoreInitial: true,
|
||||||
|
disableGlobbing: true
|
||||||
});
|
});
|
||||||
|
|
||||||
events.forEach(event => {
|
events.forEach(event => {
|
||||||
|
|||||||
@@ -11,13 +11,13 @@ export async function start(dir: string, opts: { port: number, open: boolean })
|
|||||||
const server = path.resolve(dir, 'server.js');
|
const server = path.resolve(dir, 'server.js');
|
||||||
|
|
||||||
if (!fs.existsSync(server)) {
|
if (!fs.existsSync(server)) {
|
||||||
console.log(clorox.bold.red(`> ${dir}/server.js does not exist — type ${clorox.bold.cyan(dir === 'build' ? `npx sapper build` : `npx sapper build ${dir}`)} to create it`));
|
console.log(`${clorox.bold.red(`> ${dir}/server.js does not exist — type ${clorox.bold.cyan(dir === 'build' ? `npx sapper build` : `npx sapper build ${dir}`)} to create it`)}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (port) {
|
if (port) {
|
||||||
if (!await ports.check(port)) {
|
if (!await ports.check(port)) {
|
||||||
console.log(clorox.bold.red(`> Port ${port} is unavailable`));
|
console.log(`${clorox.bold.red(`> Port ${port} is unavailable`)}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -102,7 +102,10 @@ export default function create_routes({ files } = { files: glob.sync('**/*.*', {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!a_sub_part.dynamic && a_sub_part.content !== b_sub_part.content) {
|
if (!a_sub_part.dynamic && a_sub_part.content !== b_sub_part.content) {
|
||||||
return b_sub_part.content.length - a_sub_part.content.length;
|
return (
|
||||||
|
(b_sub_part.content.length - a_sub_part.content.length) ||
|
||||||
|
(a_sub_part.content < b_sub_part.content ? -1 : 1)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -245,11 +245,11 @@ function get_route_handler(chunks: Record<string, string>, routes: RouteObject[]
|
|||||||
`baseUrl: "${req.baseUrl}"`,
|
`baseUrl: "${req.baseUrl}"`,
|
||||||
serialized.preloaded && `preloaded: ${serialized.preloaded}`,
|
serialized.preloaded && `preloaded: ${serialized.preloaded}`,
|
||||||
serialized.store && `store: ${serialized.store}`
|
serialized.store && `store: ${serialized.store}`
|
||||||
].filter(Boolean).join(',')}}`
|
].filter(Boolean).join(',')}};`;
|
||||||
|
|
||||||
const has_service_worker = fs.existsSync(path.join(locations.dest(), 'service-worker.js'));
|
const has_service_worker = fs.existsSync(path.join(locations.dest(), 'service-worker.js'));
|
||||||
if (has_service_worker) {
|
if (has_service_worker) {
|
||||||
`if ('serviceWorker' in navigator) navigator.serviceWorker.register('${req.baseUrl}/service-worker.js')`
|
inline_script += `if ('serviceWorker' in navigator) navigator.serviceWorker.register('${req.baseUrl}/service-worker.js');`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const page = template()
|
const page = template()
|
||||||
@@ -356,6 +356,8 @@ function get_route_handler(chunks: Record<string, string>, routes: RouteObject[]
|
|||||||
const rendered = route ? route.module.render({
|
const rendered = route ? route.module.render({
|
||||||
status: statusCode,
|
status: statusCode,
|
||||||
error
|
error
|
||||||
|
}, {
|
||||||
|
store: store_getter && store_getter(req)
|
||||||
}) : { head: '', css: null, html: title };
|
}) : { head: '', css: null, html: title };
|
||||||
|
|
||||||
const { head, css, html } = rendered;
|
const { head, css, html } = rendered;
|
||||||
|
|||||||
@@ -559,6 +559,12 @@ function run({ mode, basepath = '' }) {
|
|||||||
assert.equal(title, 'woohoo!');
|
assert.equal(title, 'woohoo!');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('includes service worker', () => {
|
||||||
|
return nightmare.goto(base).page.html().then(html => {
|
||||||
|
assert.ok(html.indexOf('service-worker.js') !== -1);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('headers', () => {
|
describe('headers', () => {
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ describe('create_routes', () => {
|
|||||||
[
|
[
|
||||||
'index.html',
|
'index.html',
|
||||||
'about.html',
|
'about.html',
|
||||||
'post/foo.html',
|
|
||||||
'post/bar.html',
|
'post/bar.html',
|
||||||
|
'post/foo.html',
|
||||||
'post/f[xx].html',
|
'post/f[xx].html',
|
||||||
'post/[id].json.js',
|
'post/[id].json.js',
|
||||||
'post/[id].html',
|
'post/[id].html',
|
||||||
@@ -23,7 +23,7 @@ describe('create_routes', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('prefers index page to nested route', () => {
|
it('prefers index page to nested route', () => {
|
||||||
const routes = create_routes({
|
let routes = create_routes({
|
||||||
files: [
|
files: [
|
||||||
'api/examples/[slug].js',
|
'api/examples/[slug].js',
|
||||||
'api/examples/index.js',
|
'api/examples/index.js',
|
||||||
@@ -55,6 +55,45 @@ describe('create_routes', () => {
|
|||||||
'api/gists/[id].js',
|
'api/gists/[id].js',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
routes = create_routes({
|
||||||
|
files: [
|
||||||
|
'4xx.html',
|
||||||
|
'5xx.html',
|
||||||
|
'api/blog/[slug].js',
|
||||||
|
'api/blog/index.js',
|
||||||
|
'api/guide/contents.js',
|
||||||
|
'api/guide/index.js',
|
||||||
|
'blog/[slug].html',
|
||||||
|
'blog/index.html',
|
||||||
|
'blog/rss.xml.js',
|
||||||
|
'gist/[id].js',
|
||||||
|
'gist/create.js',
|
||||||
|
'guide/index.html',
|
||||||
|
'index.html',
|
||||||
|
'repl/index.html'
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.deepEqual(
|
||||||
|
routes.map(r => r.file),
|
||||||
|
[
|
||||||
|
'4xx.html',
|
||||||
|
'5xx.html',
|
||||||
|
'index.html',
|
||||||
|
'guide/index.html',
|
||||||
|
'blog/index.html',
|
||||||
|
'blog/rss.xml.js',
|
||||||
|
'blog/[slug].html',
|
||||||
|
'gist/create.js',
|
||||||
|
'gist/[id].js',
|
||||||
|
'repl/index.html',
|
||||||
|
'api/guide/index.js',
|
||||||
|
'api/guide/contents.js',
|
||||||
|
'api/blog/index.js',
|
||||||
|
'api/blog/[slug].js',
|
||||||
|
]
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('generates params', () => {
|
it('generates params', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user