@rspack/dev-server 2.0.0-rc.0 → 2.0.0-rc.2

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.
@@ -0,0 +1 @@
1
+ /*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */
@@ -0,0 +1,76 @@
1
+ import { __webpack_require__ } from "./108.js";
2
+ import "./108.js";
3
+ __webpack_require__.add({
4
+ "./node_modules/.pnpm/connect-history-api-fallback@2.0.0/node_modules/connect-history-api-fallback/lib/index.js" (module, exports, __webpack_require__) {
5
+ var url = __webpack_require__("url");
6
+ module.exports = function(options) {
7
+ options = options || {};
8
+ var logger = getLogger(options);
9
+ return function(req, res, next) {
10
+ var headers = req.headers;
11
+ if ('GET' !== req.method && 'HEAD' !== req.method) {
12
+ logger('Not rewriting', req.method, req.url, 'because the method is not GET or HEAD.');
13
+ return next();
14
+ }
15
+ if (headers && 'string' == typeof headers.accept) {
16
+ if (0 === headers.accept.indexOf('application/json')) {
17
+ logger('Not rewriting', req.method, req.url, 'because the client prefers JSON.');
18
+ return next();
19
+ } else if (!acceptsHtml(headers.accept, options)) {
20
+ logger('Not rewriting', req.method, req.url, 'because the client does not accept HTML.');
21
+ return next();
22
+ }
23
+ } else {
24
+ logger('Not rewriting', req.method, req.url, 'because the client did not send an HTTP accept header.');
25
+ return next();
26
+ }
27
+ var parsedUrl = url.parse(req.url);
28
+ var rewriteTarget;
29
+ options.rewrites = options.rewrites || [];
30
+ for(var i = 0; i < options.rewrites.length; i++){
31
+ var rewrite = options.rewrites[i];
32
+ var match = parsedUrl.pathname.match(rewrite.from);
33
+ if (null !== match) {
34
+ rewriteTarget = evaluateRewriteRule(parsedUrl, match, rewrite.to, req);
35
+ if ('/' !== rewriteTarget.charAt(0)) logger('We recommend using an absolute path for the rewrite target.', 'Received a non-absolute rewrite target', rewriteTarget, 'for URL', req.url);
36
+ logger('Rewriting', req.method, req.url, 'to', rewriteTarget);
37
+ req.url = rewriteTarget;
38
+ return next();
39
+ }
40
+ }
41
+ var pathname = parsedUrl.pathname;
42
+ if (pathname.lastIndexOf('.') > pathname.lastIndexOf('/') && true !== options.disableDotRule) {
43
+ logger('Not rewriting', req.method, req.url, 'because the path includes a dot (.) character.');
44
+ return next();
45
+ }
46
+ rewriteTarget = options.index || '/index.html';
47
+ logger('Rewriting', req.method, req.url, 'to', rewriteTarget);
48
+ req.url = rewriteTarget;
49
+ next();
50
+ };
51
+ };
52
+ function evaluateRewriteRule(parsedUrl, match, rule, req) {
53
+ if ('string' == typeof rule) return rule;
54
+ if ('function' != typeof rule) throw new Error('Rewrite rule can only be of type string or function.');
55
+ return rule({
56
+ parsedUrl: parsedUrl,
57
+ match: match,
58
+ request: req
59
+ });
60
+ }
61
+ function acceptsHtml(header, options) {
62
+ options.htmlAcceptHeaders = options.htmlAcceptHeaders || [
63
+ 'text/html',
64
+ '*/*'
65
+ ];
66
+ for(var i = 0; i < options.htmlAcceptHeaders.length; i++)if (-1 !== header.indexOf(options.htmlAcceptHeaders[i])) return true;
67
+ return false;
68
+ }
69
+ function getLogger(options) {
70
+ if (options && options.logger) return options.logger;
71
+ if (options && options.verbose) return console.log.bind(console);
72
+ return function() {};
73
+ }
74
+ }
75
+ });
76
+ __webpack_require__("./node_modules/.pnpm/connect-history-api-fallback@2.0.0/node_modules/connect-history-api-fallback/lib/index.js");