@modern-js/utils 2.0.0-beta.0 → 2.0.0-beta.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,107 @@
1
1
  # @modern-js/utils
2
2
 
3
+ ## 2.0.0-beta.2
4
+
5
+ ### Major Changes
6
+
7
+ - dda38c9c3e: chore: v2
8
+
9
+ ### Minor Changes
10
+
11
+ - 92f0ead: feat:
12
+
13
+ 1. core: 增加 test 函数
14
+ 2. module plugins: 增加 `babel`, `mainField`, `target` 插件
15
+ 3. storybook: 修改部分逻辑并且增加 tspath webpack 插件
16
+ 4. 增加 designSystem 配置
17
+
18
+ feat:
19
+
20
+ 1. core: add test method
21
+ 2. module plugins: add `babel`, `mainField`, `target` plugin
22
+ 3. storybook: change some logic and add tspath webpack plugin
23
+ 4. add `designSystem` config
24
+
25
+ - edd1cfb1af: feat: modernjs Access builder compiler
26
+ feat: modernjs 接入 builder 构建
27
+ - d5a31df781: refactor: remove unbundle configs and types
28
+
29
+ refactor: 移除 unbundle 相关的配置项和类型定义
30
+
31
+ - 543be9558e: feat: compile server loader and support handle loader request
32
+ feat: 编译 server loader 并支持处理 loader 的请求
33
+
34
+ ### Patch Changes
35
+
36
+ - cc971eabfc: refactor: move server plugin load logic in `@modern-js/core`
37
+ refactor:移除在 `@modern-js/core` 中的 server 插件加载逻辑
38
+ - 5b9049f2e9: feat: inject async js chunk when streaming ssr
39
+ feat: streaming ssr 时, 注入 async 类型的 js chunk
40
+ - 92004d1: feat: support load chunks parallelly
41
+ feat: 支持并行加载 chunks
42
+ - b8bbe036c7: feat: change type logic
43
+ feat: 修改类型相关的逻辑
44
+ - 3bbea92b2a: feat: support Hook、Middleware new API
45
+ feat: 支持 Hook、Middleware 的新 API
46
+ - abf3421a75: fix(dev-server): isDepsExists add non pkgPath judege
47
+
48
+ 修复: isDepsExists 方法添加 package.json 不存在的兜底
49
+
50
+ - 14b712da84: fix: use consistent alias type and default value across packages
51
+
52
+ fix: 在各个包中使用一致的 alias 类型定义和默认值
53
+
54
+ ## 2.0.0-beta.1
55
+
56
+ ### Major Changes
57
+
58
+ - dda38c9: chore: v2
59
+
60
+ ### Minor Changes
61
+
62
+ - 92f0ead: feat:
63
+
64
+ 1. core: 增加 test 函数
65
+ 2. module plugins: 增加 `babel`, `mainField`, `target` 插件
66
+ 3. storybook: 修改部分逻辑并且增加 tspath webpack 插件
67
+ 4. 增加 designSystem 配置
68
+
69
+ feat:
70
+
71
+ 1. core: add test method
72
+ 2. module plugins: add `babel`, `mainField`, `target` plugin
73
+ 3. storybook: change some logic and add tspath webpack plugin
74
+ 4. add `designSystem` config
75
+
76
+ - edd1cfb1af: feat: modernjs Access builder compiler
77
+ feat: modernjs 接入 builder 构建
78
+ - d5a31df781: refactor: remove unbundle configs and types
79
+
80
+ refactor: 移除 unbundle 相关的配置项和类型定义
81
+
82
+ - 543be9558e: feat: compile server loader and support handle loader request
83
+ feat: 编译 server loader 并支持处理 loader 的请求
84
+
85
+ ### Patch Changes
86
+
87
+ - cc971eabfc: refactor: move server plugin load logic in `@modern-js/core`
88
+ refactor:移除在 `@modern-js/core` 中的 server 插件加载逻辑
89
+ - 5b9049f: feat: inject async js chunk when streaming ssr
90
+ feat: streaming ssr 时, 注入 async 类型的 js chunk
91
+ - 92004d1: feat: support load chunks parallelly
92
+ feat: 支持并行加载 chunks
93
+ - b8bbe036c7: feat: change type logic
94
+ feat: 修改类型相关的逻辑
95
+ - 3bbea92b2a: feat: support Hook、Middleware new API
96
+ feat: 支持 Hook、Middleware 的新 API
97
+ - abf3421: fix(dev-server): isDepsExists add non pkgPath judege
98
+
99
+ 修复: isDepsExists 方法添加 package.json 不存在的兜底
100
+
101
+ - 14b712d: fix: use consistent alias type and default value across packages
102
+
103
+ fix: 在各个包中使用一致的 alias 类型定义和默认值
104
+
3
105
  ## 2.0.0-beta.0
