@modern-js/prod-server 2.6.1-alpha.0 → 2.7.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.
Files changed (129) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/cjs/libs/serveFile.js +3 -4
  3. package/dist/cjs/server/modernServer.js +18 -15
  4. package/dist/cjs/utils.js +4 -13
  5. package/dist/esm/libs/serveFile.js +4 -5
  6. package/dist/esm/server/modernServer.js +14 -10
  7. package/dist/esm/utils.js +4 -8
  8. package/dist/esm-node/libs/serveFile.js +3 -4
  9. package/dist/esm-node/server/modernServer.js +18 -15
  10. package/dist/esm-node/utils.js +4 -12
  11. package/dist/types/libs/context/context.d.ts +1 -1
  12. package/dist/types/libs/serveFile.d.ts +1 -2
  13. package/dist/types/server/modernServer.d.ts +1 -1
  14. package/dist/types/utils.d.ts +2 -3
  15. package/package.json +9 -9
  16. package/dist/js/modern/constants.js +0 -35
  17. package/dist/js/modern/index.js +0 -18
  18. package/dist/js/modern/libs/context/context.js +0 -160
  19. package/dist/js/modern/libs/context/index.js +0 -6
  20. package/dist/js/modern/libs/hook-api/index.js +0 -134
  21. package/dist/js/modern/libs/hook-api/route.js +0 -20
  22. package/dist/js/modern/libs/hook-api/template.js +0 -73
  23. package/dist/js/modern/libs/loadConfig.js +0 -62
  24. package/dist/js/modern/libs/logger.js +0 -111
  25. package/dist/js/modern/libs/metrics.js +0 -11
  26. package/dist/js/modern/libs/proxy.js +0 -92
  27. package/dist/js/modern/libs/render/cache/__tests__/cache.fun.test.js +0 -114
  28. package/dist/js/modern/libs/render/cache/__tests__/cache.test.js +0 -254
  29. package/dist/js/modern/libs/render/cache/__tests__/cacheable.js +0 -47
  30. package/dist/js/modern/libs/render/cache/__tests__/error-configuration.js +0 -37
  31. package/dist/js/modern/libs/render/cache/__tests__/matched-cache.js +0 -91
  32. package/dist/js/modern/libs/render/cache/index.js +0 -115
  33. package/dist/js/modern/libs/render/cache/page-caches/index.js +0 -32
  34. package/dist/js/modern/libs/render/cache/page-caches/lru.js +0 -29
  35. package/dist/js/modern/libs/render/cache/spr.js +0 -248
  36. package/dist/js/modern/libs/render/cache/type.js +0 -0
  37. package/dist/js/modern/libs/render/cache/util.js +0 -102
  38. package/dist/js/modern/libs/render/index.js +0 -86
  39. package/dist/js/modern/libs/render/measure.js +0 -68
  40. package/dist/js/modern/libs/render/reader.js +0 -107
  41. package/dist/js/modern/libs/render/ssr.js +0 -100
  42. package/dist/js/modern/libs/render/static.js +0 -60
  43. package/dist/js/modern/libs/render/type.js +0 -9
  44. package/dist/js/modern/libs/route/index.js +0 -54
  45. package/dist/js/modern/libs/route/matcher.js +0 -87
  46. package/dist/js/modern/libs/route/route.js +0 -16
  47. package/dist/js/modern/libs/serve-file.js +0 -67
  48. package/dist/js/modern/server/index.js +0 -208
  49. package/dist/js/modern/server/modern-server-split.js +0 -74
  50. package/dist/js/modern/server/modern-server.js +0 -554
  51. package/dist/js/modern/type.js +0 -0
  52. package/dist/js/modern/utils.js +0 -136
  53. package/dist/js/modern/worker-server.js +0 -89
  54. package/dist/js/node/constants.js +0 -62
  55. package/dist/js/node/index.js +0 -44
  56. package/dist/js/node/libs/context/context.js +0 -189
  57. package/dist/js/node/libs/context/index.js +0 -30
  58. package/dist/js/node/libs/hook-api/index.js +0 -164
  59. package/dist/js/node/libs/hook-api/route.js +0 -43
  60. package/dist/js/node/libs/hook-api/template.js +0 -97
  61. package/dist/js/node/libs/loadConfig.js +0 -91
  62. package/dist/js/node/libs/logger.js +0 -133
  63. package/dist/js/node/libs/metrics.js +0 -34
  64. package/dist/js/node/libs/proxy.js +0 -114
  65. package/dist/js/node/libs/render/cache/__tests__/cache.fun.test.js +0 -115
  66. package/dist/js/node/libs/render/cache/__tests__/cache.test.js +0 -245
  67. package/dist/js/node/libs/render/cache/__tests__/cacheable.js +0 -70
  68. package/dist/js/node/libs/render/cache/__tests__/error-configuration.js +0 -60
  69. package/dist/js/node/libs/render/cache/__tests__/matched-cache.js +0 -114
  70. package/dist/js/node/libs/render/cache/index.js +0 -134
  71. package/dist/js/node/libs/render/cache/page-caches/index.js +0 -55
  72. package/dist/js/node/libs/render/cache/page-caches/lru.js +0 -58
  73. package/dist/js/node/libs/render/cache/spr.js +0 -270
  74. package/dist/js/node/libs/render/cache/type.js +0 -15
  75. package/dist/js/node/libs/render/cache/util.js +0 -138
  76. package/dist/js/node/libs/render/index.js +0 -115
  77. package/dist/js/node/libs/render/measure.js +0 -90
  78. package/dist/js/node/libs/render/reader.js +0 -140
  79. package/dist/js/node/libs/render/ssr.js +0 -123
  80. package/dist/js/node/libs/render/static.js +0 -89
  81. package/dist/js/node/libs/render/type.js +0 -32
  82. package/dist/js/node/libs/route/index.js +0 -78
  83. package/dist/js/node/libs/route/matcher.js +0 -106
  84. package/dist/js/node/libs/route/route.js +0 -39
  85. package/dist/js/node/libs/serve-file.js +0 -97
  86. package/dist/js/node/server/index.js +0 -219
  87. package/dist/js/node/server/modern-server-split.js +0 -97
  88. package/dist/js/node/server/modern-server.js +0 -559
  89. package/dist/js/node/type.js +0 -15
  90. package/dist/js/node/utils.js +0 -166
  91. package/dist/js/node/worker-server.js +0 -113
  92. package/dist/js/treeshaking/constants.js +0 -29
  93. package/dist/js/treeshaking/index.js +0 -13
  94. package/dist/js/treeshaking/libs/context/context.js +0 -274
  95. package/dist/js/treeshaking/libs/context/index.js +0 -5
  96. package/dist/js/treeshaking/libs/hook-api/index.js +0 -281
  97. package/dist/js/treeshaking/libs/hook-api/route.js +0 -68
  98. package/dist/js/treeshaking/libs/hook-api/template.js +0 -127
  99. package/dist/js/treeshaking/libs/loadConfig.js +0 -82
  100. package/dist/js/treeshaking/libs/logger.js +0 -205
  101. package/dist/js/treeshaking/libs/metrics.js +0 -6
  102. package/dist/js/treeshaking/libs/proxy.js +0 -244
  103. package/dist/js/treeshaking/libs/render/cache/__tests__/cache.fun.test.js +0 -291
  104. package/dist/js/treeshaking/libs/render/cache/__tests__/cache.test.js +0 -781
  105. package/dist/js/treeshaking/libs/render/cache/__tests__/cacheable.js +0 -67
  106. package/dist/js/treeshaking/libs/render/cache/__tests__/error-configuration.js +0 -45
  107. package/dist/js/treeshaking/libs/render/cache/__tests__/matched-cache.js +0 -147
  108. package/dist/js/treeshaking/libs/render/cache/index.js +0 -346
  109. package/dist/js/treeshaking/libs/render/cache/page-caches/index.js +0 -154
  110. package/dist/js/treeshaking/libs/render/cache/page-caches/lru.js +0 -84
  111. package/dist/js/treeshaking/libs/render/cache/spr.js +0 -492
  112. package/dist/js/treeshaking/libs/render/cache/type.js +0 -1
  113. package/dist/js/treeshaking/libs/render/cache/util.js +0 -280
  114. package/dist/js/treeshaking/libs/render/index.js +0 -234
  115. package/dist/js/treeshaking/libs/render/measure.js +0 -146
  116. package/dist/js/treeshaking/libs/render/reader.js +0 -339
  117. package/dist/js/treeshaking/libs/render/ssr.js +0 -223
  118. package/dist/js/treeshaking/libs/render/static.js +0 -216
  119. package/dist/js/treeshaking/libs/render/type.js +0 -7
  120. package/dist/js/treeshaking/libs/route/index.js +0 -130
  121. package/dist/js/treeshaking/libs/route/matcher.js +0 -143
  122. package/dist/js/treeshaking/libs/route/route.js +0 -40
  123. package/dist/js/treeshaking/libs/serve-file.js +0 -184
  124. package/dist/js/treeshaking/server/index.js +0 -505
  125. package/dist/js/treeshaking/server/modern-server-split.js +0 -360
  126. package/dist/js/treeshaking/server/modern-server.js +0 -1089
  127. package/dist/js/treeshaking/type.js +0 -1
  128. package/dist/js/treeshaking/utils.js +0 -147
  129. package/dist/js/treeshaking/worker-server.js +0 -233
