@modern-js/core 2.0.0-beta.4 → 2.0.0-beta.7

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,126 @@
1
1
  # @modern-js/core
2
2
 
3
+ ## 2.0.0-beta.7
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
+ - edd1cfb1af: feat: modernjs Access builder compiler
14
+ feat: modernjs 接入 builder 构建
15
+
16
+ ### Patch Changes
17
+
18
+ - 8b8e1bb571: feat: support nested routes
19
+ feat: 支持嵌套路由
20
+ - Updated dependencies [edd1cfb1af]
21
+ - Updated dependencies [dda38c9c3e]
22
+ - Updated dependencies [bbe4c4ab64]
23
+ - @modern-js/utils@2.0.0-beta.7
24
+ - @modern-js/node-bundle-require@2.0.0-beta.7
25
+ - @modern-js/plugin@2.0.0-beta.7
26
+
27
+ ## 2.0.0-beta.6
28
+
29
+ ### Major Changes
30
+
31
+ - dda38c9c3e: chore: v2
32
+
33
+ ### Minor Changes
34
+
35
+ - c9e800d39a: feat: support React18 streaming SSR
36
+ feat: 支持 React18 流式 SSR
37
+ - 92f0eade39: feat:
38
+
39
+ 1. core: 增加 test 函数
40
+ 2. module plugins: 增加 `babel`, `mainField`, `target` 插件
41
+ 3. storybook: 修改部分逻辑并且增加 tspath webpack 插件
42
+ 4. 增加 designSystem 配置
43
+
44
+ feat:
45
+
46
+ 1. core: add test method
47
+ 2. module plugins: add `babel`, `mainField`, `target` plugin
48
+ 3. storybook: change some logic and add tspath webpack plugin
49
+ 4. add `designSystem` config
50
+
51
+ - edd1cfb1af: feat: modernjs Access builder compiler
52
+ feat: modernjs 接入 builder 构建
53
+ - d5a31df781: refactor: remove unbundle configs and types
54
+
55
+ refactor: 移除 unbundle 相关的配置项和类型定义
56
+
57
+ - b8494ef33b: feat: remove use plugin types restrict
58
+ feat: 移除使用 plugin 类型限制
59
+ - e4558a0bc4: feat:
60
+
61
+ 1. add `runBin` function
62
+ 2. config internal plugins constants in the app/module/doc tools
63
+ 3. add app/module/doc tools internal plugins
64
+
65
+ feat:
66
+
67
+ 1. 添加 `runBin` 函数
68
+ 2. 在 app/module/doc tools 里配置内部插件
69
+ 3. 增加 app/module/doc tools 使用的插件常量
70
+
71
+ ### Patch Changes
72
+
73
+ - 85edee888c: feat(app-tools): support tools.htmlPlugin config
74
+
75
+ feat(app-tools): 支持 tools.htmlPlugin 配置项
76
+
77
+ - b8bbe036c7: feat: change type logic
78
+ feat: 修改类型相关的逻辑
79
+ - 8b8e1bb571: feat: support nested routes
80
+ feat: 支持嵌套路由
81
+ - 3bbea92b2a: feat: support Hook、Middleware new API
82
+ feat: 支持 Hook、Middleware 的新 API
83
+ - b7a96c35fc: fix(app-tools): loose CLI init options after restart
84
+
85
+ fix(app-tools): 修复重启 CLI 后丢失 init options 的问题
86
+
87
+ - cce8ecee2d: fix: handle some `TODO` & `FIXME`, change some tests
88
+ fix: 处理一些 `TODO` 和 `FIXME`, 修改了一些 tests
89
+ - ea7cf06257: chore: bump webpack/babel-loader/postcss-loader/tsconfig-paths
90
+
91
+ chore: 升级 webpack/babel-loader/postcss-loader/tsconfig-paths 版本
92
+
93
+ - 14b712da84: fix: use consistent alias type and default value across packages
94
+
95
+ fix: 在各个包中使用一致的 alias 类型定义和默认值
96
+
97
+ - Updated dependencies [7879e8f711]
98
+ - Updated dependencies [6aca875011]
99
+ - Updated dependencies [2e6031955e]
100
+ - Updated dependencies [a2509bfbdb]
101
+ - Updated dependencies [7b7d12cf8f]
102
+ - Updated dependencies [7efeed4]
103
+ - Updated dependencies [92f0eade39]
104
+ - Updated dependencies [edd1cfb1af]
105
+ - Updated dependencies [cc971eabfc]
106
+ - Updated dependencies [5b9049f2e9]
107
+ - Updated dependencies [92004d1906]
108
+ - Updated dependencies [b8bbe036c7]
109
+ - Updated dependencies [d5a31df781]
110
+ - Updated dependencies [dda38c9c3e]
111
+ - Updated dependencies [3bbea92b2a]
112
+ - Updated dependencies [b710adb843]
113
+ - Updated dependencies [f179749375]
114
+ - Updated dependencies [ea7cf06257]
115
+ - Updated dependencies [bbe4c4ab64]
116
+ - Updated dependencies [e4558a0bc4]
117
+ - Updated dependencies [abf3421a75]
118
+ - Updated dependencies [543be9558e]
119
+ - Updated dependencies [14b712da84]
120
+ - @modern-js/utils@2.0.0-beta.6
121
+ - @modern-js/node-bundle-require@2.0.0-beta.6
122
+ - @modern-js/plugin@2.0.0-beta.6
123
+
3
124
  ## 2.0.0-beta.4