4
106
 
5
107
  ### Major Changes
@@ -4,6 +4,7 @@
4
4
  * @returns module export object.
5
5
  */
6
6
  export declare const compatRequire: (filePath: string, interop?: boolean) => any;
7
+ export declare const dynamicImport: Function;
7
8
  export declare const requireExistModule: (filename: string, opt?: {
8
9
  extensions?: string[];
9
10
  interop?: boolean;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cleanRequireCache = exports.requireExistModule = exports.compatRequire = void 0;
3
+ exports.cleanRequireCache = exports.requireExistModule = exports.dynamicImport = exports.compatRequire = void 0;
4
4
  const findExists_1 = require("./findExists");
5
5
  /**
6
6
  * Require function compatible with esm and cjs module.
@@ -13,6 +13,9 @@ const compatRequire = (filePath, interop = true) => {
13
13
  return rtnESMDefault ? mod.default : mod;
14
14
  };
15
15
  exports.compatRequire = compatRequire;
16
+ // Avoid `import` to be tranpiled to `require` by babel/tsc/rollup
17
+ // eslint-disable-next-line @typescript-eslint/no-implied-eval, no-new-func
18
+ exports.dynamicImport = new Function('modulePath', 'return import(modulePath)');
16
19
  const requireExistModule = (filename, opt) => {
17
20
  const final = {
18
21
  extensions: ['.ts', '.js'],
@@ -50,6 +50,14 @@ export declare const OUTPUT_CONFIG_FILE = "modern.config.json";
50
50
  * Default server config basename
51
51
  */
52
52
  export declare const DEFAULT_SERVER_CONFIG = "modern.server-runtime.config";
53
+ /**
54
+ * Routes manifest filename
55
+ */
56
+ export declare const ROUTE_MINIFEST_FILE = "routes-manifest.json";
57
+ /**
58
+ * Property mounted on window that describes route manifest
59
+ */
60
+ export declare const ROUTE_MANIFEST = "_MODERNJS_ROUTE_MANIFEST";
53
61
  /**
54
62
  * Internal plugins that work as soon as they are installed.
55
63
  */
package/dist/constants.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PLUGIN_SCHEMAS = exports.INTERNAL_SERVER_PLUGINS = exports.INTERNAL_CLI_PLUGINS = exports.DEFAULT_SERVER_CONFIG = exports.OUTPUT_CONFIG_FILE = exports.CONFIG_FILE_EXTENSIONS = exports.CONFIG_CACHE_DIR = exports.SHARED_DIR = exports.SERVER_DIR = exports.API_DIR = exports.LOADABLE_STATS_FILE = exports.SERVER_RENDER_FUNCTION_NAME = exports.ENTRY_NAME_PATTERN = exports.SERVER_BUNDLE_DIRECTORY = exports.LAUNCH_EDITOR_ENDPOINT = exports.MAIN_ENTRY_NAME = exports.ROUTE_SPEC_FILE = exports.HMR_SOCK_PATH = void 0;
3
+ exports.PLUGIN_SCHEMAS = exports.INTERNAL_SERVER_PLUGINS = exports.INTERNAL_CLI_PLUGINS = exports.ROUTE_MANIFEST = exports.ROUTE_MINIFEST_FILE = exports.DEFAULT_SERVER_CONFIG = exports.OUTPUT_CONFIG_FILE = exports.CONFIG_FILE_EXTENSIONS = exports.CONFIG_CACHE_DIR = exports.SHARED_DIR = exports.SERVER_DIR = exports.API_DIR = exports.LOADABLE_STATS_FILE = exports.SERVER_RENDER_FUNCTION_NAME = exports.ENTRY_NAME_PATTERN = exports.SERVER_BUNDLE_DIRECTORY = exports.LAUNCH_EDITOR_ENDPOINT = exports.MAIN_ENTRY_NAME = exports.ROUTE_SPEC_FILE = exports.HMR_SOCK_PATH = void 0;
4
4
  /**
5
5
  * hmr socket connect path
6
6
  */
@@ -52,6 +52,14 @@ exports.OUTPUT_CONFIG_FILE = 'modern.config.json';
52
52
  * Default server config basename
53
53
  */
54
54
  exports.DEFAULT_SERVER_CONFIG = 'modern.server-runtime.config';
55
+ /**
56
+ * Routes manifest filename
57
+ */
58
+ exports.ROUTE_MINIFEST_FILE = 'routes-manifest.json';
59
+ /**
60
+ * Property mounted on window that describes route manifest
61
+ */
62
+ exports.ROUTE_MANIFEST = `_MODERNJS_ROUTE_MANIFEST`;
55
63
  /**
56
64
  * Internal plugins that work as soon as they are installed.
57
65
  */
@@ -60,6 +68,7 @@ exports.INTERNAL_CLI_PLUGINS = {
60
68
  '@modern-js/monorepo-tools': '@modern-js/monorepo-tools/cli',
61
69
  '@modern-js/module-tools': '@modern-js/module-tools/cli',
62
70
  '@modern-js/module-tools-v2': '@modern-js/module-tools-v2',
71
+ '@modern-js/doc-tools': '@modern-js/doc-tools',
63
72
  '@modern-js/runtime': '@modern-js/runtime/cli',
64
73
  '@modern-js/plugin-proxy': '@modern-js/plugin-proxy/cli',
65
74
  '@modern-js/plugin-ssg': '@modern-js/plugin-ssg/cli',
@@ -166,6 +175,10 @@ exports.PLUGIN_SCHEMAS = {
166
175
  target: 'source.designSystem.supportStyledComponents',
167
176
  schema: { type: ['boolean'] },
168
177
  },
178
+ {
179
+ target: 'designSystem',
180
+ schema: { typeof: ['object'] },
181
+ },
169
182
  ],
170
183
  '@modern-js/plugin-router': [
171
184
  {
package/dist/format.d.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  * https://github.com/facebook/create-react-app/blob/master/LICENSE
7
7
  */
8
8
  import type { StatsCompilation } from 'webpack';
9
- declare function formatWebpackMessages(json?: StatsCompilation): {
9
+ declare function formatWebpackMessages(json?: Pick<StatsCompilation, 'errors' | 'warnings'>): {
10
10
  errors: string[];
11
11
  warnings: string[];
12
12
  };
package/dist/routes.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export declare const getPathWithoutExt: (filename: string) => string;
2
- export declare const getRouteId: (componentPath: string, routesDir: string) => string;
2
+ export declare const getRouteId: (componentPath: string, routesDir: string, entryName: string) => string;
package/dist/routes.js CHANGED
@@ -11,9 +11,10 @@ const getPathWithoutExt = (filename) => {
11
11
  return filename.slice(0, -extname.length);
12
12
  };
13
13
  exports.getPathWithoutExt = getPathWithoutExt;
14
- const getRouteId = (componentPath, routesDir) => {
14
+ const getRouteId = (componentPath, routesDir, entryName) => {
15
15
  const relativePath = (0, path_2.normalizeToPosixPath)(path_1.default.relative(routesDir, componentPath));
16
- const id = (0, exports.getPathWithoutExt)(relativePath);
16
+ const pathWithoutExt = (0, exports.getPathWithoutExt)(relativePath);
17
+ const id = `${entryName}_${pathWithoutExt}`;
17
18
  return id;
18
19
  };
19
20
  exports.getRouteId = getRouteId;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.0.0-beta.0",
14
+ "version": "2.0.0-beta.2",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/index.d.ts",
17
17
  "main": "./dist/index.js",
@@ -129,18 +129,18 @@
129
129
  "lodash": "^4.17.21"
130
130
  },
131
131
  "devDependencies": {
132
- "@modern-js/types": "2.0.0-beta.0",
133
- "@scripts/build": "2.0.0-beta.0",
134
- "@scripts/jest-config": "2.0.0-beta.0",
135
132
  "@types/jest": "^27",
136
133
  "@types/node": "^14",
137
134
  "typescript": "^4",
138
135
  "jest": "^27",
139
- "webpack": "^5.74.0"
136
+ "webpack": "^5.74.0",
137
+ "@modern-js/types": "2.0.0-beta.2",
138
+ "@scripts/build": "2.0.0-beta.2",
139
+ "@scripts/jest-config": "2.0.0-beta.2"
140
140
  },
141
141
  "sideEffects": false,
142
142
  "scripts": {
143
- "new": "modern new",
143
+ "new": "modern-lib new",
144
144
  "dev": "tsc --watch",
145
145
  "build": "tsc",
146
146
  "test": "jest --passWithNoTests"