@@ -1,281 +0,0 @@
1
- function _arrayLikeToArray(arr, len) {
2
- if (len == null || len > arr.length) len = arr.length;
3
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
- return arr2;
5
- }
6
- function _arrayWithHoles(arr) {
7
- if (Array.isArray(arr)) return arr;
8
- }
9
- function _classCallCheck(instance, Constructor) {
10
- if (!(instance instanceof Constructor)) {
11
- throw new TypeError("Cannot call a class as a function");
12
- }
13
- }
14
- function _defineProperties(target, props) {
15
- for(var i = 0; i < props.length; i++){
16
- var descriptor = props[i];
17
- descriptor.enumerable = descriptor.enumerable || false;
18
- descriptor.configurable = true;
19
- if ("value" in descriptor) descriptor.writable = true;
20
- Object.defineProperty(target, descriptor.key, descriptor);
21
- }
22
- }
23
- function _createClass(Constructor, protoProps, staticProps) {
24
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
25
- if (staticProps) _defineProperties(Constructor, staticProps);
26
- return Constructor;
27
- }
28
- function _defineProperty(obj, key, value) {
29
- if (key in obj) {
30
- Object.defineProperty(obj, key, {
31
- value: value,
32
- enumerable: true,
33
- configurable: true,
34
- writable: true
35
- });
36
- } else {
37
- obj[key] = value;
38
- }
39
- return obj;
40
- }
41
- function _iterableToArrayLimit(arr, i) {
42
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
43
- if (_i == null) return;
44
- var _arr = [];
45
- var _n = true;
46
- var _d = false;
47
- var _s, _e;
48
- try {
49
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
50
- _arr.push(_s.value);
51
- if (i && _arr.length === i) break;
52
- }
53
- } catch (err) {
54
- _d = true;
55
- _e = err;
56
- } finally{
57
- try {
58
- if (!_n && _i["return"] != null) _i["return"]();
59
- } finally{
60
- if (_d) throw _e;
61
- }
62
- }
63
- return _arr;
64
- }
65
- function _nonIterableRest() {
66
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
67
- }
68
- function _objectSpread(target) {
69
- for(var i = 1; i < arguments.length; i++){
70
- var source = arguments[i] != null ? arguments[i] : {};
71
- var ownKeys = Object.keys(source);
72
- if (typeof Object.getOwnPropertySymbols === "function") {
73
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
74
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
75
- }));
76
- }
77
- ownKeys.forEach(function(key) {
78
- _defineProperty(target, key, source[key]);
79
- });
80
- }
81
- return target;
82
- }
83
- function ownKeys(object, enumerableOnly) {
84
- var keys = Object.keys(object);
85
- if (Object.getOwnPropertySymbols) {
86
- var symbols = Object.getOwnPropertySymbols(object);
87
- if (enumerableOnly) {
88
- symbols = symbols.filter(function(sym) {
89
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
90
- });
91
- }
92
- keys.push.apply(keys, symbols);
93
- }
94
- return keys;
95
- }
96
- function _objectSpreadProps(target, source) {
97
- source = source != null ? source : {};
98
- if (Object.getOwnPropertyDescriptors) {
99
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
100
- } else {
101
- ownKeys(Object(source)).forEach(function(key) {
102
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
103
- });
104
- }
105
- return target;
106
- }
107
- function _slicedToArray(arr, i) {
108
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
109
- }
110
- function _unsupportedIterableToArray(o, minLen) {
111
- if (!o) return;
112
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
113
- var n = Object.prototype.toString.call(o).slice(8, -1);
114
- if (n === "Object" && o.constructor) n = o.constructor.name;
115
- if (n === "Map" || n === "Set") return Array.from(n);
116
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
117
- }
118
- import cookie from "cookie";
119
- import { RouteAPI } from "./route";
120
- import { TemplateAPI } from "./template";
121
- var Response = /*#__PURE__*/ function() {
122
- "use strict";
123
- function Response(res) {
124
- _classCallCheck(this, Response);
125
- _defineProperty(this, "cookies", void 0);
126
- _defineProperty(this, "res", void 0);
127
- _defineProperty(this, "_cookie", void 0);
128
- this.res = res;
129
- this._cookie = cookie.parse(res.getHeader("set-cookie") || "");
130
- this.cookies = {
131
- get: this.getCookie.bind(this),
132
- set: this.setCookie.bind(this),
133
- delete: this.deleteCookie.bind(this),
134
- clear: this.clearCookie.bind(this),
135
- apply: this.applyCookie.bind(this)
136
- };
137
- }
138
- _createClass(Response, [
139
- {
140
- key: "get",
141
- value: function get(key) {
142
- return this.res.getHeader(key);
143
- }
144
- },
145
- {
146
- key: "set",
147
- value: function set(key, value) {
148
- return this.res.setHeader(key, value);
149
- }
150
- },
151
- {
152
- key: "status",
153
- value: function status(code) {
154
- this.res.statusCode = code;
155
- }
156
- },
157
- {
158
- key: "getCookie",
159
- value: function getCookie(key) {
160
- return this._cookie[key];
161
- }
162
- },
163
- {
164
- key: "setCookie",
165
- value: function setCookie(key, value) {
166
- this._cookie[key] = value;
167
- }
168
- },
169
- {
170
- key: "deleteCookie",
171
- value: function deleteCookie(key) {
172
- if (this._cookie[key]) {
173
- delete this._cookie[key];
174
- }
175
- }
176
- },
177
- {
178
- key: "clearCookie",
179
- value: function clearCookie() {
180
- this._cookie = {};
181
- }
182
- },
183
- {
184
- key: "applyCookie",
185
- value: function applyCookie() {
186
- var str = Object.entries(this._cookie).map(function(param) {
187
- var _param = _slicedToArray(param, 2), key = _param[0], value = _param[1];
188
- return cookie.serialize(key, value);
189
- }).join("; ");
190
- if (str) {
191
- this.res.setHeader("set-cookie", str);
192
- } else {
193
- this.res.removeHeader("set-cookie");
194
- }
195
- }
196
- },
197
- {
198
- key: "raw",
199
- value: function raw(body, options) {
200
- var _this = this;
201
- var _ref = options || {}, status = _ref.status, _ref_headers = _ref.headers, headers = _ref_headers === void 0 ? {} : _ref_headers;
202
- Object.entries(headers).forEach(function(param) {
203
- var _param = _slicedToArray(param, 2), key = _param[0], value = _param[1];
204
- _this.res.setHeader(key, value);
205
- });
206
- if (status) {
207
- this.res.statusCode = status;
208
- }
209
- this.res.end(body);
210
- }
211
- }
212
- ]);
213
- return Response;
214
- }();
215
- var Request = /*#__PURE__*/ function() {
216
- "use strict";
217
- function Request(ctx) {
218
- _classCallCheck(this, Request);
219
- _defineProperty(this, "url", void 0);
220
- _defineProperty(this, "host", void 0);
221
- _defineProperty(this, "pathname", void 0);
222
- _defineProperty(this, "query", void 0);
223
- _defineProperty(this, "headers", void 0);
224
- _defineProperty(this, "cookie", void 0);
225
- _defineProperty(this, "cookies", void 0);
226
- _defineProperty(this, "_cookie", void 0);
227
- this.url = ctx.url;
228
- this.host = ctx.host;
229
- this.pathname = ctx.path;
230
- this.query = ctx.query;
231
- this.headers = ctx.headers;
232
- this.cookie = ctx.headers.cookie || "";
233
- this._cookie = cookie.parse(this.cookie);
234
- this.cookies = {
235
- get: this.getCookie.bind(this)
236
- };
237
- }
238
- _createClass(Request, [
239
- {
240
- key: "getCookie",
241
- value: function getCookie(key) {
242
- return this._cookie[key];
243
- }
244
- }
245
- ]);
246
- return Request;
247
- }();
248
- var base = function(context) {
249
- var res = context.res;
250
- return {
251
- response: new Response(res),
252
- request: new Request(context),
253
- logger: context.logger,
254
- metrics: context.metrics
255
- };
256
- };
257
- var createAfterMatchContext = function(context, entryName) {
258
- var baseContext = base(context);
259
- return _objectSpreadProps(_objectSpread({}, baseContext), {
260
- router: new RouteAPI(entryName)
261
- });
262
- };
263
- var createAfterRenderContext = function(context, content) {
264
- var baseContext = base(context);
265
- return _objectSpreadProps(_objectSpread({}, baseContext), {
266
- template: new TemplateAPI(content)
267
- });
268
- };
269
- var createMiddlewareContext = function(context) {
270
- var baseContext = base(context);
271
- return _objectSpreadProps(_objectSpread({}, baseContext), {
272
- response: _objectSpreadProps(_objectSpread({}, baseContext.response), {
273
- locals: context.res.locals || {}
274
- }),
275
- source: {
276
- req: context.req,
277
- res: context.res
278
- }
279
- });
280
- };
281
- export { base, createAfterMatchContext, createAfterRenderContext, createMiddlewareContext };
@@ -1,68 +0,0 @@
1
- function _classCallCheck(instance, Constructor) {
2
- if (!(instance instanceof Constructor)) {
3
- throw new TypeError("Cannot call a class as a function");
4
- }
5
- }
6
- function _defineProperties(target, props) {
7
- for(var i = 0; i < props.length; i++){
8
- var descriptor = props[i];
9
- descriptor.enumerable = descriptor.enumerable || false;
10
- descriptor.configurable = true;
11
- if ("value" in descriptor) descriptor.writable = true;
12
- Object.defineProperty(target, descriptor.key, descriptor);
13
- }
14
- }
15
- function _createClass(Constructor, protoProps, staticProps) {
16
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
17
- if (staticProps) _defineProperties(Constructor, staticProps);
18
- return Constructor;
19
- }
20
- function _defineProperty(obj, key, value) {
21
- if (key in obj) {
22
- Object.defineProperty(obj, key, {
23
- value: value,
24
- enumerable: true,
25
- configurable: true,
26
- writable: true
27
- });
28
- } else {
29
- obj[key] = value;
30
- }
31
- return obj;
32
- }
33
- var RouteAPI = /*#__PURE__*/ function() {
34
- "use strict";
35
- function RouteAPI(entryName) {
36
- _classCallCheck(this, RouteAPI);
37
- _defineProperty(this, "current", void 0);
38
- _defineProperty(this, "status", void 0);
39
- _defineProperty(this, "url", void 0);
40
- this.current = entryName;
41
- this.status = 200;
42
- this.url = "";
43
- }
44
- _createClass(RouteAPI, [
45
- {
46
- key: "redirect",
47
- value: function redirect(url) {
48
- var status = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 302;
49
- this.url = url;
50
- this.status = status;
51
- }
52
- },
53
- {
54
- key: "rewrite",
55
- value: function rewrite(entryName) {
56
- this.current = entryName;
57
- }
58
- },
59
- {
60
- key: "use",
61
- value: function use(entryName) {
62
- this.rewrite(entryName);
63
- }
64
- }
65
- ]);
66
- return RouteAPI;
67
- }();
68
- export { RouteAPI };
@@ -1,127 +0,0 @@
1
- function _classCallCheck(instance, Constructor) {
2
- if (!(instance instanceof Constructor)) {
3
- throw new TypeError("Cannot call a class as a function");
4
- }
5
- }
6
- function _defineProperties(target, props) {
7
- for(var i = 0; i < props.length; i++){
8
- var descriptor = props[i];
9
- descriptor.enumerable = descriptor.enumerable || false;
10
- descriptor.configurable = true;
11
- if ("value" in descriptor) descriptor.writable = true;
12
- Object.defineProperty(target, descriptor.key, descriptor);
13
- }
14
- }
15
- function _createClass(Constructor, protoProps, staticProps) {
16
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
17
- if (staticProps) _defineProperties(Constructor, staticProps);
18
- return Constructor;
19
- }
20
- function _defineProperty(obj, key, value) {
21
- if (key in obj) {
22
- Object.defineProperty(obj, key, {
23
- value: value,
24
- enumerable: true,
25
- configurable: true,
26
- writable: true
27
- });
28
- } else {
29
- obj[key] = value;
30
- }
31
- return obj;
32
- }
33
- import { Transform } from "stream";
34
- var RegList = {
35
- before: {
36
- head: "<head>",
37
- body: "<body>"
38
- },
39
- after: {
40
- head: "</head>",
41
- body: "</body>"
42
- }
43
- };
44
- var TemplateAPI = /*#__PURE__*/ function() {
45
- "use strict";
46
- function TemplateAPI(content) {
47
- _classCallCheck(this, TemplateAPI);
48
- _defineProperty(this, "content", void 0);
49
- this.content = content;
50
- }
51
- _createClass(TemplateAPI, [
52
- {
53
- key: "get",
54
- value: function get() {
55
- return this.content;
56
- }
57
- },
58
- {
59
- key: "set",
60
- value: function set(content) {
61
- this.content = content;
62
- }
63
- },
64
- {
65
- key: "prependHead",
66
- value: function prependHead(fragment) {
67
- var head = RegList.before.head;
68
- return this.replace(head, "".concat(head).concat(fragment));
69
- }
70
- },
71
- {
72
- key: "appendHead",
73
- value: function appendHead(fragment) {
74
- var head = RegList.after.head;
75
- return this.replace(head, "".concat(fragment).concat(head));
76
- }
77
- },
78
- {
79
- key: "prependBody",
80
- value: function prependBody(fragment) {
81
- var body = RegList.before.body;
82
- return this.replace(body, "".concat(body).concat(fragment));
83
- }
84
- },
85
- {
86
- key: "appendBody",
87
- value: function appendBody(fragment) {
88
- var body = RegList.after.body;
89
- return this.replace(body, "".concat(fragment).concat(body));
90
- }
91
- },
92
- {
93
- key: "replace",
94
- value: function replace(reg, text) {
95
- this.content = this.content.replace(reg, text);
96
- }
97
- }
98
- ]);
99
- return TemplateAPI;
100
- }();
101
- var templateInjectableStream = function(param) {
102
- var prependHead = param.prependHead, appendHead = param.appendHead, prependBody = param.prependBody, appendBody = param.appendBody;
103
- return new Transform({
104
- write: function write(chunk, _, callback) {
105
- var chunk_str = chunk.toString();
106
- if (prependHead) {
107
- var head = RegList.before.head;
108
- chunk_str = chunk_str.replace(head, "".concat(head).concat(prependHead));
109
- }
110
- if (appendHead) {
111
- var head1 = RegList.after.head;
112
- chunk_str = chunk_str.replace(head1, "".concat(appendHead).concat(head1));
113
- }
114
- if (prependBody) {
115
- var body = RegList.before.body;
116
- chunk_str = chunk_str.replace(body, "".concat(body).concat(prependBody));
117
- }
118
- if (appendBody) {
119
- var body1 = RegList.after.body;
120
- chunk_str = chunk_str.replace(body1, "".concat(appendBody).concat(body1));
121
- }
122
- this.push(chunk_str);
123
- callback();
124
- }
125
- });
126
- };
127
- export { TemplateAPI, templateInjectableStream };
@@ -1,82 +0,0 @@
1
- function _defineProperty(obj, key, value) {
2
- if (key in obj) {
3
- Object.defineProperty(obj, key, {
4
- value: value,
5
- enumerable: true,
6
- configurable: true,
7
- writable: true
8
- });
9
- } else {
10
- obj[key] = value;
11
- }
12
- return obj;
13
- }
14
- function _objectSpread(target) {
15
- for(var i = 1; i < arguments.length; i++){
16
- var source = arguments[i] != null ? arguments[i] : {};
17
- var ownKeys = Object.keys(source);
18
- if (typeof Object.getOwnPropertySymbols === "function") {
19
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
20
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
21
- }));
22
- }
23
- ownKeys.forEach(function(key) {
24
- _defineProperty(target, key, source[key]);
25
- });
26
- }
27
- return target;
28
- }
29
- function ownKeys(object, enumerableOnly) {
30
- var keys = Object.keys(object);
31
- if (Object.getOwnPropertySymbols) {
32
- var symbols = Object.getOwnPropertySymbols(object);
33
- if (enumerableOnly) {
34
- symbols = symbols.filter(function(sym) {
35
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
36
- });
37
- }
38
- keys.push.apply(keys, symbols);
39
- }
40
- return keys;
41
- }
42
- function _objectSpreadProps(target, source) {
43
- source = source != null ? source : {};
44
- if (Object.getOwnPropertyDescriptors) {
45
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
46
- } else {
47
- ownKeys(Object(source)).forEach(function(key) {
48
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
49
- });
50
- }
51
- return target;
52
- }
53
- import * as path from "path";
54
- import { compatRequire, fs, DEFAULT_SERVER_CONFIG } from "@modern-js/utils";
55
- import mergeDeep from "merge-deep";
56
- var getServerConfigPath = function(distDirectory) {
57
- var serverConfigFile = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : DEFAULT_SERVER_CONFIG;
58
- var serverConfigPath = path.join(distDirectory, serverConfigFile);
59
- return "".concat(serverConfigPath, ".js");
60
- };
61
- var requireConfig = function(serverConfigPath) {
62
- if (fs.pathExistsSync(serverConfigPath)) {
63
- return compatRequire(serverConfigPath);
64
- }
65
- return {};
66
- };
67
- var loadConfig = function(param) {
68
- var cliConfig = param.cliConfig, serverConfig = param.serverConfig, resolvedConfigPath = param.resolvedConfigPath;
69
- var config = null;
70
- if (process.env.NODE_ENV === "production") {
71
- var resolvedConfig = requireConfig(resolvedConfigPath);
72
- config = mergeDeep(_objectSpreadProps(_objectSpread({}, resolvedConfig), {
73
- plugins: []
74
- }), serverConfig, cliConfig);
75
- } else {
76
- config = mergeDeep(_objectSpreadProps(_objectSpread({}, cliConfig), {
77
- plugins: []
78
- }), serverConfig);
79
- }
80
- return config;
81
- };
82
- export { getServerConfigPath, loadConfig, requireConfig };