@atlaspack/reporter-dev-server 2.14.31 → 2.14.32-dev-ts-project-refs-d30e9754f.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/Server.js ADDED
@@ -0,0 +1,408 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SOURCES_ENDPOINT = void 0;
7
+ exports.setHeaders = setHeaders;
8
+ const assert_1 = __importDefault(require("assert"));
9
+ const path_1 = __importDefault(require("path"));
10
+ const url_1 = __importDefault(require("url"));
11
+ const utils_1 = require("@atlaspack/utils");
12
+ const serverErrors_1 = __importDefault(require("./serverErrors"));
13
+ const fs_1 = __importDefault(require("fs"));
14
+ const ejs_1 = __importDefault(require("ejs"));
15
+ const connect_1 = __importDefault(require("connect"));
16
+ const serve_handler_1 = __importDefault(require("serve-handler"));
17
+ const http_proxy_middleware_1 = require("http-proxy-middleware");
18
+ const url_2 = require("url");
19
+ const launch_editor_1 = __importDefault(require("launch-editor"));
20
+ const fresh_1 = __importDefault(require("fresh"));
21
+ function setHeaders(res) {
22
+ res.setHeader('Access-Control-Allow-Origin', '*');
23
+ res.setHeader('Access-Control-Allow-Methods', 'GET, HEAD, PUT, PATCH, POST, DELETE');
24
+ res.setHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, Content-Type');
25
+ res.setHeader('Cache-Control', 'max-age=0, must-revalidate');
26
+ }
27
+ const SLASH_REGEX = /\//g;
28
+ exports.SOURCES_ENDPOINT = '/__parcel_source_root';
29
+ const EDITOR_ENDPOINT = '/__parcel_launch_editor';
30
+ const TEMPLATE_404 = fs_1.default.readFileSync(path_1.default.join(__dirname, '..', 'templates/404.html'), 'utf8');
31
+ const TEMPLATE_500 = fs_1.default.readFileSync(path_1.default.join(__dirname, '..', 'templates/500.html'), 'utf8');
32
+ class Server {
33
+ constructor(options) {
34
+ this.options = options;
35
+ try {
36
+ this.rootPath = new url_2.URL(options.publicUrl).pathname;
37
+ }
38
+ catch (e) {
39
+ this.rootPath = options.publicUrl;
40
+ }
41
+ this.pending = true;
42
+ this.pendingRequests = [];
43
+ this.middleware = [];
44
+ this.bundleGraph = null;
45
+ this.requestBundle = null;
46
+ this.errors = null;
47
+ }
48
+ buildStart() {
49
+ this.pending = true;
50
+ }
51
+ buildSuccess(bundleGraph, requestBundle) {
52
+ this.bundleGraph = bundleGraph;
53
+ this.requestBundle = requestBundle;
54
+ this.errors = null;
55
+ this.pending = false;
56
+ if (this.pendingRequests.length > 0) {
57
+ let pendingRequests = this.pendingRequests;
58
+ this.pendingRequests = [];
59
+ for (let [req, res] of pendingRequests) {
60
+ this.respond(req, res);
61
+ }
62
+ }
63
+ }
64
+ async buildError(options, diagnostics) {
65
+ this.pending = false;
66
+ this.errors = await Promise.all(diagnostics.map(async (d) => {
67
+ let ansiDiagnostic = await (0, utils_1.prettyDiagnostic)(d, options);
68
+ return {
69
+ message: (0, utils_1.ansiHtml)(ansiDiagnostic.message),
70
+ stack: ansiDiagnostic.stack ? (0, utils_1.ansiHtml)(ansiDiagnostic.stack) : null,
71
+ frames: ansiDiagnostic.frames.map((f) => ({
72
+ location: f.location,
73
+ code: (0, utils_1.ansiHtml)(f.code),
74
+ })),
75
+ hints: ansiDiagnostic.hints.map((hint) => (0, utils_1.ansiHtml)(hint)),
76
+ documentation: d.documentationURL ?? '',
77
+ };
78
+ }));
79
+ }
80
+ respond(req, res) {
81
+ if (this.middleware.some((handler) => handler(req, res)))
82
+ return;
83
+ let { pathname, search } = url_1.default.parse(req.originalUrl || req.url);
84
+ if (pathname == null) {
85
+ pathname = '/';
86
+ }
87
+ if (pathname.startsWith(EDITOR_ENDPOINT) && search) {
88
+ let query = new url_2.URLSearchParams(search);
89
+ let file = query.get('file');
90
+ if (file) {
91
+ // File location might start with /__parcel_source_root if it came from a source map.
92
+ if (file.startsWith(exports.SOURCES_ENDPOINT)) {
93
+ file = file.slice(exports.SOURCES_ENDPOINT.length + 1);
94
+ }
95
+ (0, launch_editor_1.default)(file);
96
+ }
97
+ res.end();
98
+ }
99
+ else if (this.errors) {
100
+ return this.send500(req, res);
101
+ }
102
+ else if (path_1.default.extname(pathname) === '') {
103
+ // If the URL doesn't start with the public path, or the URL doesn't
104
+ // have a file extension, send the main HTML bundle.
105
+ return this.sendIndex(req, res);
106
+ }
107
+ else if (pathname.startsWith(exports.SOURCES_ENDPOINT)) {
108
+ req.url = pathname.slice(exports.SOURCES_ENDPOINT.length);
109
+ return this.serve(this.options.inputFS, this.options.projectRoot, req, res, () => this.send404(req, res));
110
+ }
111
+ else if (pathname.startsWith(this.rootPath)) {
112
+ // Otherwise, serve the file from the dist folder
113
+ req.url =
114
+ this.rootPath === '/' ? pathname : pathname.slice(this.rootPath.length);
115
+ if (req.url[0] !== '/') {
116
+ req.url = '/' + req.url;
117
+ }
118
+ return this.serveBundle(req, res, () => this.sendIndex(req, res));
119
+ }
120
+ else {
121
+ return this.send404(req, res);
122
+ }
123
+ }
124
+ sendIndex(req, res) {
125
+ if (this.bundleGraph) {
126
+ // If the main asset is an HTML file, serve it
127
+ let htmlBundleFilePaths = this.bundleGraph
128
+ .getBundles()
129
+ .filter((bundle) => path_1.default.posix.extname(bundle.name) === '.html')
130
+ .map((bundle) => {
131
+ return `/${(0, utils_1.relativePath)(this.options.distDir, bundle.filePath, false)}`;
132
+ });
133
+ let indexFilePath = null;
134
+ let { pathname: reqURL } = url_1.default.parse(req.originalUrl || req.url);
135
+ if (!reqURL) {
136
+ reqURL = '/';
137
+ }
138
+ if (htmlBundleFilePaths.length === 1) {
139
+ indexFilePath = htmlBundleFilePaths[0];
140
+ }
141
+ else {
142
+ let bestMatch = null;
143
+ for (let bundle of htmlBundleFilePaths) {
144
+ let bundleDir = path_1.default.posix.dirname(bundle);
145
+ let bundleDirSubdir = bundleDir === '/' ? bundleDir : bundleDir + '/';
146
+ let withoutExtension = path_1.default.posix.basename(bundle, path_1.default.posix.extname(bundle));
147
+ let isIndex = withoutExtension === 'index';
148
+ let matchesIsIndex = null;
149
+ if (isIndex &&
150
+ (reqURL.startsWith(bundleDirSubdir) || reqURL === bundleDir)) {
151
+ // bundle is /bar/index.html and (/bar or something inside of /bar/** was requested was requested)
152
+ matchesIsIndex = true;
153
+ }
154
+ else if (reqURL == path_1.default.posix.join(bundleDir, withoutExtension)) {
155
+ // bundle is /bar/foo.html and /bar/foo was requested
156
+ matchesIsIndex = false;
157
+ }
158
+ if (matchesIsIndex != null) {
159
+ let depth = bundle.match(SLASH_REGEX)?.length ?? 0;
160
+ if (bestMatch == null ||
161
+ // This one is more specific (deeper)
162
+ bestMatch.depth < depth ||
163
+ // This one is just as deep, but the bundle name matches and not just index.html
164
+ (bestMatch.depth === depth && bestMatch.isIndex)) {
165
+ bestMatch = { bundle, depth, isIndex: matchesIsIndex };
166
+ }
167
+ }
168
+ }
169
+ indexFilePath = bestMatch?.['bundle'] ?? htmlBundleFilePaths[0];
170
+ }
171
+ if (indexFilePath) {
172
+ req.url = indexFilePath;
173
+ this.serveBundle(req, res, () => this.send404(req, res));
174
+ }
175
+ else {
176
+ this.send404(req, res);
177
+ }
178
+ }
179
+ else {
180
+ this.send404(req, res);
181
+ }
182
+ }
183
+ async serveBundle(req, res, next) {
184
+ let bundleGraph = this.bundleGraph;
185
+ if (bundleGraph) {
186
+ let { pathname } = url_1.default.parse(req.url);
187
+ if (!pathname) {
188
+ this.send500(req, res);
189
+ return;
190
+ }
191
+ let requestedPath = path_1.default.normalize(pathname.slice(1));
192
+ let bundle = bundleGraph
193
+ .getBundles()
194
+ .find((b) => path_1.default.relative(this.options.distDir, b.filePath) === requestedPath);
195
+ if (!bundle) {
196
+ this.serveDist(req, res, next);
197
+ return;
198
+ }
199
+ (0, assert_1.default)(this.requestBundle != null);
200
+ try {
201
+ await this.requestBundle(bundle);
202
+ }
203
+ catch (err) {
204
+ this.send500(req, res);
205
+ return;
206
+ }
207
+ this.serveDist(req, res, next);
208
+ }
209
+ else {
210
+ this.send404(req, res);
211
+ }
212
+ }
213
+ serveDist(req, res, next) {
214
+ return this.serve(this.options.outputFS, this.options.distDir, req, res, next);
215
+ }
216
+ async serve(fs, root, req, res, next) {
217
+ if (req.method !== 'GET' && req.method !== 'HEAD') {
218
+ // method not allowed
219
+ res.statusCode = 405;
220
+ res.setHeader('Allow', 'GET, HEAD');
221
+ res.setHeader('Content-Length', '0');
222
+ res.end();
223
+ return;
224
+ }
225
+ try {
226
+ var filePath = url_1.default.parse(req.url).pathname || '';
227
+ filePath = decodeURIComponent(filePath);
228
+ }
229
+ catch (err) {
230
+ return this.sendError(res, 400);
231
+ }
232
+ filePath = path_1.default.normalize('.' + path_1.default.sep + filePath);
233
+ // malicious path
234
+ if (filePath.includes(path_1.default.sep + '..' + path_1.default.sep)) {
235
+ return this.sendError(res, 403);
236
+ }
237
+ // join / normalize from the root dir
238
+ if (!path_1.default.isAbsolute(filePath)) {
239
+ filePath = path_1.default.normalize(path_1.default.join(root, filePath));
240
+ }
241
+ try {
242
+ var stat = await fs.stat(filePath);
243
+ }
244
+ catch (err) {
245
+ if (err.code === 'ENOENT') {
246
+ return next(req, res);
247
+ }
248
+ return this.sendError(res, 500);
249
+ }
250
+ // Fall back to next handler if not a file
251
+ if (!stat || !stat.isFile()) {
252
+ return next(req, res);
253
+ }
254
+ if ((0, fresh_1.default)(req.headers, { 'last-modified': stat.mtime.toUTCString() })) {
255
+ res.statusCode = 304;
256
+ res.end();
257
+ return;
258
+ }
259
+ return (0, serve_handler_1.default)(req, res, {
260
+ public: root,
261
+ cleanUrls: false,
262
+ }, {
263
+ // @ts-expect-error TS7006
264
+ lstat: (path) => fs.stat(path),
265
+ // @ts-expect-error TS7006
266
+ realpath: (path) => fs.realpath(path),
267
+ // @ts-expect-error TS7006
268
+ createReadStream: (path, options) => fs.createReadStream(path, options),
269
+ // @ts-expect-error TS7006
270
+ readdir: (path) => fs.readdir(path),
271
+ });
272
+ }
273
+ sendError(res, statusCode) {
274
+ res.statusCode = statusCode;
275
+ res.end();
276
+ }
277
+ send404(req, res) {
278
+ res.statusCode = 404;
279
+ res.end(TEMPLATE_404);
280
+ }
281
+ send500(req, res) {
282
+ res.setHeader('Content-Type', 'text/html; charset=utf-8');
283
+ res.writeHead(500);
284
+ if (this.errors) {
285
+ return res.end(ejs_1.default.render(TEMPLATE_500, {
286
+ errors: this.errors,
287
+ hmrOptions: this.options.hmrOptions,
288
+ }));
289
+ }
290
+ }
291
+ logAccessIfVerbose(req) {
292
+ this.options.logger.verbose({
293
+ message: `Request: ${req.headers.host}${req.originalUrl || req.url}`,
294
+ });
295
+ }
296
+ /**
297
+ * Load proxy table from package.json and apply them.
298
+ */
299
+ async applyProxyTable(app) {
300
+ // avoid skipping project root
301
+ const fileInRoot = path_1.default.join(this.options.projectRoot, 'index');
302
+ const configFilePath = await (0, utils_1.resolveConfig)(this.options.inputFS, fileInRoot, [
303
+ '.proxyrc.cts',
304
+ '.proxyrc.mts',
305
+ '.proxyrc.ts',
306
+ '.proxyrc.cjs',
307
+ '.proxyrc.mjs',
308
+ '.proxyrc.js',
309
+ '.proxyrc',
310
+ '.proxyrc.json',
311
+ ], this.options.projectRoot);
312
+ if (!configFilePath) {
313
+ return this;
314
+ }
315
+ const filename = path_1.default.basename(configFilePath);
316
+ if (filename === '.proxyrc' || filename === '.proxyrc.json') {
317
+ let conf = await (0, utils_1.readConfig)(this.options.inputFS, configFilePath);
318
+ if (!conf) {
319
+ return this;
320
+ }
321
+ let cfg = conf.config;
322
+ if (typeof cfg !== 'object') {
323
+ this.options.logger.warn({
324
+ message: "Proxy table in '.proxyrc' should be of object type. Skipping...",
325
+ });
326
+ return this;
327
+ }
328
+ for (const [context, options] of Object.entries(cfg)) {
329
+ // each key is interpreted as context, and value as middleware options
330
+ // @ts-expect-error TS2345
331
+ app.use((0, http_proxy_middleware_1.createProxyMiddleware)(context, options));
332
+ }
333
+ }
334
+ else {
335
+ let cfg = await this.options.packageManager.require(configFilePath, fileInRoot);
336
+ if (Object.prototype.toString.call(cfg) === '[object Module]') {
337
+ cfg = cfg.default;
338
+ }
339
+ if (typeof cfg !== 'function') {
340
+ this.options.logger.warn({
341
+ message: `Proxy configuration file '${filename}' should export a function. Skipping...`,
342
+ });
343
+ return this;
344
+ }
345
+ cfg(app);
346
+ }
347
+ return this;
348
+ }
349
+ async start() {
350
+ const finalHandler = (req, res) => {
351
+ this.logAccessIfVerbose(req);
352
+ // Wait for the parcelInstance to finish bundling if needed
353
+ if (this.pending) {
354
+ this.pendingRequests.push([req, res]);
355
+ }
356
+ else {
357
+ this.respond(req, res);
358
+ }
359
+ };
360
+ const app = (0, connect_1.default)();
361
+ app.use((req, res, next) => {
362
+ setHeaders(res);
363
+ next();
364
+ });
365
+ app.use((req, res, next) => {
366
+ if (req.url === '/__parcel_healthcheck') {
367
+ res.statusCode = 200;
368
+ res.write(`${Date.now()}`);
369
+ res.end();
370
+ }
371
+ else {
372
+ next();
373
+ }
374
+ });
375
+ await this.applyProxyTable(app);
376
+ app.use(finalHandler);
377
+ let { server, stop } = await (0, utils_1.createHTTPServer)({
378
+ cacheDir: this.options.cacheDir,
379
+ https: this.options.https,
380
+ inputFS: this.options.inputFS,
381
+ listener: app,
382
+ outputFS: this.options.outputFS,
383
+ host: this.options.host,
384
+ });
385
+ this.stopServer = stop;
386
+ server.listen(this.options.port, this.options.host);
387
+ // @ts-expect-error TS2322
388
+ return new Promise((resolve, reject) => {
389
+ server.once('error', (err) => {
390
+ this.options.logger.error({
391
+ // @ts-expect-error TS2345
392
+ message: (0, serverErrors_1.default)(err, this.options.port),
393
+ });
394
+ reject(err);
395
+ });
396
+ server.once('listening', () => {
397
+ // @ts-expect-error TS2345
398
+ resolve(server);
399
+ });
400
+ });
401
+ }
402
+ async stop() {
403
+ (0, assert_1.default)(this.stopServer != null);
404
+ await this.stopServer();
405
+ this.stopServer = null;
406
+ }
407
+ }
408
+ exports.default = Server;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const plugin_1 = require("@atlaspack/plugin");
7
+ const HMRServer_1 = __importDefault(require("./HMRServer"));
8
+ const Server_1 = __importDefault(require("./Server"));
9
+ let servers = new Map();
10
+ let hmrServers = new Map();
11
+ exports.default = new plugin_1.Reporter({
12
+ async report({ event, options, logger }) {
13
+ let { serveOptions, hmrOptions } = options;
14
+ let server = serveOptions ? servers.get(serveOptions.port) : undefined;
15
+ let hmrPort = (hmrOptions && hmrOptions.port) || (serveOptions && serveOptions.port);
16
+ let hmrServer = hmrPort ? hmrServers.get(hmrPort) : undefined;
17
+ switch (event.type) {
18
+ case 'watchStart': {
19
+ if (serveOptions) {
20
+ // If there's already a server when watching has just started, something
21
+ // is wrong.
22
+ if (server) {
23
+ return logger.warn({
24
+ message: 'Trying to create the devserver but it already exists.',
25
+ });
26
+ }
27
+ let serverOptions = {
28
+ ...serveOptions,
29
+ projectRoot: options.projectRoot,
30
+ cacheDir: options.cacheDir,
31
+ // Override the target's publicUrl as that is likely meant for production.
32
+ // This could be configurable in the future.
33
+ publicUrl: serveOptions.publicUrl ?? '/',
34
+ inputFS: options.inputFS,
35
+ outputFS: options.outputFS,
36
+ packageManager: options.packageManager,
37
+ logger,
38
+ hmrOptions,
39
+ };
40
+ server = new Server_1.default(serverOptions);
41
+ servers.set(serveOptions.port, server);
42
+ const devServer = await server.start();
43
+ if (hmrOptions && hmrOptions.port === serveOptions.port) {
44
+ let hmrServerOptions = {
45
+ port: serveOptions.port,
46
+ host: hmrOptions.host,
47
+ devServer,
48
+ // @ts-expect-error TS7006
49
+ addMiddleware: (handler) => {
50
+ server?.middleware.push(handler);
51
+ },
52
+ logger,
53
+ https: options.serveOptions ? options.serveOptions.https : false,
54
+ cacheDir: options.cacheDir,
55
+ inputFS: options.inputFS,
56
+ outputFS: options.outputFS,
57
+ };
58
+ hmrServer = new HMRServer_1.default(hmrServerOptions);
59
+ hmrServers.set(serveOptions.port, hmrServer);
60
+ await hmrServer.start();
61
+ return;
62
+ }
63
+ }
64
+ let port = hmrOptions?.port;
65
+ if (typeof port === 'number') {
66
+ let hmrServerOptions = {
67
+ port,
68
+ host: hmrOptions?.host,
69
+ logger,
70
+ https: options.serveOptions ? options.serveOptions.https : false,
71
+ cacheDir: options.cacheDir,
72
+ inputFS: options.inputFS,
73
+ outputFS: options.outputFS,
74
+ };
75
+ hmrServer = new HMRServer_1.default(hmrServerOptions);
76
+ hmrServers.set(port, hmrServer);
77
+ await hmrServer.start();
78
+ }
79
+ break;
80
+ }
81
+ case 'watchEnd':
82
+ if (serveOptions) {
83
+ if (!server) {
84
+ return logger.warn({
85
+ message: 'Could not shutdown devserver because it does not exist.',
86
+ });
87
+ }
88
+ await server.stop();
89
+ servers.delete(server.options.port);
90
+ }
91
+ if (hmrOptions && hmrServer) {
92
+ await hmrServer.stop();
93
+ hmrServers.delete(hmrServer.wss.options.port);
94
+ }
95
+ break;
96
+ case 'buildStart':
97
+ if (server) {
98
+ server.buildStart();
99
+ }
100
+ break;
101
+ case 'buildProgress':
102
+ if (event.phase === 'bundled' &&
103
+ hmrServer &&
104
+ // Only send HMR updates before packaging if the built in dev server is used to ensure that
105
+ // no stale bundles are served. Otherwise emit it for 'buildSuccess'.
106
+ options.serveOptions !== false) {
107
+ await hmrServer.emitUpdate(event);
108
+ }
109
+ break;
110
+ case 'buildSuccess':
111
+ if (serveOptions) {
112
+ if (!server) {
113
+ return logger.warn({
114
+ message: 'Could not send success event to devserver because it does not exist.',
115
+ });
116
+ }
117
+ server.buildSuccess(event.bundleGraph, event.requestBundle);
118
+ }
119
+ if (hmrServer && options.serveOptions === false) {
120
+ await hmrServer.emitUpdate(event);
121
+ }
122
+ break;
123
+ case 'buildFailure':
124
+ // On buildFailure watchStart sometimes has not been called yet
125
+ // do not throw an additional warning here
126
+ if (server) {
127
+ await server.buildError(options, event.diagnostics);
128
+ }
129
+ if (hmrServer) {
130
+ await hmrServer.emitError(options, event.diagnostics);
131
+ }
132
+ break;
133
+ }
134
+ },
135
+ });
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.StaticServerDataProvider = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ /**
9
+ * An implementation of ServerDataProvider provides data from a direct `bundleGraph`
10
+ * and `requestBundle` function.
11
+ */
12
+ class StaticServerDataProvider {
13
+ constructor(distDir) {
14
+ this.bundleGraph = null;
15
+ this.requestBundleFn = null;
16
+ this.distDir = distDir;
17
+ }
18
+ getHTMLBundleFilePaths() {
19
+ return (this.bundleGraph
20
+ ?.getBundles()
21
+ .filter((b) => path_1.default.posix.extname(b.name) === '.html')
22
+ .map((b) => path_1.default.relative(this.distDir, b.filePath)) ?? []);
23
+ }
24
+ async requestBundle(requestedPath) {
25
+ const bundle = this.bundleGraph?.getBundles().find((b) => {
26
+ const relativePath = path_1.default.relative(this.distDir, b.filePath);
27
+ return relativePath === requestedPath;
28
+ });
29
+ if (!bundle) {
30
+ return 'not-found';
31
+ }
32
+ if (!this.requestBundleFn) {
33
+ return 'not-found';
34
+ }
35
+ await this.requestBundleFn(bundle);
36
+ return 'requested';
37
+ }
38
+ /**
39
+ * Update the provider with the latest bundle graph and request function.
40
+ *
41
+ * This should be called after every successful build so that subsequent requests operate on fresh data.
42
+ *
43
+ * @param bundleGraph The most recent bundle graph representing the output of a build.
44
+ * @param requestBundleFn Function that will be called to (re)build a specific bundle on demand.
45
+ */
46
+ update(bundleGraph, requestBundleFn) {
47
+ this.bundleGraph = bundleGraph;
48
+ this.requestBundleFn = requestBundleFn;
49
+ }
50
+ }
51
+ exports.StaticServerDataProvider = StaticServerDataProvider;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = serverErrors;
4
+ const serverErrorList = {
5
+ EACCES: "You don't have access to bind the server to port {port}.",
6
+ EADDRINUSE: 'There is already a process listening on port {port}.',
7
+ };
8
+ function serverErrors(err, port) {
9
+ let desc = `Error: ${err.code} occurred while setting up server on port ${port.toString()}.`;
10
+ // @ts-expect-error TS7053
11
+ if (serverErrorList[err.code]) {
12
+ // @ts-expect-error TS7053
13
+ desc = serverErrorList[err.code].replace(/{port}/g, port);
14
+ }
15
+ return desc;
16
+ }
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/reporter-dev-server",
3
- "version": "2.14.31",
3
+ "version": "2.14.32-dev-ts-project-refs-d30e9754f.0",
4
4
  "description": "Blazing fast, zero configuration web application bundler",
