From e0d533f2ea608a5b5f64e428e852be6324d2562f Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 19 Aug 2018 16:15:04 -0400 Subject: [PATCH] bundle more stuff --- package-lock.json | 5 ----- package.json | 32 ++++++++++++++++---------------- src/api/dev.ts | 22 +++++++++++++--------- src/cli.ts | 2 +- src/cli/build.ts | 2 +- src/cli/dev.ts | 2 +- src/cli/export.ts | 2 +- src/cli/start.ts | 2 +- src/cli/upgrade.ts | 2 +- 9 files changed, 35 insertions(+), 36 deletions(-) diff --git a/package-lock.json b/package-lock.json index 084f1d3..9950a3c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -389,11 +389,6 @@ "integrity": "sha1-YXmX/F9gV2iUxDX5QNgZ4TW4B2I=", "dev": true }, - "ansi-colors": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-2.0.5.tgz", - "integrity": "sha512-yAdfUZ+c2wetVNIFsNRn44THW+Lty6S5TwMpUfLA/UaGhiXbBv/F8E60/1hMLd0cnF/CDoWH8vzVaI5bAcHCjw==" - }, "ansi-escapes": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.1.0.tgz", diff --git a/package.json b/package.json index 002680e..2934ee0 100644 --- a/package.json +++ b/package.json @@ -19,23 +19,10 @@ "test": "test" }, "dependencies": { - "ansi-colors": "^2.0.1", - "chokidar": "^2.0.3", - "cookie": "^0.3.1", - "devalue": "^1.0.4", + "chokidar": "^2.0.4", "html-minifier": "^3.5.16", - "mkdirp": "^0.5.1", - "node-fetch": "^2.1.1", - "pretty-bytes": "^5.0.0", - "pretty-ms": "^3.1.0", - "require-relative": "^0.8.7", - "rimraf": "^2.6.2", - "sade": "^1.4.1", - "sander": "^0.6.0", "source-map-support": "^0.5.6", - "tslib": "^1.9.1", - "url-parse": "^1.2.0", - "webpack-format-messages": "^2.0.1" + "tslib": "^1.9.1" }, "devDependencies": { "@types/glob": "^5.0.34", @@ -44,28 +31,41 @@ "@types/node": "^10.7.1", "@types/rimraf": "^2.0.2", "compression": "^1.7.1", + "cookie": "^0.3.1", + "devalue": "^1.0.4", "eslint": "^4.13.1", "eslint-plugin-import": "^2.12.0", "express": "^4.16.3", + "kleur": "^2.0.1", + "mkdirp": "^0.5.1", "mocha": "^5.2.0", "nightmare": "^3.0.0", + "node-fetch": "^2.1.1", "npm-run-all": "^4.1.3", "polka": "^0.4.0", "port-authority": "^1.0.5", + "pretty-bytes": "^5.0.0", + "pretty-ms": "^3.1.0", + "require-relative": "^0.8.7", + "rimraf": "^2.6.2", "rollup": "^0.59.2", "rollup-plugin-commonjs": "^9.1.3", "rollup-plugin-json": "^3.0.0", "rollup-plugin-node-resolve": "^3.3.0", "rollup-plugin-string": "^2.0.2", "rollup-plugin-typescript": "^0.8.1", + "sade": "^1.4.1", + "sander": "^0.6.0", "serve-static": "^1.13.2", "svelte": "^2.6.3", "svelte-loader": "^2.9.0", "tiny-glob": "^0.2.2", "ts-node": "^7.0.1", "typescript": "^2.8.3", + "url-parse": "^1.2.0", "walk-sync": "^0.3.2", - "webpack": "^4.8.3" + "webpack": "^4.8.3", + "webpack-format-messages": "^2.0.1" }, "scripts": { "cy:open": "cypress open", diff --git a/src/api/dev.ts b/src/api/dev.ts index 36a53da..9b6797d 100644 --- a/src/api/dev.ts +++ b/src/api/dev.ts @@ -454,19 +454,23 @@ class DevServer { function noop() {} function watch_files(pattern: string, events: string[], callback: () => void) { - const chokidar = require('chokidar'); + let watcher; - const watcher = chokidar.watch(pattern, { - persistent: true, - ignoreInitial: true, - disableGlobbing: true - }); + import('chokidar').then(({ default: chokidar }) => { + if (closed) return; - events.forEach(event => { - watcher.on(event, callback); + watcher = chokidar.watch(pattern, { + persistent: true, + ignoreInitial: true, + disableGlobbing: true + }); + + events.forEach(event => { + watcher.on(event, callback); + }); }); return { - close: () => watcher.close() + close: () => watcher && watcher.close() }; } diff --git a/src/cli.ts b/src/cli.ts index 6dad7d7..303f5d1 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -1,7 +1,7 @@ import * as fs from 'fs'; import * as path from 'path'; import sade from 'sade'; -import * as colors from 'ansi-colors'; +import colors from 'kleur'; import prettyMs from 'pretty-ms'; import * as pkg from '../package.json'; diff --git a/src/cli/build.ts b/src/cli/build.ts index 3d050b8..b7bf87b 100644 --- a/src/cli/build.ts +++ b/src/cli/build.ts @@ -1,5 +1,5 @@ import { build as _build } from '../api/build'; -import * as colors from 'ansi-colors'; +import colors from 'kleur'; import { locations } from '../config'; export function build() { diff --git a/src/cli/dev.ts b/src/cli/dev.ts index cfc3414..17eab11 100644 --- a/src/cli/dev.ts +++ b/src/cli/dev.ts @@ -1,5 +1,5 @@ import * as path from 'path'; -import * as colors from 'ansi-colors'; +import colors from 'kleur'; import * as child_process from 'child_process'; import prettyMs from 'pretty-ms'; import { dev as _dev } from '../api/dev'; diff --git a/src/cli/export.ts b/src/cli/export.ts index bcaa689..0a7737a 100644 --- a/src/cli/export.ts +++ b/src/cli/export.ts @@ -1,5 +1,5 @@ import { exporter as _exporter } from '../api/export'; -import * as colors from 'ansi-colors'; +import colors from 'kleur'; import prettyBytes from 'pretty-bytes'; import { locations } from '../config'; diff --git a/src/cli/start.ts b/src/cli/start.ts index 97e3446..ba658ae 100644 --- a/src/cli/start.ts +++ b/src/cli/start.ts @@ -1,7 +1,7 @@ import * as fs from 'fs'; import * as path from 'path'; import * as child_process from 'child_process'; -import * as colors from 'ansi-colors'; +import colors from 'kleur'; import * as ports from 'port-authority'; export async function start(dir: string, opts: { port: number, open: boolean }) { diff --git a/src/cli/upgrade.ts b/src/cli/upgrade.ts index afa694c..7d8b16b 100644 --- a/src/cli/upgrade.ts +++ b/src/cli/upgrade.ts @@ -1,5 +1,5 @@ import * as fs from 'fs'; -import * as colors from 'ansi-colors'; +import colors from 'kleur'; export default async function upgrade() { const upgraded = [