@modern-js/prod-server 2.0.0-beta.1 → 2.0.0-beta.3

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,123 @@
1
1
  # @modern-js/prod-server
2
2
 
3
+ ## 2.0.0-beta.3
4
+
5
+ ### Major Changes
6
+
7
+ - dda38c9c3e: chore: v2
8
+
9
+ ### Minor Changes
10
+
11
+ - c9e800d39a: feat: support React18 streaming SSR
12
+ feat: 支持 React18 流式 SSR
13
+ - 543be9558e: feat: compile server loader and support handle loader request
14
+ feat: 编译 server loader 并支持处理 loader 的请求
15
+
16
+ ### Patch Changes
17
+
18
+ - d032d49e09: export createHandle
19
+ 导出 createHandle 函数
20
+ - 15bf09d9c8: feat: support completely custom server, export render() api for render single page
21
+ feat: 支持完全自定义 Server,导出 render() 方法用来渲染单个页面
22
+ - cc971eabfc: refactor: move server plugin load logic in `@modern-js/core`
23
+ refactor:移除在 `@modern-js/core` 中的 server 插件加载逻辑
24
+ - 40ed5874c6: feat: inject css chunk into html for streaming ssr
25
+ feat: streaming ssr 返回的 html 注入 css chunk
26
+ - 102d32e4ba: feat(server): add `req` and `res` to SSR context
27
+
28
+ feat(server): 添加 `req` 和 `res` 到 SSR context 中
29
+
30
+ - 3bbea92b2a: feat: support Hook、Middleware new API
31
+ feat: 支持 Hook、Middleware 的新 API
32
+ - 73cd29dd9f: fix(server): add favicon fallback handler
33
+
34
+ fix(server): 添加 favicon 兜底处理逻辑
35
+
36
+ - cce8ece: fix: handle some `TODO` & `FIXME`, change some tests
37
+ fix: 处理一些 `TODO` 和 `FIXME`, 修改了一些 tests
38
+ - 18aaf42249: fix: fix server loader redirects
39
+ fix: 修复 server loader 重定向错误
40
+ - 14b712da84: fix: use consistent alias type and default value across packages
41
+
42
+ fix: 在各个包中使用一致的 alias 类型定义和默认值
43
+
44
+ - Updated dependencies [6aca875]
45
+ - Updated dependencies [15bf09d9c8]
46
+ - Updated dependencies [2e60319]
47
+ - Updated dependencies [92f0eade39]
48
+ - Updated dependencies [edd1cfb1af]
49
+ - Updated dependencies [cc971eabfc]
50
+ - Updated dependencies [5b9049f2e9]
51
+ - Updated dependencies [92004d1906]
52
+ - Updated dependencies [b8bbe036c7]
53
+ - Updated dependencies [d5a31df781]
54
+ - Updated dependencies [dda38c9c3e]
55
+ - Updated dependencies [3bbea92b2a]
56
+ - Updated dependencies [b710adb]
57
+ - Updated dependencies [ea7cf06]
58
+ - Updated dependencies [bbe4c4a]
59
+ - Updated dependencies [e4558a0]
60
+ - Updated dependencies [abf3421a75]
61
+ - Updated dependencies [543be9558e]
62
+ - Updated dependencies [14b712da84]
63
+ - @modern-js/utils@2.0.0-beta.3
64
+ - @modern-js/server-core@2.0.0-beta.3
65
+
66
+ ## 2.0.0-beta.2
67
+
68
+ ### Major Changes
69
+
70
+ - dda38c9c3e: chore: v2
71
+
72
+ ### Minor Changes
73
+
74
+ - c9e800d39a: feat: support React18 streaming SSR
75
+ feat: 支持 React18 流式 SSR
76
+ - 543be9558e: feat: compile server loader and support handle loader request
77
+ feat: 编译 server loader 并支持处理 loader 的请求
78
+
79
+ ### Patch Changes
80
+
81
+ - d032d49: export createHandle
82
+ 导出 createHandle 函数
83
+ - 15bf09d9c8: feat: support completely custom server, export render() api for render single page
84
+ feat: 支持完全自定义 Server,导出 render() 方法用来渲染单个页面
85
+ - cc971eabfc: refactor: move server plugin load logic in `@modern-js/core`
86
+ refactor:移除在 `@modern-js/core` 中的 server 插件加载逻辑
87
+ - 40ed587: feat: inject css chunk into html for streaming ssr
88
+ feat: streaming ssr 返回的 html 注入 css chunk
89
+ - 102d32e4ba: feat(server): add `req` and `res` to SSR context
90
+
91
+ feat(server): 添加 `req` 和 `res` 到 SSR context 中
92
+
93
+ - 3bbea92b2a: feat: support Hook、Middleware new API
94
+ feat: 支持 Hook、Middleware 的新 API
95
+ - 73cd29dd9f: fix(server): add favicon fallback handler
96
+
97
+ fix(server): 添加 favicon 兜底处理逻辑
98
+
99
+ - 18aaf42: fix: fix server loader redirects
100
+ fix: 修复 server loader 重定向错误
101
+ - 14b712da84: fix: use consistent alias type and default value across packages
102
+
103
+ fix: 在各个包中使用一致的 alias 类型定义和默认值
104
+
105
+ - Updated dependencies [15bf09d9c8]
106
+ - Updated dependencies [92f0ead]
107
+ - Updated dependencies [edd1cfb1af]
108
+ - Updated dependencies [cc971eabfc]
109
+ - Updated dependencies [5b9049f2e9]
110
+ - Updated dependencies [92004d1]
111
+ - Updated dependencies [b8bbe036c7]
112
+ - Updated dependencies [d5a31df781]
113
+ - Updated dependencies [dda38c9c3e]
114
+ - Updated dependencies [3bbea92b2a]
115
+ - Updated dependencies [abf3421a75]
116
+ - Updated dependencies [543be9558e]
117
+ - Updated dependencies [14b712da84]
118
+ - @modern-js/server-core@2.0.0-beta.2
119
+ - @modern-js/utils@2.0.0-beta.2
120
+
3
121
  ## 2.0.0-beta.1
