@modern-js/server 1.21.2 → 2.0.0-beta.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/CHANGELOG.md CHANGED
@@ -1,5 +1,44 @@
1
1
  # @modern-js/server
2
2
 
3
+ ## 2.0.0-beta.0
4
+
5
+ ### Major Changes
6
+
7
+ - dda38c9: chore: v2
8
+
9
+ ### Patch Changes
10
+
11
+ - 15bf09d9c: feat: support completely custom server, export render() api for render single page
12
+ feat: 支持完全自定义 Server,导出 render() 方法用来渲染单个页面
13
+ - 61f21d1e7: fix: ignore the entire distPath for pia ssr bundle
14
+ fix: dist 目录的产物不应该被 ts-node 编译
15
+ - 14b712d: fix: use consistent alias type and default value across packages
16
+
17
+ fix: 在各个包中使用一致的 alias 类型定义和默认值
18
+
19
+ - Updated dependencies [9b915e0c1]
20
+ - Updated dependencies [c9e800d39]
21
+ - Updated dependencies [15bf09d9c]
22
+ - Updated dependencies [edd1cfb1a]
23
+ - Updated dependencies [cc971eabf]
24
+ - Updated dependencies [5b9049f]
25
+ - Updated dependencies [6bda14ed7]
26
+ - Updated dependencies [a8642da]
27
+ - Updated dependencies [b8bbe036c]
28
+ - Updated dependencies [d5a31df78]
29
+ - Updated dependencies [dda38c9]
30
+ - Updated dependencies [102d32e4b]
31
+ - Updated dependencies [8b8e1bb57]
32
+ - Updated dependencies [3bbea92b2]
33
+ - Updated dependencies [73cd29dd9]
34
+ - Updated dependencies [abf3421]
35
+ - Updated dependencies [543be95]
36
+ - Updated dependencies [14b712d]
37
+ - @modern-js/server-utils@2.0.0-beta.0
38
+ - @modern-js/prod-server@2.0.0-beta.0
39
+ - @modern-js/utils@2.0.0-beta.0
40
+ - @modern-js/types@2.0.0-beta.0
41
+
3
42
  ## 1.21.2
4
43
 
5
44
  ### Patch Changes
@@ -6,7 +6,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
6
6
 
7
7
  import path from 'path';
8
8
  import { resolveBabelConfig } from '@modern-js/server-utils';
9
- import { fs, getAlias, createDebugger } from '@modern-js/utils';
9
+ import { fs, getAliasConfig, createDebugger } from '@modern-js/utils';
10
10
  const debug = createDebugger('server');
11
11
 
