@modern-js/prod-server 2.17.1 → 2.18.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @modern-js/prod-server
2
2
 
3
+ ## 2.18.1
4
+
5
+ ### Patch Changes
6
+
7
+ - @modern-js/server-core@2.18.1
8
+ - @modern-js/utils@2.18.1
9
+
10
+ ## 2.18.0
11
+
12
+ ### Patch Changes
13
+
14
+ - @modern-js/server-core@2.18.0
15
+ - @modern-js/utils@2.18.0
16
+
3
17
  ## 2.17.1
4
18
 
5
19
  ### Patch Changes
@@ -8,7 +8,6 @@ Object.defineProperty(exports, "render", {
8
8
  });
9
9
  const _path = /* @__PURE__ */ _interop_require_default(require("path"));
10
10
  const _utils = require("@modern-js/utils");
11
- const _constants = require("@modern-js/utils/constants");
12
11
  const _cache = /* @__PURE__ */ _interop_require_default(require("./cache"));
13
12
  const _measure = require("./measure");
14
13
  const _utils1 = require("./utils");
@@ -21,9 +20,9 @@ const render = async (ctx, renderOptions, runner) => {
21
20
  var _ctx_res;
22
21
  const { urlPath, bundle, distDir, template, entryName, staticGenerate, enableUnsafeCtx = false } = renderOptions;
23
22
  const bundleJS = _path.default.join(distDir, bundle);
24
- const loadableUri = _path.default.join(distDir, _constants.LOADABLE_STATS_FILE);
23
+ const loadableUri = _path.default.join(distDir, _utils.LOADABLE_STATS_FILE);
25
24
  const loadableStats = _utils.fs.existsSync(loadableUri) ? require(loadableUri) : "";
26
- const routesManifestUri = _path.default.join(distDir, _constants.ROUTE_MANIFEST_FILE);
25
+ const routesManifestUri = _path.default.join(distDir, _utils.ROUTE_MANIFEST_FILE);
27
26
  const routeManifest = _utils.fs.existsSync(routesManifestUri) ? require(routesManifestUri) : void 0;
28
27
  const context = {
29
28
  request: {
@@ -59,7 +58,7 @@ const render = async (ctx, renderOptions, runner) => {
59
58
  context.logger = (0, _measure.createLogger)(context, ctx.logger);
60
59
  context.metrics = (0, _measure.createMetrics)(context, ctx.metrics);
61
60
  runner.extendSSRContext(context);
62
- const serverRender = require(bundleJS)[_constants.SERVER_RENDER_FUNCTION_NAME];
61
+ const serverRender = require(bundleJS)[_utils.SERVER_RENDER_FUNCTION_NAME];
63
62
  const content = await (0, _cache.default)(serverRender, ctx)(context);
64
63
  const { url, status = 302 } = context.redirection;
65
64
  if (url) {
@@ -23,7 +23,7 @@ function _create_class(Constructor, protoProps, staticProps) {
23
23
  function _define_property(obj, key, value) {
24
24
  if (key in obj) {
25
25
  Object.defineProperty(obj, key, {
26
- value,
26
+ value: value,
27
27
  enumerable: true,
28
28
  configurable: true,
29
29
  writable: true
@@ -34,7 +34,7 @@ function _create_class(Constructor, protoProps, staticProps) {
34
34
  function _define_property(obj, key, value) {
35
35
  if (key in obj) {
36
36
  Object.defineProperty(obj, key, {
37
- value,
37
+ value: value,
38
38
  enumerable: true,
39
39
  configurable: true,
40
40
  writable: true
@@ -23,7 +23,7 @@ function _create_class(Constructor, protoProps, staticProps) {
23
23
  function _define_property(obj, key, value) {
24
24
  if (key in obj) {
25
25
  Object.defineProperty(obj, key, {
26
- value,
26
+ value: value,
27
27
  enumerable: true,
28
28
  configurable: true,
29
29
  writable: true
@@ -23,7 +23,7 @@ function _create_class(Constructor, protoProps, staticProps) {
23
23
  function _define_property(obj, key, value) {
24
24
  if (key in obj) {
25
25
  Object.defineProperty(obj, key, {
26
- value,
26
+ value: value,
27
27
  enumerable: true,
28
28
  configurable: true,
29
29
  writable: true
@@ -1,7 +1,7 @@
1
1
  function _define_property(obj, key, value) {
2
2
  if (key in obj) {
3
3
  Object.defineProperty(obj, key, {
4
- value,
4
+ value: value,
5
5
  enumerable: true,
6
6
  configurable: true,
7
7
  writable: true
@@ -38,7 +38,7 @@ function _create_class(Constructor, protoProps, staticProps) {
38
38
  function _define_property(obj, key, value) {
39
39
  if (key in obj) {
40
40
  Object.defineProperty(obj, key, {
41
- value,
41
+ value: value,
42
42
  enumerable: true,
43
43
  configurable: true,
44
44
  writable: true
@@ -41,7 +41,7 @@ function _async_to_generator(fn) {
41
41
  function _define_property(obj, key, value) {
42
42
  if (key in obj) {
43
43
  Object.defineProperty(obj, key, {
44
- value,
44
+ value: value,
45
45
  enumerable: true,
46
46
  configurable: true,
47
47
  writable: true
@@ -41,7 +41,7 @@ function _async_to_generator(fn) {
41
41
  function _define_property(obj, key, value) {
42
42
  if (key in obj) {
43
43
  Object.defineProperty(obj, key, {
44
- value,
44
+ value: value,
45
45
  enumerable: true,
46
46
  configurable: true,
47
47
  writable: true
@@ -30,7 +30,7 @@ function _async_to_generator(fn) {
30
30
  function _define_property(obj, key, value) {
31
31
  if (key in obj) {
32
32
  Object.defineProperty(obj, key, {
33
- value,
33
+ value: value,
34
34
  enumerable: true,
35
35
  configurable: true,
36
36
  writable: true
@@ -140,7 +140,7 @@ function _createPageCaches() {
140
140
  switch (_state.label) {
141
141
  case 0:
142
142
  constructorOptions = {
143
- max
143
+ max: max
144
144
  };
145
145
  cacheInstance = new LRUCaches(constructorOptions);
146
146
  return [
@@ -23,7 +23,7 @@ function _create_class(Constructor, protoProps, staticProps) {
23
23
  function _define_property(obj, key, value) {
24
24
  if (key in obj) {
25
25
  Object.defineProperty(obj, key, {
26
- value,
26
+ value: value,
27
27
  enumerable: true,
28
28
  configurable: true,
29
29
  writable: true
@@ -52,7 +52,7 @@ function _create_class(Constructor, protoProps, staticProps) {
52
52
  function _define_property(obj, key, value) {
53
53
  if (key in obj) {
54
54
  Object.defineProperty(obj, key, {
55
- value,
55
+ value: value,
56
56
  enumerable: true,
57
57
  configurable: true,
58
58
  writable: true
@@ -333,7 +333,7 @@ var CacheManager = /* @__PURE__ */ function() {
333
333
  includes: config.includes || null,
334
334
  limit: config.staleLimit,
335
335
  matches: config.matches || null,
336
- caches
336
+ caches: caches
337
337
  };
338
338
  }
339
339
  },
@@ -374,8 +374,8 @@ var CacheManager = /* @__PURE__ */ function() {
374
374
  {
375
375
  content: html || "",
376
376
  contentType: mime.contentType("html"),
377
- isStale,
378
- isGarbage,
377
+ isStale: isStale,
378
+ isGarbage: isGarbage,
379
379
  hash: cacheHash
380
380
  }
381
381
  ];
@@ -438,9 +438,9 @@ var CacheManager = /* @__PURE__ */ function() {
438
438
  next.caches.set(cacheHash, {
439
439
  expireTime: Date.now() + cacheConfig.interval * 1e3,
440
440
  limitTime: typeof limit === "number" ? Date.now() + limit * 1e3 : null,
441
- cacheHash,
441
+ cacheHash: cacheHash,
442
442
  html: storeHTML,
443
- size
443
+ size: size
444
444
  })
445
445
  ];
446
446
  case 1:
@@ -202,12 +202,12 @@ export var createRenderHandler = function(param) {
202
202
  return [
203
203
  4,
204
204
  ssr.render(ctx, {
205
- distDir,
205
+ distDir: distDir,
206
206
  entryName: route.entryName,
207
207
  urlPath: route.urlPath,
208
208
  bundle: route.bundle,
209
209
  template: content.toString(),
210
- staticGenerate
210
+ staticGenerate: staticGenerate
211
211
  }, runner)
212
212
  ];
213
213
  case 5:
@@ -12,7 +12,7 @@ function _array_without_holes(arr) {
12
12
  function _define_property(obj, key, value) {
13
13
  if (key in obj) {
14
14
  Object.defineProperty(obj, key, {
15
- value,
15
+ value: value,
16
16
  enumerable: true,
17
17
  configurable: true,
18
18
  writable: true
@@ -98,20 +98,20 @@ export var createMetrics = function(context, metrics) {
98
98
  var emitTimer = function(name, cost) {
99
99
  var tags = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
100
100
  metrics.emitTimer(name, cost, _object_spread_props(_object_spread({}, tags), {
101
- pathname,
102
- entry
101
+ pathname: pathname,
102
+ entry: entry
103
103
  }));
104
104
  };
105
105
  var emitCounter = function(name, counter) {
106
106
  var tags = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
107
107
  metrics.emitCounter(name, counter, _object_spread_props(_object_spread({}, tags), {
108
- pathname,
109
- entry
108
+ pathname: pathname,
109
+ entry: entry
110
110
  }));
111
111
  };
112
112
  return {
113
- emitTimer,
114
- emitCounter
113
+ emitTimer: emitTimer,
114
+ emitCounter: emitCounter
115
115
  };
116
116
  };
117
117
  export var createLogger = function(serverContext, logger) {
@@ -147,8 +147,8 @@ export var createLogger = function(serverContext, logger) {
147
147
  logger.error("SSR Error - ".concat(message, ", error = %s, req.url = %s, req.headers = %o"), _instanceof(e, Error) ? e.stack || e.message : e, pathname, headersWithoutCookie(headers));
148
148
  };
149
149
  return {
150
- error,
151
- info,
152
- debug
150
+ error: error,
151
+ info: info,
152
+ debug: debug
153
153
  };
154
154
  };
@@ -52,7 +52,7 @@ function _create_class(Constructor, protoProps, staticProps) {
52
52
  function _define_property(obj, key, value) {
53
53
  if (key in obj) {
54
54
  Object.defineProperty(obj, key, {
55
- value,
55
+ value: value,
56
56
  enumerable: true,
57
57
  configurable: true,
58
58
  writable: true
@@ -187,8 +187,8 @@ var createCacheItem = function() {
187
187
  return [
188
188
  2,
189
189
  {
190
- content,
191
- mtime
190
+ content: content,
191
+ mtime: mtime
192
192
  }
193
193
  ];
194
194
  }
@@ -234,7 +234,7 @@ export var LruReader = /* @__PURE__ */ function() {
234
234
  return [
235
235
  2,
236
236
  {
237
- content
237
+ content: content
238
238
  }
239
239
  ];
240
240
  }
@@ -130,8 +130,7 @@ var __generator = function(thisArg, body) {
130
130
  }
131
131
  };
132
132
  import path from "path";
133
- import { fs, mime } from "@modern-js/utils";
134
- import { LOADABLE_STATS_FILE, ROUTE_MANIFEST_FILE, SERVER_RENDER_FUNCTION_NAME } from "@modern-js/utils/constants";
133
+ import { fs, mime, LOADABLE_STATS_FILE, ROUTE_MANIFEST_FILE, SERVER_RENDER_FUNCTION_NAME } from "@modern-js/utils";
135
134
  import cache from "./cache";
136
135
  import { createLogger, createMetrics } from "./measure";
137
136
  import { injectServerDataStream, injectServerData } from "./utils";
@@ -167,16 +166,16 @@ export var render = function() {
167
166
  locals: ((_ctx_res = ctx.res) === null || _ctx_res === void 0 ? void 0 : _ctx_res.locals) || {}
168
167
  },
169
168
  redirection: {},
170
- template,
171
- loadableStats,
172
- routeManifest,
173
- entryName,
174
- staticGenerate,
169
+ template: template,
170
+ loadableStats: loadableStats,
171
+ routeManifest: routeManifest,
172
+ entryName: entryName,
173
+ staticGenerate: staticGenerate,
175
174
  logger: void 0,
176
175
  metrics: void 0,
177
176
  req: ctx.req,
178
177
  res: ctx.res,
179
- enableUnsafeCtx
178
+ enableUnsafeCtx: enableUnsafeCtx
180
179
  };
181
180
  context.logger = createLogger(context, ctx.logger);
182
181
  context.metrics = createMetrics(context, ctx.metrics);
@@ -209,7 +209,7 @@ function _handleDirectory() {
209
209
  return [
210
210
  2,
211
211
  {
212
- content,
212
+ content: content,
213
213
  contentType: contentType || ""
214
214
  }
215
215
  ];
@@ -23,7 +23,7 @@ function _create_class(Constructor, protoProps, staticProps) {
23
23
  function _define_property(obj, key, value) {
24
24
  if (key in obj) {
25
25
  Object.defineProperty(obj, key, {
26
- value,
26
+ value: value,
27
27
  enumerable: true,
28
28
  configurable: true,
29
29
  writable: true
@@ -23,7 +23,7 @@ function _create_class(Constructor, protoProps, staticProps) {
23
23
  function _define_property(obj, key, value) {
24
24
  if (key in obj) {
25
25
  Object.defineProperty(obj, key, {
26
- value,
26
+ value: value,
27
27
  enumerable: true,
28
28
  configurable: true,
29
29
  writable: true
@@ -6,7 +6,7 @@ function _class_call_check(instance, Constructor) {
6
6
  function _define_property(obj, key, value) {
7
7
  if (key in obj) {
8
8
  Object.defineProperty(obj, key, {
9
- value,
9
+ value: value,
10
10
  enumerable: true,
11
11
  configurable: true,
12
12
  writable: true
@@ -63,7 +63,7 @@ function _create_class(Constructor, protoProps, staticProps) {
63
63
  function _define_property(obj, key, value) {
64
64
  if (key in obj) {
65
65
  Object.defineProperty(obj, key, {
66
- value,
66
+ value: value,
67
67
  enumerable: true,
68
68
  configurable: true,
69
69
  writable: true
@@ -403,7 +403,7 @@ export var Server = /* @__PURE__ */ function() {
403
403
  options.config = loadConfig({
404
404
  cliConfig: config,
405
405
  serverConfig: finalServerConfig,
406
- resolvedConfigPath
406
+ resolvedConfigPath: resolvedConfigPath
407
407
  });
408
408
  return [
409
409
  2
@@ -483,7 +483,7 @@ export var Server = /* @__PURE__ */ function() {
483
483
  _options_internalPlugins = options.internalPlugins, internalPlugins = _options_internalPlugins === void 0 ? INTERNAL_SERVER_PLUGINS : _options_internalPlugins, pwd = options.pwd, _options_plugins = options.plugins, plugins = _options_plugins === void 0 ? [] : _options_plugins;
484
484
  serverPlugins = _this.serverConfig.plugins || [];
485
485
  loadedPlugins = loadPlugins(pwd, _to_consumable_array(serverPlugins).concat(_to_consumable_array(plugins)), {
486
- internalPlugins
486
+ internalPlugins: internalPlugins
487
487
  });
488
488
  debug("plugins", loadedPlugins);
489
489
  loadedPlugins.forEach(function(p) {
@@ -535,7 +535,7 @@ export var Server = /* @__PURE__ */ function() {
535
535
  };
536
536
  });
537
537
  return {
538
- appDirectory,
538
+ appDirectory: appDirectory,
539
539
  apiDirectory: appContext === null || appContext === void 0 ? void 0 : appContext.apiDirectory,
540
540
  lambdaDirectory: appContext === null || appContext === void 0 ? void 0 : appContext.lambdaDirectory,
541
541
  sharedDirectory: (appContext === null || appContext === void 0 ? void 0 : appContext.sharedDirectory) || path.resolve(appDirectory, SHARED_DIR),
@@ -52,7 +52,7 @@ function _create_class(Constructor, protoProps, staticProps) {
52
52
  function _define_property(obj, key, value) {
53
53
  if (key in obj) {
54
54
  Object.defineProperty(obj, key, {
55
- value,
55
+ value: value,
56
56
  enumerable: true,
57
57
  configurable: true,
58
58
  writable: true
@@ -306,9 +306,9 @@ export var ModernServer = /* @__PURE__ */ function() {
306
306
  ssrConfig = (_this_conf_server = _this.conf.server) === null || _this_conf_server === void 0 ? void 0 : _this_conf_server.ssr;
307
307
  forceCSR = typeof ssrConfig === "object" ? ssrConfig.forceCSR : false;
308
308
  _this.routeRenderHandler = createRenderHandler({
309
- distDir,
310
- staticGenerate,
311
- forceCSR
309
+ distDir: distDir,
310
+ staticGenerate: staticGenerate,
311
+ forceCSR: forceCSR
312
312
  });
313
313
  return [
314
314
  4,
@@ -356,8 +356,8 @@ export var ModernServer = /* @__PURE__ */ function() {
356
356
  return [
357
357
  4,
358
358
  _this.prepareFrameHandler({
359
- onlyWeb,
360
- onlyApi
359
+ onlyWeb: onlyWeb,
360
+ onlyApi: onlyApi
361
361
  })
362
362
  ];
363
363
  case 1:
@@ -491,7 +491,7 @@ export var ModernServer = /* @__PURE__ */ function() {
491
491
  4,
492
492
  runner.prepareLoaderHandler({
493
493
  serverRoutes: specs,
494
- distDir
494
+ distDir: distDir
495
495
  }, {
496
496
  onLast: function() {
497
497
  return null;
@@ -771,7 +771,7 @@ export var ModernServer = /* @__PURE__ */ function() {
771
771
  4,
772
772
  _this.routeRenderHandler({
773
773
  ctx: context,
774
- route,
774
+ route: route,
775
775
  runner: _this.runner
776
776
  })
777
777
  ];
@@ -1153,7 +1153,7 @@ export var ModernServer = /* @__PURE__ */ function() {
1153
1153
  return [
1154
1154
  4,
1155
1155
  _this.routeRenderHandler({
1156
- route,
1156
+ route: route,
1157
1157
  ctx: context,
1158
1158
  runner: _this.runner
1159
1159
  })
package/dist/esm/utils.js CHANGED
@@ -12,7 +12,7 @@ function _array_without_holes(arr) {
12
12
  function _define_property(obj, key, value) {
13
13
  if (key in obj) {
14
14
  Object.defineProperty(obj, key, {
15
- value,
15
+ value: value,
16
16
  enumerable: true,
17
17
  configurable: true,
18
18
  writable: true
@@ -90,9 +90,9 @@ export var createMiddlewareCollecter = function() {
90
90
  };
91
91
  };
92
92
  return {
93
- getMiddlewares,
94
- addWebMiddleware,
95
- addAPIMiddleware
93
+ getMiddlewares: getMiddlewares,
94
+ addWebMiddleware: addWebMiddleware,
95
+ addAPIMiddleware: addAPIMiddleware
96
96
  };
97
97
  };
98
98
  export var getStaticReg = function() {
@@ -1,6 +1,5 @@
1
1
  import path from "path";
2
- import { fs, mime } from "@modern-js/utils";
3
- import { LOADABLE_STATS_FILE, ROUTE_MANIFEST_FILE, SERVER_RENDER_FUNCTION_NAME } from "@modern-js/utils/constants";
2
+ import { fs, mime, LOADABLE_STATS_FILE, ROUTE_MANIFEST_FILE, SERVER_RENDER_FUNCTION_NAME } from "@modern-js/utils";
4
3
  import cache from "./cache";
5
4
  import { createLogger, createMetrics } from "./measure";
6
5
  import { injectServerDataStream, injectServerData } from "./utils";
@@ -2,7 +2,7 @@
2
2
  /// <reference types="node" />
3
3
  /// <reference types="node" />
4
4
  /// <reference types="node/http" />
5
- /// <reference types=".dts-temp/Vvkf_ZXVvB1QPdEj4fyaW/src/type" />
5
+ /// <reference types=".dts-temp/zqSQqAITBl0q4ajYXnO0Q/src/type" />
6
6
  import { IncomingMessage, ServerResponse } from 'http';
7
7
  import qs from 'querystring';
8
8
  import type { ModernServerContext as ModernServerContextInterface } from '@modern-js/types';
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node/http" />
3
- /// <reference types=".dts-temp/Vvkf_ZXVvB1QPdEj4fyaW/src/type" />
3
+ /// <reference types=".dts-temp/zqSQqAITBl0q4ajYXnO0Q/src/type" />
4
4
  import { IncomingMessage } from 'http';
5
5
  import type { OutputNormalizedConfig, HtmlNormalizedConfig } from '@modern-js/server-core';
6
6
  export declare const debug: any;
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.17.1",
18
+ "version": "2.18.1",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -60,8 +60,8 @@
60
60
  "merge-deep": "^3.0.3",
61
61
  "path-to-regexp": "^6.2.0",
62
62
  "serve-static": "^1.14.1",
63
- "@modern-js/utils": "2.17.1",
64
- "@modern-js/server-core": "2.17.1"
63
+ "@modern-js/utils": "2.18.1",
64
+ "@modern-js/server-core": "2.18.1"
65
65
  },
66
66
  "devDependencies": {
67
67
  "@types/cookie": "^0.4.1",
@@ -77,10 +77,10 @@
77
77
  "node-mocks-http": "^1.11.0",
78
78
  "portfinder": "^1.0.28",
79
79
  "typescript": "^4",
80
- "@modern-js/types": "2.17.1",
81
- "@modern-js/server-core": "2.17.1",
82
- "@scripts/jest-config": "2.17.1",
83
- "@scripts/build": "2.17.1"
80
+ "@modern-js/types": "2.18.1",
81
+ "@modern-js/server-core": "2.18.1",
82
+ "@scripts/build": "2.18.1",
83
+ "@scripts/jest-config": "2.18.1"
84
84
  },
85
85
  "sideEffects": false,
86
86
  "publishConfig": {