mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-16 04:44:35 +00:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
62b8a79e9f | ||
|
|
7f255563a4 | ||
|
|
32f4a50f25 | ||
|
|
b1a9be2dc3 | ||
|
|
c5456d3033 | ||
|
|
9b33dad589 | ||
|
|
4315a46ff2 | ||
|
|
0fb5827968 | ||
|
|
f9bf23dc43 |
12
CHANGELOG.md
12
CHANGELOG.md
@@ -1,5 +1,17 @@
|
|||||||
# sapper changelog
|
# sapper changelog
|
||||||
|
|
||||||
|
## 0.17.1
|
||||||
|
|
||||||
|
* Print which file is causing build errors/warnings ([#371](https://github.com/sveltejs/sapper/pull/371))
|
||||||
|
|
||||||
|
## 0.17.0
|
||||||
|
|
||||||
|
* Use `cheap-watch` instead of `chokidar` ([#364](https://github.com/sveltejs/sapper/issues/364))
|
||||||
|
|
||||||
|
## 0.16.1
|
||||||
|
|
||||||
|
* Fix file watching regression in previous version
|
||||||
|
|
||||||
## 0.16.0
|
## 0.16.0
|
||||||
|
|
||||||
* Slim down installed package ([#363](https://github.com/sveltejs/sapper/pull/363))
|
* Slim down installed package ([#363](https://github.com/sveltejs/sapper/pull/363))
|
||||||
|
|||||||
333
package-lock.json
generated
333
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sapper",
|
"name": "sapper",
|
||||||
"version": "0.16.0",
|
"version": "0.17.1",
|
||||||
"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": {
|
||||||
@@ -19,7 +19,6 @@
|
|||||||
"test": "test"
|
"test": "test"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chokidar": "^2.0.4",
|
|
||||||
"html-minifier": "^3.5.16",
|
"html-minifier": "^3.5.16",
|
||||||
"source-map-support": "^0.5.6",
|
"source-map-support": "^0.5.6",
|
||||||
"tslib": "^1.9.1"
|
"tslib": "^1.9.1"
|
||||||
@@ -30,6 +29,7 @@
|
|||||||
"@types/mocha": "^5.2.5",
|
"@types/mocha": "^5.2.5",
|
||||||
"@types/node": "^10.7.1",
|
"@types/node": "^10.7.1",
|
||||||
"@types/rimraf": "^2.0.2",
|
"@types/rimraf": "^2.0.2",
|
||||||
|
"cheap-watch": "^0.3.0",
|
||||||
"compression": "^1.7.1",
|
"compression": "^1.7.1",
|
||||||
"cookie": "^0.3.1",
|
"cookie": "^0.3.1",
|
||||||
"devalue": "^1.0.4",
|
"devalue": "^1.0.4",
|
||||||
|
|||||||
@@ -119,21 +119,30 @@ class Watcher extends EventEmitter {
|
|||||||
this.dev_server = new DevServer(dev_port);
|
this.dev_server = new DevServer(dev_port);
|
||||||
|
|
||||||
this.filewatchers.push(
|
this.filewatchers.push(
|
||||||
watch_files(locations.routes(), ['add', 'unlink'], () => {
|
watch_dir(
|
||||||
const routes = create_routes();
|
locations.routes(),
|
||||||
create_main_manifests({ routes, dev_port });
|
({ path: file, stats }) => {
|
||||||
|
if (stats.isDirectory()) {
|
||||||
try {
|
return path.basename(file)[0] !== '_';
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
() => {
|
||||||
const routes = create_routes();
|
const routes = create_routes();
|
||||||
create_main_manifests({ routes, dev_port });
|
create_main_manifests({ routes, dev_port });
|
||||||
} catch (err) {
|
|
||||||
this.emit('error', <events.ErrorEvent>{
|
|
||||||
message: err.message
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
|
|
||||||
watch_files(`${locations.app()}/template.html`, ['change'], () => {
|
try {
|
||||||
|
const routes = create_routes();
|
||||||
|
create_main_manifests({ routes, dev_port });
|
||||||
|
} catch (err) {
|
||||||
|
this.emit('error', <events.ErrorEvent>{
|
||||||
|
message: err.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
),
|
||||||
|
|
||||||
|
fs.watch(`${locations.app()}/template.html`, () => {
|
||||||
this.dev_server.send({
|
this.dev_server.send({
|
||||||
action: 'reload'
|
action: 'reload'
|
||||||
});
|
});
|
||||||
@@ -453,24 +462,32 @@ class DevServer {
|
|||||||
|
|
||||||
function noop() {}
|
function noop() {}
|
||||||
|
|
||||||
function watch_files(pattern: string, events: string[], callback: () => void) {
|
function watch_dir(
|
||||||
let watcher;
|
dir: string,
|
||||||
|
filter: ({ path, stats }: { path: string, stats: fs.Stats }) => boolean,
|
||||||
|
callback: () => void
|
||||||
|
) {
|
||||||
|
let watch;
|
||||||
|
let closed = false;
|
||||||
|
|
||||||
import('chokidar').then(({ default: chokidar }) => {
|
import('cheap-watch').then(CheapWatch => {
|
||||||
if (closed) return;
|
if (closed) return;
|
||||||
|
|
||||||
watcher = chokidar.watch(pattern, {
|
watch = new CheapWatch({ dir, filter, debounce: 50 });
|
||||||
persistent: true,
|
|
||||||
ignoreInitial: true,
|
watch.on('+', ({ isNew }) => {
|
||||||
disableGlobbing: true
|
if (isNew) callback();
|
||||||
});
|
});
|
||||||
|
|
||||||
events.forEach(event => {
|
watch.on('-', callback);
|
||||||
watcher.on(event, callback);
|
|
||||||
});
|
watch.init();
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
close: () => watcher && watcher.close()
|
close: () => {
|
||||||
|
if (watch) watch.close();
|
||||||
|
closed = true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -26,8 +26,8 @@ export type InvalidEvent = {
|
|||||||
|
|
||||||
export type BuildEvent = {
|
export type BuildEvent = {
|
||||||
type: string;
|
type: string;
|
||||||
errors: Array<{ message: string, duplicate: boolean }>;
|
errors: Array<{ file: string, message: string, duplicate: boolean }>;
|
||||||
warnings: Array<{ message: string, duplicate: boolean }>;
|
warnings: Array<{ file: string, message: string, duplicate: boolean }>;
|
||||||
duration: number;
|
duration: number;
|
||||||
webpack_stats: any;
|
webpack_stats: any;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export function dev(opts: { port: number, open: boolean }) {
|
|||||||
|
|
||||||
watcher.on('ready', (event: events.ReadyEvent) => {
|
watcher.on('ready', (event: events.ReadyEvent) => {
|
||||||
if (first) {
|
if (first) {
|
||||||
console.log(`${colors.bold.cyan(`> Listening on http://localhost:${event.port}`)}`);
|
console.log(colors.bold.cyan(`> Listening on http://localhost:${event.port}`));
|
||||||
if (opts.open) child_process.exec(`open http://localhost:${event.port}`);
|
if (opts.open) child_process.exec(`open http://localhost:${event.port}`);
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
@@ -35,20 +35,21 @@ 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.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.message}`)}`);
|
console.log(colors.bold.red(`> ${event.message}`));
|
||||||
if (event.log) console.log(event.log);
|
if (event.log) console.log(event.log);
|
||||||
});
|
});
|
||||||
|
|
||||||
watcher.on('build', (event: events.BuildEvent) => {
|
watcher.on('build', (event: events.BuildEvent) => {
|
||||||
if (event.errors.length) {
|
if (event.errors.length) {
|
||||||
console.log(`${colors.bold.red(`✗ ${event.type}`)}`);
|
console.log(colors.bold.red(`✗ ${event.type}`));
|
||||||
|
|
||||||
event.errors.filter(e => !e.duplicate).forEach(error => {
|
event.errors.filter(e => !e.duplicate).forEach(error => {
|
||||||
|
if (error.file) console.log(colors.bold(error.file));
|
||||||
console.log(error.message);
|
console.log(error.message);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -57,9 +58,10 @@ export function dev(opts: { port: number, open: boolean }) {
|
|||||||
console.log(`${hidden} duplicate ${hidden === 1 ? 'error' : 'errors'} hidden\n`);
|
console.log(`${hidden} duplicate ${hidden === 1 ? 'error' : 'errors'} hidden\n`);
|
||||||
}
|
}
|
||||||
} else if (event.warnings.length) {
|
} else if (event.warnings.length) {
|
||||||
console.log(`${colors.bold.yellow(`• ${event.type}`)}`);
|
console.log(colors.bold.yellow(`• ${event.type}`));
|
||||||
|
|
||||||
event.warnings.filter(e => !e.duplicate).forEach(warning => {
|
event.warnings.filter(e => !e.duplicate).forEach(warning => {
|
||||||
|
if (warning.file) console.log(colors.bold(warning.file));
|
||||||
console.log(warning.message);
|
console.log(warning.message);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -72,7 +74,7 @@ export function dev(opts: { port: number, open: boolean }) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(`${colors.bold.red(`> ${err.message}`)}`);
|
console.log(colors.bold.red(`> ${err.message}`));
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user