4
122
 
5
123
  ### Major Changes
@@ -79,12 +79,11 @@ export class Server {
79
79
  runner.prepare();
80
80
  }
81
81
  initServerConfig(options) {
82
- var _options$config$outpu;
83
82
  const {
84
83
  pwd,
85
84
  serverConfigFile
86
85
  } = options;
87
- const distDirectory = path.join(pwd, ((_options$config$outpu = options.config.output) === null || _options$config$outpu === void 0 ? void 0 : _options$config$outpu.path) || 'dist');
86
+ const distDirectory = path.join(pwd, options.config.output.path || 'dist');
88
87
  const serverConfigPath = getServerConfigPath(distDirectory, serverConfigFile);
89
88
  const serverConfig = requireConfig(serverConfigPath);
90
89
  this.serverConfig = serverConfig;
@@ -95,7 +94,6 @@ export class Server {
95
94
  * merge cliConfig and serverConfig
96
95
  */
97
96
  async initConfig(runner, options) {
98
- var _config$output;
99
97
  const {
100
98
  pwd,
101
99
  config
@@ -104,7 +102,7 @@ export class Server {
104
102
  serverConfig
105
103
  } = this;
106
104
  const finalServerConfig = this.runConfigHook(runner, serverConfig);
107
- const resolvedConfigPath = path.join(pwd, (config === null || config === void 0 ? void 0 : (_config$output = config.output) === null || _config$output === void 0 ? void 0 : _config$output.path) || 'dist', OUTPUT_CONFIG_FILE);
105
+ const resolvedConfigPath = path.join(pwd, config.output.path || 'dist', OUTPUT_CONFIG_FILE);
108
106
  options.config = loadConfig({
109
107
  cliConfig: config,
110
108
  serverConfig: finalServerConfig,
@@ -142,8 +140,7 @@ export class Server {
142
140
  // TODO: 确认下这里是不是可以不从 options 中取插件,而是从 config 中取和过滤
143
141
  const {
144
142
  internalPlugins = INTERNAL_SERVER_PLUGINS,
145
- pwd,
146
- config
143
+ pwd
147
144
  } = options;
148
145
  const serverPlugins = this.serverConfig.plugins || [];
149
146
 
@@ -151,7 +148,7 @@ export class Server {
151
148
  const loadedPlugins = loadPlugins(pwd, serverPlugins, {
152
149
  internalPlugins
153
150
  });
154
- debug('plugins', config.plugins, loadedPlugins);
151
+ debug('plugins', loadedPlugins);
155
152
  loadedPlugins.forEach(p => {
156
153
  serverManager.usePlugin(p);
157
154
  });
@@ -161,7 +158,6 @@ export class Server {
161
158
  return hooksRunner;
162
159
  }
163
160
  async injectContext(runner, options) {
164
- var _config$output2;
165
161
  const appContext = this.initAppContext();
166
162
  const {
167
163
  config,
@@ -169,11 +165,10 @@ export class Server {
169
165
  } = options;
170
166
  ConfigContext.set(config);
171
167
  AppContext.set(_objectSpread(_objectSpread({}, appContext), {}, {
172
- distDirectory: path.join(pwd, ((_config$output2 = config.output) === null || _config$output2 === void 0 ? void 0 : _config$output2.path) || 'dist')
168
+ distDirectory: path.join(pwd, config.output.path || 'dist')
173
169
  }));
174
170
  }
175
171
  initAppContext() {
176
- var _config$output3;
177
172
  const {
178
173
  options
179
174
  } = this;
@@ -187,7 +182,7 @@ export class Server {
187
182
  }));
188
183
  return {
189
184
  appDirectory,
190
- distDirectory: path.join(appDirectory, ((_config$output3 = config.output) === null || _config$output3 === void 0 ? void 0 : _config$output3.path) || 'dist'),
185
+ distDirectory: path.join(appDirectory, config.output.path || 'dist'),
191
186
  sharedDirectory: path.resolve(appDirectory, SHARED_DIR),
192
187
  plugins: serverPlugins
193
188
  };
@@ -38,7 +38,6 @@ export class ModernServer {
38
38
  runMode,
39
39
  proxyTarget
40
40
  }) {
41
- var _config$output;
42
41
  _defineProperty(this, "pwd", void 0);
43
42
  _defineProperty(this, "distDir", void 0);
44
43
  _defineProperty(this, "workDir", void 0);
@@ -62,7 +61,7 @@ export class ModernServer {
62
61
  _defineProperty(this, "staticGenerate", void 0);
63
62
  require('ignore-styles');
64
63
  this.pwd = pwd;
65
- this.distDir = path.join(pwd, ((_config$output = config.output) === null || _config$output === void 0 ? void 0 : _config$output.path) || 'dist');
64
+ this.distDir = path.join(pwd, config.output.path || 'dist');
66
65
  this.workDir = this.distDir;
67
66
  this.conf = config;
68
67
  debug('server conf', this.conf);
@@ -111,7 +110,7 @@ export class ModernServer {
111
110
 
112
111
  // Only work when without setting `assetPrefix`.
113
112
  // Setting `assetPrefix` means these resources should be uploaded to CDN.
114
- const staticPathRegExp = getStaticReg(this.conf.output || {});
113
+ const staticPathRegExp = getStaticReg(this.conf.output || {}, this.conf.html);
115
114
  this.staticFileHandler = createStaticFileHandler([{
116
115
  path: staticPathRegExp,
117
116
  target: distDir
@@ -67,15 +67,19 @@ export const createMiddlewareCollecter = () => {
67
67
  export const useLocalPrefix = url => {
68
68
  return isProd() && !url.includes('.');
69
69
  };
70
- export const getStaticReg = (output = {}) => {
70
+ export const getStaticReg = (output = {}, html = {}) => {
71
71
  const {
72
- favicon,
73
- faviconByEntries,
74
- cssPath,
75
- jsPath,
76
- mediaPath,
72
+ distPath: {
73
+ css: cssPath,
74
+ js: jsPath,
75
+ media: mediaPath
76
+ } = {},
77
77
  assetPrefix = '/'
78
78
  } = output;
79
+ const {
80
+ favicon,
81
+ faviconByEntries
82
+ } = html;
79
83
  const prefix = useLocalPrefix(assetPrefix) ? assetPrefix : '';
80
84
  const favicons = prepareFavicons(favicon, faviconByEntries);
81
85
  const staticFiles = [cssPath, jsPath, mediaPath].filter(v => Boolean(v));
@@ -86,12 +86,11 @@ class Server {
86
86
  runner.prepare();
87
87
  }
88
88
  initServerConfig(options) {
89
- var _options$config$outpu;
90
89
  const {
91
90
  pwd,
92
91
  serverConfigFile
93
92
  } = options;
94
- const distDirectory = _path.default.join(pwd, ((_options$config$outpu = options.config.output) === null || _options$config$outpu === void 0 ? void 0 : _options$config$outpu.path) || 'dist');
93
+ const distDirectory = _path.default.join(pwd, options.config.output.path || 'dist');
95
94
  const serverConfigPath = (0, _loadConfig.getServerConfigPath)(distDirectory, serverConfigFile);
96
95
  const serverConfig = (0, _loadConfig.requireConfig)(serverConfigPath);
97
96
  this.serverConfig = serverConfig;
@@ -102,7 +101,6 @@ class Server {
102
101
  * merge cliConfig and serverConfig
103
102
  */
104
103
  async initConfig(runner, options) {
105
- var _config$output;
106
104
  const {
107
105
  pwd,
108
106
  config
@@ -111,7 +109,7 @@ class Server {
111
109
  serverConfig
112
110
  } = this;
113
111
  const finalServerConfig = this.runConfigHook(runner, serverConfig);
114
- const resolvedConfigPath = _path.default.join(pwd, (config === null || config === void 0 ? void 0 : (_config$output = config.output) === null || _config$output === void 0 ? void 0 : _config$output.path) || 'dist', _utils.OUTPUT_CONFIG_FILE);
112
+ const resolvedConfigPath = _path.default.join(pwd, config.output.path || 'dist', _utils.OUTPUT_CONFIG_FILE);
115
113
  options.config = (0, _loadConfig.loadConfig)({
116
114
  cliConfig: config,
117
115
  serverConfig: finalServerConfig,
@@ -149,8 +147,7 @@ class Server {
149
147
  // TODO: 确认下这里是不是可以不从 options 中取插件,而是从 config 中取和过滤
150
148
  const {
151
149
  internalPlugins = _utils.INTERNAL_SERVER_PLUGINS,
152
- pwd,
153
- config
150
+ pwd
154
151
  } = options;
155
152
  const serverPlugins = this.serverConfig.plugins || [];
156
153
 
@@ -158,7 +155,7 @@ class Server {
158
155
  const loadedPlugins = (0, _serverCore.loadPlugins)(pwd, serverPlugins, {
159
156
  internalPlugins
160
157
  });
161
- (0, _utils2.debug)('plugins', config.plugins, loadedPlugins);
158
+ (0, _utils2.debug)('plugins', loadedPlugins);
162
159
  loadedPlugins.forEach(p => {
163
160
  _serverCore.serverManager.usePlugin(p);
164
161
  });
@@ -168,7 +165,6 @@ class Server {
168
165
  return hooksRunner;
169
166
  }
170
167
  async injectContext(runner, options) {
171
- var _config$output2;
172
168
  const appContext = this.initAppContext();
173
169
  const {
174
170
  config,
@@ -176,11 +172,10 @@ class Server {
176
172
  } = options;
177
173
  _serverCore.ConfigContext.set(config);
178
174
  _serverCore.AppContext.set(_objectSpread(_objectSpread({}, appContext), {}, {
179
- distDirectory: _path.default.join(pwd, ((_config$output2 = config.output) === null || _config$output2 === void 0 ? void 0 : _config$output2.path) || 'dist')
175
+ distDirectory: _path.default.join(pwd, config.output.path || 'dist')
180
176
  }));
181
177
  }
182
178
  initAppContext() {
183
- var _config$output3;
184
179
  const {
185
180
  options
186
181
  } = this;
@@ -194,7 +189,7 @@ class Server {
194
189
  }));
195
190
  return {
196
191
  appDirectory,
197
- distDirectory: _path.default.join(appDirectory, ((_config$output3 = config.output) === null || _config$output3 === void 0 ? void 0 : _config$output3.path) || 'dist'),
192
+ distDirectory: _path.default.join(appDirectory, config.output.path || 'dist'),
198
193
  sharedDirectory: _path.default.resolve(appDirectory, _utils.SHARED_DIR),
199
194
  plugins: serverPlugins
200
195
  };
@@ -46,7 +46,6 @@ class ModernServer {
46
46
  runMode,
47
47
  proxyTarget
48
48
  }) {
49
- var _config$output;
50
49
  _defineProperty(this, "pwd", void 0);
51
50
  _defineProperty(this, "distDir", void 0);
52
51
  _defineProperty(this, "workDir", void 0);
@@ -70,7 +69,7 @@ class ModernServer {
70
69
  _defineProperty(this, "staticGenerate", void 0);
71
70
  require('ignore-styles');
72
71
  this.pwd = pwd;
73
- this.distDir = _path.default.join(pwd, ((_config$output = config.output) === null || _config$output === void 0 ? void 0 : _config$output.path) || 'dist');
72
+ this.distDir = _path.default.join(pwd, config.output.path || 'dist');
74
73
  this.workDir = this.distDir;
75
74
  this.conf = config;
76
75
  (0, _utils2.debug)('server conf', this.conf);
@@ -119,7 +118,7 @@ class ModernServer {
119
118
 
120
119
  // Only work when without setting `assetPrefix`.
121
120
  // Setting `assetPrefix` means these resources should be uploaded to CDN.
122
- const staticPathRegExp = (0, _utils2.getStaticReg)(this.conf.output || {});
121
+ const staticPathRegExp = (0, _utils2.getStaticReg)(this.conf.output || {}, this.conf.html);
123
122
  this.staticFileHandler = (0, _serveFile.createStaticFileHandler)([{
124
123
  path: staticPathRegExp,
125
124
  target: distDir
@@ -79,15 +79,19 @@ const useLocalPrefix = url => {
79
79
  return (0, _utils.isProd)() && !url.includes('.');
80
80
  };
81
81
  exports.useLocalPrefix = useLocalPrefix;
82
- const getStaticReg = (output = {}) => {
82
+ const getStaticReg = (output = {}, html = {}) => {
83
83
  const {
84
- favicon,
85
- faviconByEntries,
86
- cssPath,
87
- jsPath,
88
- mediaPath,
84
+ distPath: {
85
+ css: cssPath,
86
+ js: jsPath,
87
+ media: mediaPath
88
+ } = {},
89
89
  assetPrefix = '/'
90
90
  } = output;
91
+ const {
92
+ favicon,
93
+ faviconByEntries
94
+ } = html;
91
95
  const prefix = useLocalPrefix(assetPrefix) ? assetPrefix : '';
92
96
  const favicons = prepareFavicons(favicon, faviconByEntries);
93
97
  const staticFiles = [cssPath, jsPath, mediaPath].filter(v => Boolean(v));
@@ -129,10 +129,9 @@ export var Server = /*#__PURE__*/function () {
129
129
  }, {
130
130
  key: "initServerConfig",
131
131
  value: function initServerConfig(options) {
132
- var _options$config$outpu;
133
132
  var pwd = options.pwd,
134
133
  serverConfigFile = options.serverConfigFile;
135
- var distDirectory = path.join(pwd, ((_options$config$outpu = options.config.output) === null || _options$config$outpu === void 0 ? void 0 : _options$config$outpu.path) || 'dist');
134
+ var distDirectory = path.join(pwd, options.config.output.path || 'dist');
136
135
  var serverConfigPath = getServerConfigPath(distDirectory, serverConfigFile);
137
136
  var serverConfig = requireConfig(serverConfigPath);
138
137
  this.serverConfig = serverConfig;
@@ -146,7 +145,6 @@ export var Server = /*#__PURE__*/function () {
146
145
  key: "initConfig",
147
146
  value: function () {
148
147
  var _initConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(runner, options) {
149
- var _config$output;
150
148
  var pwd, config, serverConfig, finalServerConfig, resolvedConfigPath;
151
149
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
152
150
  while (1) {
@@ -155,7 +153,7 @@ export var Server = /*#__PURE__*/function () {
155
153
  pwd = options.pwd, config = options.config;
156
154
  serverConfig = this.serverConfig;
157
155
  finalServerConfig = this.runConfigHook(runner, serverConfig);
158
- resolvedConfigPath = path.join(pwd, (config === null || config === void 0 ? void 0 : (_config$output = config.output) === null || _config$output === void 0 ? void 0 : _config$output.path) || 'dist', OUTPUT_CONFIG_FILE);
156
+ resolvedConfigPath = path.join(pwd, config.output.path || 'dist', OUTPUT_CONFIG_FILE);
159
157
  options.config = loadConfig({
160
158
  cliConfig: config,
161
159
  serverConfig: finalServerConfig,
@@ -240,7 +238,7 @@ export var Server = /*#__PURE__*/function () {
240
238
  key: "createHookRunner",
241
239
  value: function () {
242
240
  var _createHookRunner = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
243
- var options, _options$internalPlug, internalPlugins, pwd, config, serverPlugins, loadedPlugins, hooksRunner;
241
+ var options, _options$internalPlug, internalPlugins, pwd, serverPlugins, loadedPlugins, hooksRunner;
244
242
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
245
243
  while (1) {
246
244
  switch (_context6.prev = _context6.next) {
@@ -248,12 +246,12 @@ export var Server = /*#__PURE__*/function () {
248
246
  // clear server manager every create time
249
247
  serverManager.clear();
250
248
  options = this.options; // TODO: 确认下这里是不是可以不从 options 中取插件,而是从 config 中取和过滤
251
- _options$internalPlug = options.internalPlugins, internalPlugins = _options$internalPlug === void 0 ? INTERNAL_SERVER_PLUGINS : _options$internalPlug, pwd = options.pwd, config = options.config;
249
+ _options$internalPlug = options.internalPlugins, internalPlugins = _options$internalPlug === void 0 ? INTERNAL_SERVER_PLUGINS : _options$internalPlug, pwd = options.pwd;
252
250
  serverPlugins = this.serverConfig.plugins || []; // server app context for serve plugin
253
251
  loadedPlugins = loadPlugins(pwd, serverPlugins, {
254
252
  internalPlugins: internalPlugins
255
253
  });
256
- debug('plugins', config.plugins, loadedPlugins);
254
+ debug('plugins', loadedPlugins);
257
255
  loadedPlugins.forEach(function (p) {
258
256
  serverManager.usePlugin(p);
259
257
  });
@@ -280,7 +278,6 @@ export var Server = /*#__PURE__*/function () {
280
278
  key: "injectContext",
281
279
  value: function () {
282
280
  var _injectContext = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(runner, options) {
283
- var _config$output2;
284
281
  var appContext, config, pwd;
285
282
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
286
283
  while (1) {
@@ -290,7 +287,7 @@ export var Server = /*#__PURE__*/function () {
290
287
  config = options.config, pwd = options.pwd;
291
288
  ConfigContext.set(config);
292
289
  AppContext.set(_objectSpread(_objectSpread({}, appContext), {}, {
293
- distDirectory: path.join(pwd, ((_config$output2 = config.output) === null || _config$output2 === void 0 ? void 0 : _config$output2.path) || 'dist')
290
+ distDirectory: path.join(pwd, config.output.path || 'dist')
294
291
  }));
295
292
  case 4:
296
293
  case "end":
@@ -307,7 +304,6 @@ export var Server = /*#__PURE__*/function () {
307
304
  }, {
308
305
  key: "initAppContext",
309
306
  value: function initAppContext() {
310
- var _config$output3;
311
307
  var options = this.options;
312
308
  var appDirectory = options.pwd,
313
309
  _options$plugins = options.plugins,
@@ -320,7 +316,7 @@ export var Server = /*#__PURE__*/function () {
320
316
  });
321
317
  return {
322
318
  appDirectory: appDirectory,
323
- distDirectory: path.join(appDirectory, ((_config$output3 = config.output) === null || _config$output3 === void 0 ? void 0 : _config$output3.path) || 'dist'),
319
+ distDirectory: path.join(appDirectory, config.output.path || 'dist'),
324
320
  sharedDirectory: path.resolve(appDirectory, SHARED_DIR),
325
321
  plugins: serverPlugins
326
322
  };
@@ -32,7 +32,6 @@ export var ModernServer = /*#__PURE__*/function () {
32
32
  // work on src or dist
33
33
 
34
34
  function ModernServer(_ref) {
35
- var _config$output;
36
35
  var pwd = _ref.pwd,
37
36
  config = _ref.config,
38
37
  routes = _ref.routes,
@@ -65,7 +64,7 @@ export var ModernServer = /*#__PURE__*/function () {
65
64
  _defineProperty(this, "staticGenerate", void 0);
66
65
  require('ignore-styles');
67
66
  this.pwd = pwd;
68
- this.distDir = path.join(pwd, ((_config$output = config.output) === null || _config$output === void 0 ? void 0 : _config$output.path) || 'dist');
67
+ this.distDir = path.join(pwd, config.output.path || 'dist');
69
68
  this.workDir = this.distDir;
70
69
  this.conf = config;
71
70
  debug('server conf', this.conf);
@@ -122,7 +121,7 @@ export var ModernServer = /*#__PURE__*/function () {
122
121
  case 14:
123
122
  // Only work when without setting `assetPrefix`.
124
123
  // Setting `assetPrefix` means these resources should be uploaded to CDN.
125
- staticPathRegExp = getStaticReg(this.conf.output || {});
124
+ staticPathRegExp = getStaticReg(this.conf.output || {}, this.conf.html);
126
125
  this.staticFileHandler = createStaticFileHandler([{
127
126
  path: staticPathRegExp,
128
127
  target: distDir
@@ -41,13 +41,16 @@ export var useLocalPrefix = function useLocalPrefix(url) {
41
41
  };
42
42
  export var getStaticReg = function getStaticReg() {
43
43
  var output = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
44
- var favicon = output.favicon,
45
- faviconByEntries = output.faviconByEntries,
46
- cssPath = output.cssPath,
47
- jsPath = output.jsPath,
48
- mediaPath = output.mediaPath,
44
+ var html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
45
+ var _output$distPath = output.distPath;
46
+ _output$distPath = _output$distPath === void 0 ? {} : _output$distPath;
47
+ var cssPath = _output$distPath.css,
48
+ jsPath = _output$distPath.js,
49
+ mediaPath = _output$distPath.media,
49
50
  _output$assetPrefix = output.assetPrefix,
50
51
  assetPrefix = _output$assetPrefix === void 0 ? '/' : _output$assetPrefix;
52
+ var favicon = html.favicon,
53
+ faviconByEntries = html.faviconByEntries;
51
54
  var prefix = useLocalPrefix(assetPrefix) ? assetPrefix : '';
52
55
  var favicons = prepareFavicons(favicon, faviconByEntries);
53
56
  var staticFiles = [cssPath, jsPath, mediaPath].filter(function (v) {
@@ -2,7 +2,7 @@
2
2
  /// <reference types="node" />
3
3
  /// <reference types="node/http" />
4
4
  import { IncomingMessage } from 'http';
5
- import type { NormalizedConfig } from '@modern-js/core';
5
+ import type { OutputNormalizedConfig, HtmlNormalizedConfig } from '@modern-js/server-core';
6
6
  export declare const debug: any;
7
7
  export declare const mergeExtension: (users: any[]) => {
8
8
  middleware: any[];
@@ -19,7 +19,7 @@ export declare const createMiddlewareCollecter: () => {
19
19
  addAPIMiddleware: (input: any) => void;
20
20
  };
21
21
  export declare const useLocalPrefix: (url: string) => boolean;
22
- export declare const getStaticReg: (output?: NormalizedConfig['output']) => RegExp;
22
+ export declare const getStaticReg: (output?: OutputNormalizedConfig, html?: HtmlNormalizedConfig) => RegExp;
23
23
  export declare const prepareFavicons: (favicon: string | undefined, faviconByEntries?: Record<string, string | undefined>) => string[];
24
24
  export declare const headersWithoutCookie: (headers: IncomingMessage['headers']) => import("http").IncomingHttpHeaders;
25
25
  export declare const isRedirect: (code: number) => boolean;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.0.0-beta.1",
14
+ "version": "2.0.0-beta.3",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -59,8 +59,8 @@
59
59
  "path-to-regexp": "^6.2.0",
60
60
  "serve-static": "^1.14.1",
61
61
  "ua-parser-js": "^0.7.28",
62
- "@modern-js/utils": "2.0.0-beta.1",
63
- "@modern-js/server-core": "2.0.0-beta.1"
62
+ "@modern-js/utils": "2.0.0-beta.3",
63
+ "@modern-js/server-core": "2.0.0-beta.3"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@types/cookie": "^0.4.1",
@@ -76,10 +76,10 @@
76
76
  "node-mocks-http": "^1.11.0",
77
77
  "portfinder": "^1.0.28",
78
78
  "typescript": "^4",
79
- "@modern-js/types": "2.0.0-beta.1",
80
- "@modern-js/core": "2.0.0-beta.1",
81
- "@scripts/jest-config": "2.0.0-beta.1",
82
- "@scripts/build": "2.0.0-beta.1"
79
+ "@modern-js/types": "2.0.0-beta.3",
80
+ "@modern-js/server-core": "2.0.0-beta.3",
81
+ "@scripts/jest-config": "2.0.0-beta.3",
82
+ "@scripts/build": "2.0.0-beta.3"
83
83
  },
84
84
  "sideEffects": false,
85
85
  "modernConfig": {
@@ -90,9 +90,9 @@
90
90
  "registry": "https://registry.npmjs.org/"
91
91
  },
92
92
  "scripts": {
93
- "new": "modern new",
94
- "build": "modern build",
95
- "dev": "modern build --watch",
93
+ "new": "modern-lib new",
94
+ "build": "modern-lib build",
95
+ "dev": "modern-lib build --watch",
96
96
  "test": "jest"
97
97
  }
98
98
  }