mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-15 20:34:44 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f821c19528 | ||
|
|
b9a120164a | ||
|
|
087356f781 | ||
|
|
31110a5326 | ||
|
|
667a68768c | ||
|
|
5075981a90 |
@@ -1,5 +1,13 @@
|
|||||||
# sapper changelog
|
# sapper changelog
|
||||||
|
|
||||||
|
## 0.13.6
|
||||||
|
|
||||||
|
* Fix `baseUrl` synthesis ([#296](https://github.com/sveltejs/sapper/issues/296))
|
||||||
|
|
||||||
|
## 0.13.5
|
||||||
|
|
||||||
|
* Fix handling of fatal errors ([#289](https://github.com/sveltejs/sapper/issues/289))
|
||||||
|
|
||||||
## 0.13.4
|
## 0.13.4
|
||||||
|
|
||||||
* Focus `<body>` after navigation ([#287](https://github.com/sveltejs/sapper/issues/287))
|
* Focus `<body>` after navigation ([#287](https://github.com/sveltejs/sapper/issues/287))
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sapper",
|
"name": "sapper",
|
||||||
"version": "0.13.4",
|
"version": "0.13.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": {
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ class Watcher extends EventEmitter {
|
|||||||
server: Deferred;
|
server: Deferred;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
crashed: boolean;
|
||||||
restarting: boolean;
|
restarting: boolean;
|
||||||
current_build: {
|
current_build: {
|
||||||
changed: Set<string>;
|
changed: Set<string>;
|
||||||
@@ -130,10 +131,16 @@ class Watcher extends EventEmitter {
|
|||||||
// TODO watch the configs themselves?
|
// TODO watch the configs themselves?
|
||||||
const compilers = create_compilers({ webpack: this.dirs.webpack });
|
const compilers = create_compilers({ webpack: this.dirs.webpack });
|
||||||
|
|
||||||
|
let log = '';
|
||||||
|
|
||||||
const emitFatal = () => {
|
const emitFatal = () => {
|
||||||
this.emit('fatal', <events.FatalEvent>{
|
this.emit('fatal', <events.FatalEvent>{
|
||||||
message: `Server crashed`
|
message: `Server crashed`,
|
||||||
|
log
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.crashed = true;
|
||||||
|
this.proc = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.watch(compilers.server, {
|
this.watch(compilers.server, {
|
||||||
@@ -149,18 +156,30 @@ class Watcher extends EventEmitter {
|
|||||||
|
|
||||||
this.deferreds.client.promise.then(() => {
|
this.deferreds.client.promise.then(() => {
|
||||||
const restart = () => {
|
const restart = () => {
|
||||||
ports.wait(this.port).then((() => {
|
log = '';
|
||||||
this.emit('ready', <events.ReadyEvent>{
|
this.crashed = false;
|
||||||
port: this.port,
|
|
||||||
process: this.proc
|
|
||||||
});
|
|
||||||
|
|
||||||
this.deferreds.server.fulfil();
|
ports.wait(this.port)
|
||||||
|
.then((() => {
|
||||||
|
this.emit('ready', <events.ReadyEvent>{
|
||||||
|
port: this.port,
|
||||||
|
process: this.proc
|
||||||
|
});
|
||||||
|
|
||||||
this.dev_server.send({
|
this.deferreds.server.fulfil();
|
||||||
status: 'completed'
|
|
||||||
|
this.dev_server.send({
|
||||||
|
status: 'completed'
|
||||||
|
});
|
||||||
|
}))
|
||||||
|
.catch(err => {
|
||||||
|
if (this.crashed) return;
|
||||||
|
|
||||||
|
this.emit('fatal', <events.FatalEvent>{
|
||||||
|
message: `Server is not listening on port ${this.port}`,
|
||||||
|
log
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.proc) {
|
if (this.proc) {
|
||||||
@@ -180,10 +199,12 @@ class Watcher extends EventEmitter {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.proc.stdout.on('data', chunk => {
|
this.proc.stdout.on('data', chunk => {
|
||||||
|
log += chunk;
|
||||||
this.emit('stdout', chunk);
|
this.emit('stdout', chunk);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.proc.stderr.on('data', chunk => {
|
this.proc.stderr.on('data', chunk => {
|
||||||
|
log += chunk;
|
||||||
this.emit('stderr', chunk);
|
this.emit('stderr', chunk);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -301,7 +322,7 @@ class Watcher extends EventEmitter {
|
|||||||
if (err) {
|
if (err) {
|
||||||
this.emit('error', <events.ErrorEvent>{
|
this.emit('error', <events.ErrorEvent>{
|
||||||
type: name,
|
type: name,
|
||||||
error: err
|
message: err.message
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const messages = format_messages(stats);
|
const messages = format_messages(stats);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ export type ErrorEvent = {
|
|||||||
|
|
||||||
export type FatalEvent = {
|
export type FatalEvent = {
|
||||||
message: string;
|
message: string;
|
||||||
|
log?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type InvalidEvent = {
|
export type InvalidEvent = {
|
||||||
|
|||||||
@@ -36,11 +36,12 @@ export function dev(opts: { port: number, open: boolean }) {
|
|||||||
|
|
||||||
watcher.on('error', (event: events.ErrorEvent) => {
|
watcher.on('error', (event: events.ErrorEvent) => {
|
||||||
console.log(`${colors.red(`✗ ${event.type}`)}`);
|
console.log(`${colors.red(`✗ ${event.type}`)}`);
|
||||||
console.log(`${colors.red(event.error.message)}`);
|
console.log(`${colors.red(event.message)}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
watcher.on('fatal', (event: events.FatalEvent) => {
|
watcher.on('fatal', (event: events.FatalEvent) => {
|
||||||
console.log(`${colors.bold.red(`> ${event.error.message}`)}`);
|
console.log(`${colors.bold.red(`> ${event.message}`)}`);
|
||||||
|
if (event.log) console.log(event.log);
|
||||||
});
|
});
|
||||||
|
|
||||||
watcher.on('build', (event: events.BuildEvent) => {
|
watcher.on('build', (event: events.BuildEvent) => {
|
||||||
|
|||||||
@@ -61,8 +61,13 @@ export default function middleware({ App, routes, store }: {
|
|||||||
const middleware = compose_handlers([
|
const middleware = compose_handlers([
|
||||||
(req: Req, res: ServerResponse, next: () => void) => {
|
(req: Req, res: ServerResponse, next: () => void) => {
|
||||||
if (req.baseUrl === undefined) {
|
if (req.baseUrl === undefined) {
|
||||||
req.baseUrl = req.originalUrl
|
let { originalUrl } = req;
|
||||||
? req.originalUrl.slice(0, -req.url.length)
|
if (req.url === '/' && originalUrl[originalUrl.length - 1] !== '/') {
|
||||||
|
originalUrl += '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
req.baseUrl = originalUrl
|
||||||
|
? originalUrl.slice(0, -req.url.length)
|
||||||
: '';
|
: '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user