Compare commits

..

5 Commits

Author SHA1 Message Date
Rich Harris
c0cc877456 -> v0.7.3 2018-02-20 12:23:32 -05:00
Rich Harris
3ed9ce27a1 Merge pull request #131 from sveltejs/webpack-insanity
handle case where webpack asset is an array instead of a string
2018-02-20 12:18:29 -05:00
Rich Harris
edba45b809 Merge pull request #129 from sveltejs/robustify-hmr
ensure old server is killed before listening for port on new server
2018-02-20 12:18:10 -05:00
Rich Harris
43c1890235 handle case where webpack asset is an array instead of a string 2018-02-20 11:11:55 -05:00
Rich Harris
605929053c ensure old server is killed before listening for port on new server 2018-02-20 11:11:02 -05:00
4 changed files with 27 additions and 6 deletions

View File

@@ -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

View File

@@ -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": {

View File

@@ -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
});
}
});

View File

@@ -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({