4
125
 
5
126
  ### Major Changes
package/dist/bin.js CHANGED
@@ -1,38 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- const utils_1 = require("@modern-js/utils");
5
- const _1 = require(".");
6
- const command = process.argv[2];
7
- if (!process.env.NODE_ENV) {
8
- if (['build', 'start', 'deploy', 'release'].includes(command)) {
9
- process.env.NODE_ENV = 'production';
10
- }
11
- else if (command === 'test') {
12
- process.env.NODE_ENV = 'test';
13
- }
14
- else {
15
- process.env.NODE_ENV = 'development';
16
- }
17
- }
18
- const { version } = require('../package.json');
19
- const cliParams = (0, utils_1.minimist)(process.argv.slice(2));
20
- const runOptions = {
21
- version,
22
- };
23
- /**
24
- * Commands that support specify config files
25
- * Some commands can't support this feature, such as `new`
26
- */
27
- const SUPPORT_CONFIG_PARAM_COMMANDS = [
28
- 'dev',
29
- 'build',
30
- 'deploy',
31
- 'start',
32
- 'inspect',
33
- ];
34
- const customConfigFile = cliParams.config || cliParams.c;
35
- if (SUPPORT_CONFIG_PARAM_COMMANDS.includes(command) && customConfigFile) {
36
- runOptions.configFile = customConfigFile;
37
- }
38
- _1.cli.run(runOptions);
4
+ const runBin_1 = require("./runBin");
5
+ (0, runBin_1.run)();
@@ -0,0 +1,2 @@
1
+ import { UserConfig } from '../types';
2
+ export declare function createDefaultConfig(): UserConfig;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createDefaultConfig = void 0;
4
+ function createDefaultConfig() {
5
+ return {
6
+ autoLoadPlugins: false,
7
+ };
8
+ }
9
+ exports.createDefaultConfig = createDefaultConfig;
@@ -29,6 +29,7 @@ const constants_1 = require("@modern-js/utils/constants");
29
29
  const patchSchema_1 = require("../schema/patchSchema");
30
30
  const repeatKeyWarning_1 = require("../utils/repeatKeyWarning");
31
31
  const mergeConfig_1 = require("../utils/mergeConfig");
32
+ const createDefaultConfig_1 = require("./createDefaultConfig");
32
33
  const debug = (0, utils_1.createDebugger)('resolve-config');
33
34
  const showAdditionalPropertiesError = async (error) => {
34
35
  if (error.keyword === 'additionalProperties' &&
@@ -84,7 +85,7 @@ loaded, configs, schemas, onSchemaError = showAdditionalPropertiesError) => {
84
85
  throw new Error(`Validate configuration error.`);
85
86
  }
86
87
  }
87
- const resolved = (0, mergeConfig_1.mergeConfig)([...configs, userConfig]);
88
+ const resolved = (0, mergeConfig_1.mergeConfig)([(0, createDefaultConfig_1.createDefaultConfig)(), ...configs, userConfig]);
88
89
  debug('resolved %o', resolved);
89
90
  return resolved;
90
91
  };
@@ -1,2 +1,3 @@
1
1
  export * from './createLoadedConfig';
2
2
  export * from './createResolvedConfig';
3
+ export * from './createDefaultConfig';
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./createLoadedConfig"), exports);
18
18
  __exportStar(require("./createResolvedConfig"), exports);
