mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-13 19:45:26 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c0cc877456 | ||
|
|
3ed9ce27a1 | ||
|
|
edba45b809 | ||
|
|
43c1890235 | ||
|
|
605929053c |
@@ -1,5 +1,10 @@
|
||||
# sapper changelog
|
||||
|
||||
## 0.7.3
|
||||
|
||||
* Handle webpack assets that are arrays instead of strings ([#131](https://github.com/sveltejs/sapper/pull/131))
|
||||
* Wait for new server to start before broadcasting HMR update ([#129](https://github.com/sveltejs/sapper/pull/129))
|
||||
|
||||
## 0.7.2
|
||||
|
||||
* Add `hmr-client.js` to package
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sapper",
|
||||
"version": "0.7.2",
|
||||
"version": "0.7.3",
|
||||
"description": "Military-grade apps, engineered by Svelte",
|
||||
"main": "middleware.js",
|
||||
"bin": {
|
||||
|
||||
@@ -137,14 +137,21 @@ export default async function dev(src: string, dir: string) {
|
||||
fs.writeFileSync(path.join(dir, 'server_info.json'), JSON.stringify(server_info, null, ' '));
|
||||
|
||||
deferreds.client.promise.then(() => {
|
||||
if (proc) proc.kill();
|
||||
function restart() {
|
||||
wait_for_port(3000, deferreds.server.fulfil); // TODO control port
|
||||
}
|
||||
|
||||
if (proc) {
|
||||
proc.kill();
|
||||
proc.on('exit', restart);
|
||||
} else {
|
||||
restart();
|
||||
}
|
||||
|
||||
proc = child_process.fork(`${dir}/server.js`, [], {
|
||||
cwd: process.cwd(),
|
||||
env: Object.assign({}, process.env)
|
||||
});
|
||||
|
||||
wait_for_port(3000, deferreds.server.fulfil); // TODO control port
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -122,7 +122,12 @@ function get_route_handler(chunks: Record<string, string>, routes: RouteObject[]
|
||||
|
||||
// preload main.js and current route
|
||||
// TODO detect other stuff we can preload? images, CSS, fonts?
|
||||
res.setHeader('Link', `</client/${chunks.main}>;rel="preload";as="script", </client/${chunks[route.id]}>;rel="preload";as="script"`);
|
||||
const link = []
|
||||
.concat(chunks.main, chunks[route.id])
|
||||
.map(file => `</client/${file}>;rel="preload";as="script"`)
|
||||
.join(', ');
|
||||
|
||||
res.setHeader('Link', link);
|
||||
|
||||
const data = { params: req.params, query: req.query };
|
||||
|
||||
@@ -159,7 +164,11 @@ function get_route_handler(chunks: Record<string, string>, routes: RouteObject[]
|
||||
|
||||
const { html, head, css } = mod.render(data);
|
||||
|
||||
let scripts = `<script src='/client/${chunks.main}'></script>`;
|
||||
let scripts = []
|
||||
.concat(chunks.main) // chunks main might be an array. it might not! thanks, webpack
|
||||
.map(file => `<script src='/client/${file}'></script>`)
|
||||
.join('');
|
||||
|
||||
scripts = `<script>__SAPPER__ = { preloaded: ${serialized} };</script>${scripts}`;
|
||||
|
||||
const page = template.render({
|
||||
|
||||
Reference in New Issue
Block a user