5
5
  "license": "(MIT OR Apache-2.0)",
6
6
  "type": "commonjs",
@@ -13,7 +13,7 @@
13
13
  },
14
14
  "main": "./lib/ServerReporter.js",
15
15
  "source": "./src/ServerReporter.ts",
16
- "types": "./lib/types/ServerReporter.d.ts",
16
+ "types": "./lib/types/src/ServerReporter.d.ts",
17
17
  "engines": {
18
18
  "node": ">= 16.0.0"
19
19
  },
@@ -26,9 +26,9 @@
26
26
  }
27
27
  },
28
28
  "dependencies": {
29
- "@atlaspack/plugin": "2.14.31",
30
- "@atlaspack/utils": "2.19.3",
31
- "@atlaspack/types": "2.15.21",
29
+ "@atlaspack/plugin": "2.14.32-dev-ts-project-refs-d30e9754f.0",
30
+ "@atlaspack/types": "2.15.22-dev-ts-project-refs-d30e9754f.0",
31
+ "@atlaspack/utils": "2.19.4-dev-ts-project-refs-d30e9754f.0",
32
32
  "connect": "^3.7.0",
33
33
  "ejs": "^3.1.6",
34
34
  "fresh": "^0.5.2",
@@ -40,14 +40,14 @@
40
40
  "ws": "^7.0.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@atlaspack/babel-preset": "2.14.4",
43
+ "@atlaspack/babel-preset": "2.14.5-dev-ts-project-refs-d30e9754f.0",
44
44
  "@types/connect": "^3.4.38",
45
45
  "@types/ejs": "^3.1.5",
46
46
  "@types/fresh": "^0.5.3",
47
47
  "@types/serve-handler": "^6.1.4"
48
48
  },
49
49
  "scripts": {
50
- "check-ts": "tsc --emitDeclarationOnly --rootDir src",
51
50
  "build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
52
- }
51
+ },
52
+ "gitHead": "d30e9754f8d423d53261ec54ec87e6fa1299578a"
53
53
  }
package/tsconfig.json CHANGED
@@ -1,4 +1,18 @@
1
1
  {
2
- "extends": "../../../tsconfig.json",
3
- "include": ["src"]
2
+ "extends": "../../../tsconfig.base.json",
3
+ "include": ["src"],
4
+ "compilerOptions": {
5
+ "composite": true
6
+ },
7
+ "references": [
8
+ {
9
+ "path": "../../core/plugin/tsconfig.json"
10
+ },
11
+ {
12
+ "path": "../../core/types/tsconfig.json"
13
+ },
14
+ {
15
+ "path": "../../core/utils/tsconfig.json"
16
+ }
17
+ ]
4
18
  }