mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-14 20:14:39 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
46bf8f2b78 | ||
|
|
553db81b7b | ||
|
|
67cc29ed38 | ||
|
|
36f930f489 | ||
|
|
3b098caa6e |
@@ -1,5 +1,13 @@
|
|||||||
# sapper changelog
|
# sapper changelog
|
||||||
|
|
||||||
|
## 0.18.2
|
||||||
|
|
||||||
|
* Update `pkg.files`
|
||||||
|
|
||||||
|
## 0.18.1
|
||||||
|
|
||||||
|
* Add live reloading ([#385](https://github.com/sveltejs/sapper/issues/385))
|
||||||
|
|
||||||
## 0.18.0
|
## 0.18.0
|
||||||
|
|
||||||
* Rollup support ([#379](https://github.com/sveltejs/sapper/pull/379))
|
* Rollup support ([#379](https://github.com/sveltejs/sapper/pull/379))
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sapper",
|
"name": "sapper",
|
||||||
"version": "0.18.0",
|
"version": "0.18.2",
|
||||||
"description": "Military-grade apps, engineered by Svelte",
|
"description": "Military-grade apps, engineered by Svelte",
|
||||||
"main": "dist/middleware.js",
|
"main": "dist/middleware.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
"*.js",
|
"*.js",
|
||||||
"runtime",
|
"runtime",
|
||||||
"webpack",
|
"webpack",
|
||||||
|
"config",
|
||||||
"sapper",
|
"sapper",
|
||||||
"components",
|
"components",
|
||||||
"dist"
|
"dist"
|
||||||
|
|||||||
@@ -29,14 +29,13 @@ class Watcher extends EventEmitter {
|
|||||||
}
|
}
|
||||||
port: number;
|
port: number;
|
||||||
closed: boolean;
|
closed: boolean;
|
||||||
|
live: boolean;
|
||||||
|
hot: boolean;
|
||||||
|
|
||||||
dev_server: DevServer;
|
dev_server: DevServer;
|
||||||
proc: child_process.ChildProcess;
|
proc: child_process.ChildProcess;
|
||||||
filewatchers: Array<{ close: () => void }>;
|
filewatchers: Array<{ close: () => void }>;
|
||||||
deferreds: {
|
deferred: Deferred;
|
||||||
client: Deferred;
|
|
||||||
server: Deferred;
|
|
||||||
};
|
|
||||||
|
|
||||||
crashed: boolean;
|
crashed: boolean;
|
||||||
restarting: boolean;
|
restarting: boolean;
|
||||||
@@ -51,6 +50,8 @@ class Watcher extends EventEmitter {
|
|||||||
app = locations.app(),
|
app = locations.app(),
|
||||||
dest = locations.dest(),
|
dest = locations.dest(),
|
||||||
routes = locations.routes(),
|
routes = locations.routes(),
|
||||||
|
live,
|
||||||
|
hot,
|
||||||
bundler,
|
bundler,
|
||||||
webpack = 'webpack',
|
webpack = 'webpack',
|
||||||
rollup = 'rollup',
|
rollup = 'rollup',
|
||||||
@@ -59,6 +60,8 @@ class Watcher extends EventEmitter {
|
|||||||
app: string,
|
app: string,
|
||||||
dest: string,
|
dest: string,
|
||||||
routes: string,
|
routes: string,
|
||||||
|
live: boolean,
|
||||||
|
hot: boolean,
|
||||||
bundler?: string,
|
bundler?: string,
|
||||||
webpack: string,
|
webpack: string,
|
||||||
rollup: string,
|
rollup: string,
|
||||||
@@ -71,6 +74,9 @@ class Watcher extends EventEmitter {
|
|||||||
this.port = port;
|
this.port = port;
|
||||||
this.closed = false;
|
this.closed = false;
|
||||||
|
|
||||||
|
this.live = live;
|
||||||
|
this.hot = hot;
|
||||||
|
|
||||||
this.filewatchers = [];
|
this.filewatchers = [];
|
||||||
|
|
||||||
this.current_build = {
|
this.current_build = {
|
||||||
@@ -159,10 +165,7 @@ class Watcher extends EventEmitter {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
this.deferreds = {
|
let deferred = new Deferred();
|
||||||
server: new Deferred(),
|
|
||||||
client: new Deferred()
|
|
||||||
};
|
|
||||||
|
|
||||||
// TODO watch the configs themselves?
|
// TODO watch the configs themselves?
|
||||||
const compilers: Compilers = create_compilers(this.bundler, {
|
const compilers: Compilers = create_compilers(this.bundler, {
|
||||||
@@ -187,11 +190,10 @@ class Watcher extends EventEmitter {
|
|||||||
|
|
||||||
invalid: filename => {
|
invalid: filename => {
|
||||||
this.restart(filename, 'server');
|
this.restart(filename, 'server');
|
||||||
this.deferreds.server = new Deferred();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
handle_result: (result: CompileResult) => {
|
handle_result: (result: CompileResult) => {
|
||||||
this.deferreds.client.promise.then(() => {
|
deferred.promise.then(() => {
|
||||||
const restart = () => {
|
const restart = () => {
|
||||||
log = '';
|
log = '';
|
||||||
this.crashed = false;
|
this.crashed = false;
|
||||||
@@ -203,11 +205,15 @@ class Watcher extends EventEmitter {
|
|||||||
process: this.proc
|
process: this.proc
|
||||||
});
|
});
|
||||||
|
|
||||||
this.deferreds.server.fulfil();
|
if (this.hot && this.bundler === 'webpack') {
|
||||||
|
this.dev_server.send({
|
||||||
this.dev_server.send({
|
status: 'completed'
|
||||||
status: 'completed'
|
});
|
||||||
});
|
} else {
|
||||||
|
this.dev_server.send({
|
||||||
|
action: 'reload'
|
||||||
|
});
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
if (this.crashed) return;
|
if (this.crashed) return;
|
||||||
@@ -263,7 +269,7 @@ class Watcher extends EventEmitter {
|
|||||||
|
|
||||||
invalid: filename => {
|
invalid: filename => {
|
||||||
this.restart(filename, 'client');
|
this.restart(filename, 'client');
|
||||||
this.deferreds.client = new Deferred();
|
deferred = new Deferred();
|
||||||
|
|
||||||
// TODO we should delete old assets. due to a webpack bug
|
// TODO we should delete old assets. due to a webpack bug
|
||||||
// i don't even begin to comprehend, this is apparently
|
// i don't even begin to comprehend, this is apparently
|
||||||
@@ -276,7 +282,6 @@ class Watcher extends EventEmitter {
|
|||||||
shimport: this.bundler === 'rollup' && require('shimport/package.json').version,
|
shimport: this.bundler === 'rollup' && require('shimport/package.json').version,
|
||||||
assets: result.assetsByChunkName
|
assets: result.assetsByChunkName
|
||||||
}, null, ' '));
|
}, null, ' '));
|
||||||
this.deferreds.client.fulfil();
|
|
||||||
|
|
||||||
const client_files = result.assets.map((file: string) => `client/${file}`);
|
const client_files = result.assets.map((file: string) => `client/${file}`);
|
||||||
|
|
||||||
@@ -285,6 +290,8 @@ class Watcher extends EventEmitter {
|
|||||||
client_files
|
client_files
|
||||||
});
|
});
|
||||||
|
|
||||||
|
deferred.fulfil();
|
||||||
|
|
||||||
// we need to wait a beat before watching the service
|
// we need to wait a beat before watching the service
|
||||||
// worker, because of some webpack nonsense
|
// worker, because of some webpack nonsense
|
||||||
setTimeout(watch_serviceworker, 100);
|
setTimeout(watch_serviceworker, 100);
|
||||||
|
|||||||
10
src/cli.ts
10
src/cli.ts
@@ -11,8 +11,16 @@ prog.command('dev')
|
|||||||
.describe('Start a development server')
|
.describe('Start a development server')
|
||||||
.option('-p, --port', 'Specify a port')
|
.option('-p, --port', 'Specify a port')
|
||||||
.option('-o, --open', 'Open a browser window')
|
.option('-o, --open', 'Open a browser window')
|
||||||
|
.option('--hot', 'Use hot module replacement (requires webpack)', true)
|
||||||
|
.option('-l --live', 'Reload on changes if not using --hot', true)
|
||||||
.option('--bundler', 'Specify a bundler (rollup or webpack)')
|
.option('--bundler', 'Specify a bundler (rollup or webpack)')
|
||||||
.action(async (opts: { port: number, open: boolean, bundler?: string }) => {
|
.action(async (opts: {
|
||||||
|
port: number,
|
||||||
|
open: boolean,
|
||||||
|
live: boolean,
|
||||||
|
hot: boolean,
|
||||||
|
bundler?: string
|
||||||
|
}) => {
|
||||||
const { dev } = await import('./cli/dev');
|
const { dev } = await import('./cli/dev');
|
||||||
dev(opts);
|
dev(opts);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ export default function middleware(opts: {
|
|||||||
|
|
||||||
serve({
|
serve({
|
||||||
prefix: '/client/',
|
prefix: '/client/',
|
||||||
cache_control: 'max-age=31536000'
|
cache_control: dev() ? 'no-cache' : 'max-age=31536000'
|
||||||
}),
|
}),
|
||||||
|
|
||||||
get_server_route_handler(manifest.server_routes),
|
get_server_route_handler(manifest.server_routes),
|
||||||
|
|||||||
Reference in New Issue
Block a user