12
12
  const checkDep = (depName, paths) => {
@@ -43,14 +43,14 @@ export const enableRegister = (projectRoot, config // eslint-disable-next-line c
43
43
  const {
44
44
  alias
45
45
  } = config.source;
46
- const aliasOption = getAlias(alias || {}, {
46
+ const aliasConfig = getAliasConfig(alias, {
47
47
  appDirectory: projectRoot,
48
48
  tsconfigPath
49
49
  });
50
50
  const {
51
51
  paths = {},
52
52
  absoluteBaseUrl = './'
53
- } = aliasOption;
53
+ } = aliasConfig;
54
54
  const tsPaths = Object.keys(paths).reduce((o, key) => {
55
55
  let tsPath = paths[key];
56
56
 
@@ -75,14 +75,16 @@ export const enableRegister = (projectRoot, config // eslint-disable-next-line c
75
75
  // for env.d.ts, https://www.npmjs.com/package/ts-node#missing-types
76
76
  files: true,
77
77
  transpileOnly: true,
78
- ignore: ['(?:^|/)node_modules/', `(?:^|/)${distPath}/bundles/`]
78
+ ignore: ['(?:^|/)node_modules/', `(?:^|/)${distPath}/`]
79
79
  });
80
80
  } else {
81
+ var _config$tools, _config$server;
82
+
81
83
  debug('use @babel/register');
82
84
  const babelConfig = resolveBabelConfig(projectRoot, _objectSpread(_objectSpread({}, config.source), {}, {
83
- babelConfig: config.tools.babel,
85
+ babelConfig: (_config$tools = config.tools) === null || _config$tools === void 0 ? void 0 : _config$tools.babel,
84
86
  server: {
85
- compiler: config.server.compiler
87
+ compiler: (_config$server = config.server) === null || _config$server === void 0 ? void 0 : _config$server.compiler
86
88
  }
87
89
  }), {
88
90
  tsconfigPath,
@@ -306,6 +306,8 @@ export class ModernDevServer extends ModernServer {
306
306
  }
307
307
 
308
308
  startWatcher() {
309
+ var _this$conf$server;
310
+
309
311
  const {
310
312
  pwd
311
313
  } = this;
@@ -313,7 +315,7 @@ export class ModernDevServer extends ModernServer {
313
315
  mock
314
316
  } = AGGRED_DIR;
315
317
  const defaultWatched = [`${mock}/**/*`, `${SERVER_DIR}/**/*`, `${API_DIR}/**`, `${SHARED_DIR}/**/*`];
316
- const watchOptions = mergeWatchOptions(this.conf.server.watchOptions);
318
+ const watchOptions = mergeWatchOptions((_this$conf$server = this.conf.server) === null || _this$conf$server === void 0 ? void 0 : _this$conf$server.watchOptions);
317
319
  const defaultWatchedPaths = defaultWatched.map(p => path.normalize(path.join(pwd, p)));
318
320
  const watcher = new Watcher();
319
321
  watcher.createDepTree(); // 监听文件变动,如果有变动则给 client,也就是 start 启动的插件发消息
@@ -58,14 +58,14 @@ const enableRegister = (projectRoot, config // eslint-disable-next-line consiste
58
58
  const {
59
59
  alias
60
60
  } = config.source;
61
- const aliasOption = (0, _utils.getAlias)(alias || {}, {
61
+ const aliasConfig = (0, _utils.getAliasConfig)(alias, {
62
62
  appDirectory: projectRoot,
63
63
  tsconfigPath
64
64
  });
65
65
  const {
66
66
  paths = {},
67
67
  absoluteBaseUrl = './'
68
- } = aliasOption;
68
+ } = aliasConfig;
69
69
  const tsPaths = Object.keys(paths).reduce((o, key) => {
70
70
  let tsPath = paths[key];
71
71
 
@@ -90,14 +90,16 @@ const enableRegister = (projectRoot, config // eslint-disable-next-line consiste
90
90
  // for env.d.ts, https://www.npmjs.com/package/ts-node#missing-types
91
91
  files: true,
92
92
  transpileOnly: true,
93
- ignore: ['(?:^|/)node_modules/', `(?:^|/)${distPath}/bundles/`]
93
+ ignore: ['(?:^|/)node_modules/', `(?:^|/)${distPath}/`]
94
94
  });
95
95
  } else {
96
+ var _config$tools, _config$server;
97
+
96
98
  debug('use @babel/register');
97
99
  const babelConfig = (0, _serverUtils.resolveBabelConfig)(projectRoot, _objectSpread(_objectSpread({}, config.source), {}, {
98
- babelConfig: config.tools.babel,
100
+ babelConfig: (_config$tools = config.tools) === null || _config$tools === void 0 ? void 0 : _config$tools.babel,
99
101
  server: {
100
- compiler: config.server.compiler
102
+ compiler: (_config$server = config.server) === null || _config$server === void 0 ? void 0 : _config$server.compiler
101
103
  }
102
104
  }), {
103
105
  tsconfigPath,
@@ -333,6 +333,8 @@ class ModernDevServer extends _prodServer.ModernServer {
333
333
  }
334
334
 
335
335
  startWatcher() {
336
+ var _this$conf$server;
337
+
336
338
  const {
337
339
  pwd
338
340
  } = this;
@@ -340,7 +342,7 @@ class ModernDevServer extends _prodServer.ModernServer {
340
342
  mock
341
343
  } = _prodServer.AGGRED_DIR;
342
344
  const defaultWatched = [`${mock}/**/*`, `${_utils.SERVER_DIR}/**/*`, `${_utils.API_DIR}/**`, `${_utils.SHARED_DIR}/**/*`];
343
- const watchOptions = (0, _watcher.mergeWatchOptions)(this.conf.server.watchOptions);
345
+ const watchOptions = (0, _watcher.mergeWatchOptions)((_this$conf$server = this.conf.server) === null || _this$conf$server === void 0 ? void 0 : _this$conf$server.watchOptions);
344
346
  const defaultWatchedPaths = defaultWatched.map(p => _path.default.normalize(_path.default.join(pwd, p)));
345
347
  const watcher = new _watcher.default();
346
348
  watcher.createDepTree(); // 监听文件变动,如果有变动则给 client,也就是 start 启动的插件发消息
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.21.2",
14
+ "version": "2.0.0-beta.0",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -30,10 +30,10 @@
30
30
  "dependencies": {
31
31
  "@babel/core": "^7.18.0",
32
32
  "@babel/register": "^7.17.7",
33
- "@modern-js/prod-server": "1.21.2",
34
- "@modern-js/server-utils": "1.21.2",
35
- "@modern-js/types": "1.21.2",
36
- "@modern-js/utils": "1.21.2",
33
+ "@modern-js/prod-server": "2.0.0-beta.0",
34
+ "@modern-js/server-utils": "2.0.0-beta.0",
35
+ "@modern-js/types": "2.0.0-beta.0",
36
+ "@modern-js/utils": "2.0.0-beta.0",
37
37
  "connect-history-api-fallback": "^2.0.0",
38
38
  "devcert": "^1.2.2",
39
39
  "minimatch": "^3.0.4",
@@ -41,10 +41,10 @@
41
41
  "ws": "^8.2.0"
42
42
  },
43
43
  "devDependencies": {
44
- "@modern-js/core": "1.21.2",
45
- "@modern-js/server-core": "1.21.2",
46
- "@scripts/build": "1.21.2",
47
- "@scripts/jest-config": "1.21.2",
44
+ "@modern-js/core": "2.0.0-beta.0",
45
+ "@modern-js/server-core": "2.0.0-beta.0",
46
+ "@scripts/build": "2.0.0-beta.0",
47
+ "@scripts/jest-config": "2.0.0-beta.0",
48
48
  "@types/connect-history-api-fallback": "^1.3.5",
49
49
  "@types/jest": "^27",
50
50
  "@types/minimatch": "^3.0.5",
@@ -72,33 +72,10 @@
72
72
  "registry": "https://registry.npmjs.org/",
73
73
  "access": "public"
74
74
  },
75
- "wireit": {
76
- "build": {
77
- "command": "modern build",
78
- "files": [
79
- "src/**/*",
80
- "tsconfig.json",
81
- "package.json"
82
- ],
83
- "output": [
84
- "dist/**/*"
85
- ]
86
- },
87
- "test": {
88
- "command": "jest",
89
- "files": [
90
- "src/**/*",
91
- "tsconfig.json",
92
- "package.json",
93
- "tests/**/*"
94
- ],
95
- "output": []
96
- }
97
- },
98
75
  "scripts": {
99
76
  "new": "modern new",
100
- "build": "wireit",
77
+ "build": "modern build",
101
78
  "dev": "modern build --watch",
102
- "test": "wireit"
79
+ "test": "jest"
103
80
  }
104
81
  }