19
+ __exportStar(require("./createDefaultConfig"), exports);
package/dist/index.d.ts CHANGED
@@ -17,6 +17,7 @@ export interface CoreOptions {
17
17
  internalPlugins?: {
18
18
  cli?: InternalPlugins;
19
19
  server?: InternalPlugins;
20
+ autoLoad?: InternalPlugins;
20
21
  };
21
22
  transformPlugin?: TransformPlugin;
22
23
  onSchemaError?: (error: ErrorObject) => void;
@@ -27,6 +28,8 @@ export interface CoreOptions {
27
28
  sharedDir?: string;
28
29
  };
29
30
  toolsType?: ToolsType;
31
+ /** force the modern-js core auto register plugin exist in the package.json */
32
+ forceAutoLoadPlugins?: boolean;
30
33
  }
31
34
  export declare const mergeOptions: (options?: CoreOptions) => {
32
35
  cwd?: string | undefined;
@@ -37,6 +40,7 @@ export declare const mergeOptions: (options?: CoreOptions) => {
37
40
  internalPlugins?: {
38
41
  cli?: InternalPlugins | undefined;
39
42
  server?: InternalPlugins | undefined;
43
+ autoLoad?: InternalPlugins | undefined;
40
44
  } | undefined;
41
45
  transformPlugin?: TransformPlugin | undefined;
42
46
  onSchemaError?: ((error: ErrorObject) => void) | undefined;
@@ -47,6 +51,7 @@ export declare const mergeOptions: (options?: CoreOptions) => {
47
51
  sharedDir?: string | undefined;
48
52
  } | undefined;
49
53
  toolsType?: ToolsType | undefined;
54
+ forceAutoLoadPlugins?: boolean | undefined;
50
55
  };
51
56
  export declare const cli: {
52
57
  init: (options?: CoreOptions) => Promise<{
package/dist/index.js CHANGED
@@ -71,7 +71,7 @@ const createCli = () => {
71
71
  let hooksRunner;
72
72
  let initOptions;
73
73
  const init = async (options) => {
74
- var _a, _b, _c, _d;
74
+ var _a, _b, _c, _d, _e;
75
75
  manager_1.manager.clear();
76
76
  const mergedOptions = (0, exports.mergeOptions)(options);
77
77
  initOptions = mergedOptions;
@@ -84,6 +84,8 @@ const createCli = () => {
84
84
  const plugins = await (0, loadPlugins_1.loadPlugins)(appDirectory, loaded.config, {
85
85
  internalPlugins: (_c = mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.internalPlugins) === null || _c === void 0 ? void 0 : _c.cli,
86
86
  transformPlugin: mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.transformPlugin,
87
+ autoLoad: (_d = mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.internalPlugins) === null || _d === void 0 ? void 0 : _d.autoLoad,
88
+ forceAutoLoadPlugins: mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.forceAutoLoadPlugins,
87
89
  });
88
90
  plugins.forEach(plugin => plugin && manager_1.manager.usePlugin(plugin));
89
91
  const appContext = (0, context_1.initAppContext)({
@@ -93,7 +95,7 @@ const createCli = () => {
93
95
  configFile: loaded.filePath,
94
96
  options: mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.options,
95
97
  serverConfigFile: mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.serverConfigFile,
96
- serverInternalPlugins: ((_d = mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.internalPlugins) === null || _d === void 0 ? void 0 : _d.server) || utils_1.INTERNAL_SERVER_PLUGINS,
98
+ serverInternalPlugins: ((_e = mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.internalPlugins) === null || _e === void 0 ? void 0 : _e.server) || utils_1.INTERNAL_SERVER_PLUGINS,
97
99
  });
98
100
  context_1.ConfigContext.set(loaded.config);
99
101
  context_1.AppContext.set(appContext);
@@ -12,5 +12,7 @@ export declare const isOldPluginConfig: (config?: PluginConfig) => config is Old
12
12
  */
13
13
  export declare const loadPlugins: (appDirectory: string, userConfig: UserConfig, options?: {
14
14
  internalPlugins?: InternalPlugins;
15
+ autoLoad?: InternalPlugins;
15
16
  transformPlugin?: TransformPlugin;
17
+ forceAutoLoadPlugins?: boolean;
16
18
  }) => Promise<CliPlugin<{}, {}, {}, {}>[]>;
@@ -41,8 +41,13 @@ exports.isOldPluginConfig = isOldPluginConfig;
41
41
  const loadPlugins = async (appDirectory, userConfig, options = {}) => {
42
42
  const pluginConfig = userConfig.plugins;
43
43
  const plugins = [
44
- ...(0, utils_1.getInternalPlugins)(appDirectory, options.internalPlugins),
44
+ ...(options.forceAutoLoadPlugins || userConfig.autoLoadPlugins
45
+ ? (0, utils_1.getInternalPlugins)(appDirectory, options.internalPlugins)
46
+ : []),
45
47
  ...((0, exports.isOldPluginConfig)(pluginConfig) ? pluginConfig : []),
48
+ ...(options.autoLoad
49
+ ? (0, utils_1.getInternalPlugins)(appDirectory, options.autoLoad)
50
+ : []),
46
51
  ];
47
52
  const loadedPlugins = await Promise.all(plugins.map(plugin => {
48
53
  const loadedPlugin = resolveCliPlugin(plugin, userConfig, appDirectory, options.transformPlugin);
package/dist/runBin.js CHANGED
@@ -7,7 +7,7 @@ const _1 = require(".");
7
7
  const run = async (otherCoreOptions = {}, options = {}) => {
8
8
  const command = process.argv[2];
9
9
  if (!process.env.NODE_ENV) {
10
- if (['build', 'start', 'deploy', 'release'].includes(command)) {
10
+ if (['build', 'start', 'serve', 'deploy', 'release'].includes(command)) {
11
11
  process.env.NODE_ENV = 'production';
12
12
  }
13
13
  else if (command === 'test') {
@@ -31,6 +31,7 @@ const run = async (otherCoreOptions = {}, options = {}) => {
31
31
  'build',
32
32
  'deploy',
33
33
  'start',
34
+ 'serve',
34
35
  'inspect',
35
36
  ];
36
37
  const customConfigFile = cliParams.config || cliParams.c;
@@ -12,6 +12,12 @@ export declare type UserConfig<Extends extends {
12
12
  } = {}, ExtendNormalizedConfig extends Record<string, any> = {}> = {
13
13
  testing?: BaseTestingUserConfig<DropUndefined<Extends['userConfig']>['testing']>;
14
14
  plugins?: PluginConfig<any>;
15
+ /**
16
+ * auto load plugin that exist in the package.json
17
+ *
18
+ * **default: `false`**
19
+ */
20
+ autoLoadPlugins?: boolean;
15
21
  } & Omit<Extends['userConfig'], 'plugins' | 'testing'>;
16
22
  export declare type NormalizedConfig<Extends extends {
17
23
  hooks?: ExtendHooks;
@@ -23,6 +29,12 @@ export declare type NormalizedConfig<Extends extends {
23
29
  } = {}> = {
24
30
  plugins: PluginConfig<any>;
25
31
  testing: BaseTestingNormalizedConfig<DropUndefined<Extends['normalizedConfig']>['testing']>;
32
+ /**
33
+ * auto load plugin that exist in the package.json
34
+ *
35
+ * **default: `false`**
36
+ */
37
+ autoLoadPlugins: boolean;
26
38
  } & Omit<Extends['normalizedConfig'], 'plugins' | 'testing'>;
27
39
  export declare type LoadedConfig<Extends extends {
28
40
  hooks?: ExtendHooks;
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "modern",
11
11
  "modern.js"
12
12
  ],
13
- "version": "2.0.0-beta.4",
13
+ "version": "2.0.0-beta.7",
14
14
  "jsnext:source": "./src/index.ts",
15
15
  "types": "./dist/index.d.ts",
16
16
  "main": "./dist/index.js",
@@ -51,9 +51,9 @@
51
51
  }
52
52
  },
53
53
  "dependencies": {
54
- "@modern-js/node-bundle-require": "2.0.0-beta.4",
55
- "@modern-js/plugin": "2.0.0-beta.4",
56
- "@modern-js/utils": "2.0.0-beta.4"
54
+ "@modern-js/node-bundle-require": "2.0.0-beta.7",
55
+ "@modern-js/plugin": "2.0.0-beta.7",
56
+ "@modern-js/utils": "2.0.0-beta.7"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@jest/types": "^27.0.6",
@@ -72,11 +72,11 @@
72
72
  "terser-webpack-plugin": "^5.1.4",
73
73
  "typescript": "^4",
74
74
  "webpack": "^5.75.0",
75
- "@modern-js/builder-shared": "2.0.0-beta.4",
76
- "@modern-js/babel-preset-app": "2.0.0-beta.4",
77
- "@modern-js/types": "2.0.0-beta.4",
78
- "@scripts/build": "2.0.0-beta.4",
79
- "@scripts/jest-config": "2.0.0-beta.4"
75
+ "@modern-js/builder-shared": "2.0.0-beta.7",
76
+ "@modern-js/babel-preset-app": "2.0.0-beta.7",
77
+ "@modern-js/types": "2.0.0-beta.7",
78
+ "@scripts/jest-config": "2.0.0-beta.7",
79
+ "@scripts/build": "2.0.0-beta.7"
80
80
  },
81
81
  "sideEffects": false,
82
82
  "publishConfig": {