UNPKG

3.01 kBTypeScriptView Raw
1import Browserify = require("browserify");
2
3declare module "browserify" {
4 interface BrowserifyObject extends NodeJS.EventEmitter {
5 /**
6 * When the bundle changes, emit the array of bundle ids that changed.
7 */
8 on(event: "update", listener: (ids: string[]) => any): this;
9 /**
10 * When a bundle is generated, this event fires with the number of bytes
11 */
12 on(event: "bytes", listener: (bytes: number) => any): this;
13 /**
14 * When a bundle is generated, this event fires with the time it took to create the bundle in milliseconds.
15 */
16 on(event: "time", listener: (time: number) => any): this;
17 /**
18 * This event fires after a bundle was created with messages of the form:
19 * ```text
20 * X bytes written (Y seconds)
21 * ```
22 * with the number of bytes in the bundle X and the time in seconds Y.
23 */
24 on(event: "log", listener: (msg: string) => any): this;
25 }
26}
27
28declare var Watchify: Watchify.Constructor;
29
30/**
31 * Watch mode for browserify builds.
32 * Update any source file and your browserify bundle will be recompiled on the spot
33 */
34declare namespace Watchify {
35 /**
36 * Watch mode for browserify builds.
37 * Update any source file and your browserify bundle will be recompiled on the spot
38 */
39 interface Constructor {
40 args: { cache: any; packageCache: any };
41
42 <T extends Browserify.BrowserifyObject>(b: T, opts?: Options): T;
43 (b: Browserify.BrowserifyObject, opts?: Options): Browserify.BrowserifyObject;
44
45 /** Close all the open watch handles. */
46 close(): void;
47 }
48
49 interface Options {
50 /**
51 * The amount of time in milliseconds to wait before emitting an "update" event after a change.
52 * @default 100
53 */
54 delay?: number | undefined;
55
56 /**
57 * Ignores monitoring files for changes. If set to `true`, then ** /node_modules/ ** will be ignored.
58 * For other possible values see Chokidar's documentation on "ignored"
59 * Also see anymatch package: https://github.com/es128/anymatch#usage
60 */
61 ignoreWatch?:
62 | boolean
63 | (
64 | string
65 | RegExp
66 | ((...values: any[]) => boolean)
67 | Array<string | RegExp | ((...values: any[]) => boolean)>
68 )
69 | undefined;
70
71 /**
72 * Enables polling to monitor for changes. If set to `true`, then a polling interval of 100 ms is used.
73 * If set to a number, then that amount of milliseconds will be the polling interval. For more info see
74 * Chokidar's documentation on "usePolling" and "interval".
75 * This option is useful if you're watching an NFS volume
76 * Also see chokidar package: https://github.com/paulmillr/chokidar#path-filtering
77 */
78 poll?: boolean | number | undefined;
79 }
80}
81
82export = Watchify;
83
\No newline at end of file