1 | import * as express from "express-serve-static-core";
|
2 | import * as http from "http";
|
3 | import * as https from "https";
|
4 |
|
5 | declare namespace ParcelBundler {
|
6 | interface HttpsOptions {
|
7 | /**
|
8 | * Path to custom certificate
|
9 | *
|
10 | * @default "./ssl/c.crt"
|
11 | */
|
12 | cert?: string | undefined;
|
13 | /**
|
14 | * Path to custom key
|
15 | *
|
16 | * @default "./ssl/k.key"
|
17 | */
|
18 | key?: string | undefined;
|
19 | }
|
20 |
|
21 | interface ParcelOptions {
|
22 | /**
|
23 | * The out directory to put the build files in
|
24 | *
|
25 | * @default "./dist"
|
26 | */
|
27 | outDir?: string | undefined;
|
28 | /**
|
29 | * The name of the outputFile
|
30 | *
|
31 | * @default "index.html"
|
32 | */
|
33 | outFile?: string | undefined;
|
34 | /**
|
35 | * The url to server on
|
36 | *
|
37 | * @default "./"
|
38 | */
|
39 | publicUrl?: string | undefined;
|
40 | /**
|
41 | * Whether to watch the files and rebuild them on change
|
42 | *
|
43 | * @default process.env.NODE_ENV !== 'production'
|
44 | */
|
45 | watch?: boolean | undefined;
|
46 | /**
|
47 | * Enabled or disables caching
|
48 | *
|
49 | * @default true
|
50 | */
|
51 | cache?: boolean | undefined;
|
52 | /**
|
53 | * The directory cache gets put in
|
54 | *
|
55 | * @default ".cache"
|
56 | */
|
57 | cacheDir?: string | undefined;
|
58 | /**
|
59 | * Disable content hash from being included on the filename
|
60 | *
|
61 | * @default false
|
62 | */
|
63 | contentHash?: boolean | undefined;
|
64 | /**
|
65 | * Minify files
|
66 | *
|
67 | * @default process.env.NODE_ENV === 'production'
|
68 | */
|
69 | minify?: boolean | undefined;
|
70 | /**
|
71 | * Turn on experimental scope hoisting/tree shaking flag, for smaller production bundles
|
72 | *
|
73 | * @default false
|
74 | */
|
75 | scopeHoist?: boolean | undefined;
|
76 | /**
|
77 | * @default "browser"
|
78 | */
|
79 | target?: "browser" | "node" | "electron" | undefined;
|
80 | /**
|
81 | * Define a custom {key, cert} pair
|
82 | *
|
83 | * Use true to generate one or false to use http
|
84 | */
|
85 | https?:
|
86 | | true
|
87 | | false
|
88 | | HttpsOptions
|
89 | | undefined;
|
90 | /**
|
91 | * 3 = log everything, 2 = log warnings & errors, 1 = log errors
|
92 | *
|
93 | * @default 3
|
94 | */
|
95 | logLevel?: 3 | 2 | 1 | undefined;
|
96 | /**
|
97 | * The port the HMR socket runs on
|
98 | *
|
99 | * Defaults to a random free port (0 in node.js resolves to a random free port)
|
100 | *
|
101 | * @default 0
|
102 | */
|
103 | hmrPort?: 0 | number | undefined;
|
104 | /**
|
105 | * Enable or disable sourcemaps
|
106 | *
|
107 | * Defaults to enabled (not supported in minified builds yet)
|
108 | *
|
109 | * @default true
|
110 | */
|
111 | sourceMaps?: boolean | undefined;
|
112 | /**
|
113 | * A hostname for hot module reload
|
114 | *
|
115 | * @default ""
|
116 | */
|
117 | hmrHostname?: string | undefined;
|
118 | /**
|
119 | * Prints a detailed report of the bundles, assets, filesizes and times
|
120 | *
|
121 | * Reports are only printed if watch is disabled
|
122 | *
|
123 | * @default false
|
124 | */
|
125 | detailedReport?: boolean | undefined;
|
126 |
|
127 | /**
|
128 | * Expose modules as UMD under this name, disabled by default
|
129 | */
|
130 | global?: string | undefined;
|
131 |
|
132 | /**
|
133 | * By default, package.json dependencies are not included when using 'node' or 'electron' with the 'target' option.
|
134 | *
|
135 | * Set to true to add them to the bundle.
|
136 | *
|
137 | * @default false
|
138 | */
|
139 | bundleNodeModules?: true | false | undefined;
|
140 |
|
141 | /**
|
142 | * Enable or disable HMR while watching
|
143 | *
|
144 | * @default false
|
145 | */
|
146 | hmr?: true | false | undefined;
|
147 |
|
148 | /**
|
149 | * Enable or disable auto install of missing dependencies found during bundling
|
150 | *
|
151 | * @default true
|
152 | */
|
153 | autoInstall?: boolean | undefined;
|
154 | }
|
155 |
|
156 | type ParcelAsset = any;
|
157 |
|
158 | interface ParcelBundle {
|
159 | /**
|
160 | * The type of assets it contains (e.g. js, css, map, ...)
|
161 | */
|
162 | type: string;
|
163 | /**
|
164 | * The name of the bundle (generated using Asset.generateBundleName() of entryAsset)
|
165 | */
|
166 | name: string;
|
167 | /**
|
168 | * The parent bundle, is null in case of the entry bundleany
|
169 | */
|
170 | parentBundle?: any;
|
171 | /**
|
172 | * The entryPoint of the bundle, used for generating the name and gathering assets.
|
173 | */
|
174 | entryAsset: any;
|
175 | /**
|
176 | * A Set of all assets inside the bundle
|
177 | */
|
178 | assets: Set<any>;
|
179 | /**
|
180 | * A Set of all sibling bundles
|
181 | */
|
182 | siblingBundles: Set<any>;
|
183 | /**
|
184 | * A Map<String(Type: js, css, map, ...), Bundle> of all sibling bundles
|
185 | */
|
186 | siblingBundlesMap: Map<string, ParcelBundle>;
|
187 | /**
|
188 | * A Map<Asset, number(line number inside the bundle)> of all the locations of the assets inside the bundle, used to generate accurate source maps
|
189 | */
|
190 | offsets: Map<ParcelAsset, number>;
|
191 |
|
192 | /**
|
193 | * A Set of all child bundles
|
194 | */
|
195 | childBundles: Set<any>;
|
196 | }
|
197 | }
|
198 |
|
199 | declare class ParcelBundler {
|
200 | constructor(
|
201 | entryFiles?: string | string[],
|
202 | options?: ParcelBundler.ParcelOptions,
|
203 | );
|
204 |
|
205 | addAssetType(extension: string, path: string): void;
|
206 |
|
207 | addPackager(type: string, packager: string): void;
|
208 |
|
209 | bundle(): Promise<ParcelBundler.ParcelBundle>;
|
210 |
|
211 | middleware(): (req: express.Request, res: express.Response, next: express.NextFunction) => any;
|
212 |
|
213 | serve(
|
214 | port?: number,
|
215 | https?: true | false | ParcelBundler.HttpsOptions,
|
216 | host?: string,
|
217 | ): Promise<http.Server | https.Server>;
|
218 |
|
219 | on(name: "buildEnd", cb: () => void): void;
|
220 | on(name: "bundled", cb: (bundle: ParcelBundler.ParcelBundle) => void): void;
|
221 | on(name: "buildStart", cb: (entryPoints: string[]) => void): void;
|
222 | on(name: "buildError", cb: (error: Error) => void): void;
|
223 |
|
224 | off(name: "buildEnd" | "bundled" | "buildStart" | "buildError", cb: (...any: any[]) => void): void;
|
225 | }
|
226 |
|
227 | export = ParcelBundler;
|