Compare commits

..

11 Commits

Author SHA1 Message Date
Rich Harris
631afbbfe4 -> v0.7.4 2018-02-27 20:10:48 -05:00
Rich Harris
1cc9acb4f1 Merge pull request #142 from sveltejs/gh-141
force NODE_ENV=production in build/export
2018-02-27 20:09:05 -05:00
Rich Harris
19005110f1 huh, not sure why that changed 2018-02-27 19:58:49 -05:00
Rich Harris
21ee8ad39d force NODE_ENV=production in build/export 2018-02-27 19:49:58 -05:00
Rich Harris
906b0c7ad5 Merge pull request #134 from sveltejs/source-map-support
install source-map-support
2018-02-27 19:46:17 -05:00
Rich Harris
896fd410d1 install source-map-support 2018-02-20 14:01:25 -05:00
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
6 changed files with 41 additions and 8 deletions

View File

@@ -1,5 +1,15 @@
# sapper changelog
## 0.7.4
* Force `NODE_ENV='production'` when running `build` or `export` ([#141](https://github.com/sveltejs/sapper/issues/141))
* Use source-map-support ([#134](https://github.com/sveltejs/sapper/pull/134))
## 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.4",
"description": "Military-grade apps, engineered by Svelte",
"main": "middleware.js",
"bin": {
@@ -37,6 +37,7 @@
"rimraf": "^2.6.2",
"sander": "^0.6.0",
"serialize-javascript": "^1.4.0",
"source-map-support": "^0.5.3",
"tslib": "^1.8.1",
"url-parse": "^1.2.0",
"wait-port": "^0.2.2",
@@ -60,7 +61,6 @@
"rollup-plugin-json": "^2.3.0",
"rollup-plugin-string": "^2.0.2",
"rollup-plugin-typescript": "^0.8.1",
"source-map-support": "^0.5.2",
"style-loader": "^0.19.1",
"svelte": "^1.49.1",
"svelte-loader": "^2.3.2",

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

@@ -30,6 +30,8 @@ const [cmd] = opts._;
const start = Date.now();
if (cmd === 'build') {
process.env.NODE_ENV = 'production';
build({ dest, dev: false, entry, src })
.then(() => {
const elapsed = Date.now() - start;
@@ -39,6 +41,8 @@ if (cmd === 'build') {
console.error(err ? err.details || err.stack || err.message || err : 'Unknown error');
});
} else if (cmd === 'export') {
process.env.NODE_ENV = 'production';
build({ dest, dev: false, entry, src })
.then(() => exporter(dest))
.then(() => {

View File

@@ -9,6 +9,9 @@ import escape_html from 'escape-html';
import { create_routes, templates, create_compilers, create_template } from 'sapper/core.js';
import { dest, entry, isDev, src } from '../config';
import { Route, Template } from '../interfaces';
import sourceMapSupport from 'source-map-support';
sourceMapSupport.install();
const dev = isDev();
@@ -122,7 +125,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 +167,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({

View File

@@ -389,7 +389,7 @@ function run(env) {
);
assert.ok(
/<\/client\/[^/]+\/main\.js>;rel="preload";as="script", <\/client\/[^/]+\/_\.0\.js>;rel="preload";as="script"/.test(headers['link']),
/<\/client\/[^/]+\/main\.js>;rel="preload";as="script", <\/client\/[^/]+\/_\.\d+\.js>;rel="preload";as="script"/.test(headers['link']),
headers['link']
);
});