@modern-js/server-core 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.
Files changed (35) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/dist/js/modern/index.js +2 -1
  3. package/dist/js/modern/loadPlugins.js +0 -4
  4. package/dist/js/modern/plugin.js +15 -6
  5. package/dist/js/modern/types/config/bff.js +0 -0
  6. package/dist/js/modern/types/config/html.js +0 -0
  7. package/dist/js/modern/types/config/index.js +7 -0
  8. package/dist/js/modern/types/config/output.js +0 -0
  9. package/dist/js/modern/types/config/server.js +0 -0
  10. package/dist/js/modern/types/config/share.js +0 -0
  11. package/dist/js/modern/types/config/source.js +0 -0
  12. package/dist/js/modern/types/config/tools.js +1 -0
  13. package/dist/js/node/index.js +11 -6
  14. package/dist/js/node/loadPlugins.js +0 -7
  15. package/dist/js/node/plugin.js +15 -16
  16. package/dist/js/node/types/config/bff.js +0 -0
  17. package/dist/js/node/types/config/html.js +0 -0
  18. package/dist/js/node/types/config/index.js +71 -0
  19. package/dist/js/node/types/config/output.js +0 -0
  20. package/dist/js/node/types/config/server.js +0 -0
  21. package/dist/js/node/types/config/share.js +0 -0
  22. package/dist/js/node/types/config/source.js +0 -0
  23. package/dist/js/node/types/config/tools.js +5 -0
  24. package/dist/types/index.d.ts +2 -1
  25. package/dist/types/loadPlugins.d.ts +5 -5
  26. package/dist/types/plugin.d.ts +2 -21
  27. package/dist/types/types/config/bff.d.ts +5 -0
  28. package/dist/types/types/config/html.d.ts +5 -0
  29. package/dist/types/types/config/index.d.ts +34 -0
  30. package/dist/types/types/config/output.d.ts +17 -0
  31. package/dist/types/types/config/server.d.ts +27 -0
  32. package/dist/types/types/config/share.d.ts +3 -0
  33. package/dist/types/types/config/source.d.ts +15 -0
  34. package/dist/types/types/config/tools.d.ts +9 -0
  35. package/package.json +11 -11
package/CHANGELOG.md CHANGED
@@ -1,5 +1,71 @@
1
1
  # @modern-js/server-plugin
2
2
 
3
+ ## 2.0.0-beta.2
4
+
5
+ ### Major Changes
6
+
7
+ - dda38c9c3e: chore: v2
8
+
9
+ ### Minor Changes
10
+
11
+ - 543be9558e: feat: compile server loader and support handle loader request
12
+ feat: 编译 server loader 并支持处理 loader 的请求
13
+
14
+ ### Patch Changes
15
+
16
+ - 15bf09d9c8: feat: support completely custom server, export render() api for render single page
17
+ feat: 支持完全自定义 Server,导出 render() 方法用来渲染单个页面
18
+ - cc971eabfc: refactor: move server plugin load logic in `@modern-js/core`
19
+ refactor:移除在 `@modern-js/core` 中的 server 插件加载逻辑
20
+ - Updated dependencies [92f0ead]
21
+ - Updated dependencies [edd1cfb1af]
22
+ - Updated dependencies [cc971eabfc]
23
+ - Updated dependencies [5b9049f2e9]
24
+ - Updated dependencies [92004d1]
25
+ - Updated dependencies [b8bbe036c7]
26
+ - Updated dependencies [d5a31df781]
27
+ - Updated dependencies [dda38c9c3e]
28
+ - Updated dependencies [3bbea92b2a]
29
+ - Updated dependencies [f179749]
30
+ - Updated dependencies [abf3421a75]
31
+ - Updated dependencies [543be9558e]
32
+ - Updated dependencies [14b712da84]
33
+ - @modern-js/utils@2.0.0-beta.2
34
+ - @modern-js/plugin@2.0.0-beta.2
35
+
36
+ ## 2.0.0-beta.1
37
+
38
+ ### Major Changes
39
+
40
+ - dda38c9: chore: v2
41
+
42
+ ### Minor Changes
43
+
44
+ - 543be9558e: feat: compile server loader and support handle loader request
45
+ feat: 编译 server loader 并支持处理 loader 的请求
46
+
47
+ ### Patch Changes
48
+
49
+ - 15bf09d9c8: feat: support completely custom server, export render() api for render single page
50
+ feat: 支持完全自定义 Server,导出 render() 方法用来渲染单个页面
51
+ - cc971eabfc: refactor: move server plugin load logic in `@modern-js/core`
52
+ refactor:移除在 `@modern-js/core` 中的 server 插件加载逻辑
53
+ - Updated dependencies [92f0ead]
54
+ - Updated dependencies [edd1cfb1af]
55
+ - Updated dependencies [cc971eabfc]
56
+ - Updated dependencies [5b9049f]
57
+ - Updated dependencies [92004d1]
58
+ - Updated dependencies [b8bbe036c7]
59
+ - Updated dependencies [d5a31df781]
60
+ - Updated dependencies [dda38c9]
61
+ - Updated dependencies [3bbea92b2a]
62
+ - Updated dependencies [f179749]
63
+ - Updated dependencies [abf3421]
64
+ - Updated dependencies [543be9558e]
65
+ - Updated dependencies [14b712d]
66
+ - @modern-js/utils@2.0.0-beta.1
67
+ - @modern-js/plugin@2.0.0-beta.1
68
+
3
69
  ## 2.0.0-beta.0
4
70
 
5
71
  ### Major Changes
@@ -1,3 +1,4 @@
1
1
  export * from "./plugin";
2
2
  export * from '@modern-js/plugin';
3
- export * from "./loadPlugins";
3
+ export * from "./loadPlugins";
4
+ export * from "./types/config";
@@ -1,15 +1,12 @@
1
1
  import { compatRequire, getInternalPlugins, tryResolve } from '@modern-js/utils';
2
2
  import { createPlugin } from "./plugin";
3
-
4
3
  const resolvePlugin = (p, appDirectory) => {
5
4
  const isPluginInstance = typeof p !== 'string';
6
-
7
5
  if (isPluginInstance) {
8
6
  return {
9
7
  module: createPlugin(p.setup, p)
10
8
  };
11
9
  }
12
-
13
10
  const pluginPath = tryResolve(p, appDirectory);
14
11
  const module = compatRequire(pluginPath);
15
12
  const pluginInstance = module();
@@ -17,7 +14,6 @@ const resolvePlugin = (p, appDirectory) => {
17
14
  module: createPlugin(pluginInstance.setup, pluginInstance)
18
15
  };
19
16
  };
20
-
21
17
  export const loadPlugins = (appDirectory, configPlugins, options) => {
22
18
  const loadedPlugins = getInternalPlugins(appDirectory, options.internalPlugins);
23
19
  return [...loadedPlugins, ...configPlugins].map(plugin => {
@@ -1,7 +1,8 @@
1
1
  import { createContext, createAsyncManager, createAsyncPipeline, createAsyncWaterfall, createParallelWorkflow, createWaterfall } from '@modern-js/plugin';
2
2
  // collect all middleware register in server plugins
3
- const gather = createParallelWorkflow(); // config
3
+ const gather = createParallelWorkflow();
4
4
 
5
+ // config
5
6
  const config = createWaterfall();
6
7
  const prepare = createWaterfall();
7
8
  const preparebeforeRouteHandler = createAsyncPipeline();
@@ -10,7 +11,9 @@ const prepareApiServer = createAsyncPipeline();
10
11
  const onApiChange = createWaterfall();
11
12
  const beforeDevServer = createParallelWorkflow();
12
13
  const setupCompiler = createParallelWorkflow();
13
- const afterDevServer = createParallelWorkflow(); // TODO FIXME
14
+ const afterDevServer = createParallelWorkflow();
15
+
16
+ // TODO FIXME
14
17
 
15
18
  const beforeRouteSet = createAsyncPipeline();
16
19
  const afterRouteSet = createAsyncPipeline();
@@ -23,9 +26,13 @@ const extendSSRContext = createAsyncWaterfall();
23
26
  const extendContext = createAsyncPipeline();
24
27
  const handleError = createParallelWorkflow();
25
28
  const beforeMatch = createAsyncPipeline();
26
- const afterMatch = createAsyncPipeline(); // TODO FIXME
29
+ const afterMatch = createAsyncPipeline();
30
+
31
+ // TODO FIXME
32
+
33
+ const prefetch = createParallelWorkflow();
27
34
 
28
- const prefetch = createParallelWorkflow(); // TODO FIXME
35
+ // TODO FIXME
29
36
 
30
37
  const renderToString = createAsyncPipeline();
31
38
  const beforeRender = createAsyncPipeline();
@@ -36,15 +43,15 @@ const reset = createParallelWorkflow();
36
43
  export const AppContext = createContext({});
37
44
  export const setAppContext = value => AppContext.set(value);
38
45
  export const ConfigContext = createContext({});
46
+
39
47
  /**
40
48
  * Get original content of user config.
41
49
  */
42
-
43
50
  export const useConfigContext = () => ConfigContext.use().value;
51
+
44
52
  /**
45
53
  * Get app context, including directories, plugins and some static infos.
46
54
  */
47
-
48
55
  export const useAppContext = () => AppContext.use().value;
49
56
  const pluginAPI = {
50
57
  useAppContext,
@@ -84,10 +91,12 @@ const serverHooks = {
84
91
  afterSend,
85
92
  reset
86
93
  };
94
+
87
95
  /** All hooks of server plugin. */
88
96
 
89
97
  export const createServerManager = () => createAsyncManager(serverHooks, pluginAPI);
90
98
  export const serverManager = createServerManager();
99
+
91
100
  /** Plugin options of a server plugin. */
92
101
 
93
102
  export const {
File without changes
File without changes
@@ -0,0 +1,7 @@
1
+ export * from "./bff";
2
+ export * from "./html";
3
+ export * from "./output";
4
+ export * from "./server";
5
+ export * from "./source";
6
+ export * from "./tools";
7
+ export {};
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1 @@
1
+ export {};
@@ -3,9 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
6
  var _plugin = require("./plugin");
8
-
9
7
  Object.keys(_plugin).forEach(function (key) {
10
8
  if (key === "default" || key === "__esModule") return;
11
9
  if (key in exports && exports[key] === _plugin[key]) return;
@@ -16,9 +14,7 @@ Object.keys(_plugin).forEach(function (key) {
16
14
  }
17
15
  });
18
16
  });
19
-
20
17
  var _plugin2 = require("@modern-js/plugin");
21
-
22
18
  Object.keys(_plugin2).forEach(function (key) {
23
19
  if (key === "default" || key === "__esModule") return;
24
20
  if (key in exports && exports[key] === _plugin2[key]) return;
@@ -29,9 +25,7 @@ Object.keys(_plugin2).forEach(function (key) {
29
25
  }
30
26
  });
31
27
  });
32
-
33
28
  var _loadPlugins = require("./loadPlugins");
34
-
35
29
  Object.keys(_loadPlugins).forEach(function (key) {
36
30
  if (key === "default" || key === "__esModule") return;
37
31
  if (key in exports && exports[key] === _loadPlugins[key]) return;
@@ -41,4 +35,15 @@ Object.keys(_loadPlugins).forEach(function (key) {
41
35
  return _loadPlugins[key];
42
36
  }
43
37
  });
38
+ });
39
+ var _config = require("./types/config");
40
+ Object.keys(_config).forEach(function (key) {
41
+ if (key === "default" || key === "__esModule") return;
42
+ if (key in exports && exports[key] === _config[key]) return;
43
+ Object.defineProperty(exports, key, {
44
+ enumerable: true,
45
+ get: function () {
46
+ return _config[key];
47
+ }
48
+ });
44
49
  });
@@ -4,20 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.loadPlugins = void 0;
7
-
8
7
  var _utils = require("@modern-js/utils");
9
-
10
8
  var _plugin = require("./plugin");
11
-
12
9
  const resolvePlugin = (p, appDirectory) => {
13
10
  const isPluginInstance = typeof p !== 'string';
14
-
15
11
  if (isPluginInstance) {
16
12
  return {
17
13
  module: (0, _plugin.createPlugin)(p.setup, p)
18
14
  };
19
15
  }
20
-
21
16
  const pluginPath = (0, _utils.tryResolve)(p, appDirectory);
22
17
  const module = (0, _utils.compatRequire)(pluginPath);
23
18
  const pluginInstance = module();
@@ -25,7 +20,6 @@ const resolvePlugin = (p, appDirectory) => {
25
20
  module: (0, _plugin.createPlugin)(pluginInstance.setup, pluginInstance)
26
21
  };
27
22
  };
28
-
29
23
  const loadPlugins = (appDirectory, configPlugins, options) => {
30
24
  const loadedPlugins = (0, _utils.getInternalPlugins)(appDirectory, options.internalPlugins);
31
25
  return [...loadedPlugins, ...configPlugins].map(plugin => {
@@ -35,5 +29,4 @@ const loadPlugins = (appDirectory, configPlugins, options) => {
35
29
  return module;
36
30
  });
37
31
  };
38
-
39
32
  exports.loadPlugins = loadPlugins;
@@ -4,12 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.useConfigContext = exports.useAppContext = exports.setAppContext = exports.serverManager = exports.createServerManager = exports.createPlugin = exports.ConfigContext = exports.AppContext = void 0;
7
-
8
7
  var _plugin = require("@modern-js/plugin");
9
-
10
8
  // collect all middleware register in server plugins
11
- const gather = (0, _plugin.createParallelWorkflow)(); // config
9
+ const gather = (0, _plugin.createParallelWorkflow)();
12
10
 
11
+ // config
13
12
  const config = (0, _plugin.createWaterfall)();
14
13
  const prepare = (0, _plugin.createWaterfall)();
15
14
  const preparebeforeRouteHandler = (0, _plugin.createAsyncPipeline)();
@@ -18,7 +17,9 @@ const prepareApiServer = (0, _plugin.createAsyncPipeline)();
18
17
  const onApiChange = (0, _plugin.createWaterfall)();
19
18
  const beforeDevServer = (0, _plugin.createParallelWorkflow)();
20
19
  const setupCompiler = (0, _plugin.createParallelWorkflow)();
21
- const afterDevServer = (0, _plugin.createParallelWorkflow)(); // TODO FIXME
20
+ const afterDevServer = (0, _plugin.createParallelWorkflow)();
21
+
22
+ // TODO FIXME
22
23
 
23
24
  const beforeRouteSet = (0, _plugin.createAsyncPipeline)();
24
25
  const afterRouteSet = (0, _plugin.createAsyncPipeline)();
@@ -31,9 +32,13 @@ const extendSSRContext = (0, _plugin.createAsyncWaterfall)();
31
32
  const extendContext = (0, _plugin.createAsyncPipeline)();
32
33
  const handleError = (0, _plugin.createParallelWorkflow)();
33
34
  const beforeMatch = (0, _plugin.createAsyncPipeline)();
34
- const afterMatch = (0, _plugin.createAsyncPipeline)(); // TODO FIXME
35
+ const afterMatch = (0, _plugin.createAsyncPipeline)();
36
+
37
+ // TODO FIXME
38
+
39
+ const prefetch = (0, _plugin.createParallelWorkflow)();
35
40
 
36
- const prefetch = (0, _plugin.createParallelWorkflow)(); // TODO FIXME
41
+ // TODO FIXME
37
42
 
38
43
  const renderToString = (0, _plugin.createAsyncPipeline)();
39
44
  const beforeRender = (0, _plugin.createAsyncPipeline)();
@@ -43,27 +48,21 @@ const afterSend = (0, _plugin.createParallelWorkflow)();
43
48
  const reset = (0, _plugin.createParallelWorkflow)();
44
49
  const AppContext = (0, _plugin.createContext)({});
45
50
  exports.AppContext = AppContext;
46
-
47
51
  const setAppContext = value => AppContext.set(value);
48
-
49
52
  exports.setAppContext = setAppContext;
50
53
  const ConfigContext = (0, _plugin.createContext)({});
54
+
51
55
  /**
52
56
  * Get original content of user config.
53
57
  */
54
-
55
58
  exports.ConfigContext = ConfigContext;
56
-
57
59
  const useConfigContext = () => ConfigContext.use().value;
60
+
58
61
  /**
59
62
  * Get app context, including directories, plugins and some static infos.
60
63
  */
61
-
62
-
63
64
  exports.useConfigContext = useConfigContext;
64
-
65
65
  const useAppContext = () => AppContext.use().value;
66
-
67
66
  exports.useAppContext = useAppContext;
68
67
  const pluginAPI = {
69
68
  useAppContext,
@@ -103,14 +102,14 @@ const serverHooks = {
103
102
  afterSend,
104
103
  reset
105
104
  };
105
+
106
106
  /** All hooks of server plugin. */
107
107
 
108
108
  const createServerManager = () => (0, _plugin.createAsyncManager)(serverHooks, pluginAPI);
109
-
110
109
  exports.createServerManager = createServerManager;
111
110
  const serverManager = createServerManager();
112
- /** Plugin options of a server plugin. */
113
111
 
112
+ /** Plugin options of a server plugin. */
114
113
  exports.serverManager = serverManager;
115
114
  const {
116
115
  createPlugin
File without changes
File without changes
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _bff = require("./bff");
7
+ Object.keys(_bff).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _bff[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _bff[key];
14
+ }
15
+ });
16
+ });
17
+ var _html = require("./html");
18
+ Object.keys(_html).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _html[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _html[key];
25
+ }
26
+ });
27
+ });
28
+ var _output = require("./output");
29
+ Object.keys(_output).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _output[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _output[key];
36
+ }
37
+ });
38
+ });
39
+ var _server = require("./server");
40
+ Object.keys(_server).forEach(function (key) {
41
+ if (key === "default" || key === "__esModule") return;
42
+ if (key in exports && exports[key] === _server[key]) return;
43
+ Object.defineProperty(exports, key, {
44
+ enumerable: true,
45
+ get: function () {
46
+ return _server[key];
47
+ }
48
+ });
49
+ });
50
+ var _source = require("./source");
51
+ Object.keys(_source).forEach(function (key) {
52
+ if (key === "default" || key === "__esModule") return;
53
+ if (key in exports && exports[key] === _source[key]) return;
54
+ Object.defineProperty(exports, key, {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _source[key];
58
+ }
59
+ });
60
+ });
61
+ var _tools = require("./tools");
62
+ Object.keys(_tools).forEach(function (key) {
63
+ if (key === "default" || key === "__esModule") return;
64
+ if (key in exports && exports[key] === _tools[key]) return;
65
+ Object.defineProperty(exports, key, {
66
+ enumerable: true,
67
+ get: function () {
68
+ return _tools[key];
69
+ }
70
+ });
71
+ });
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -1,3 +1,4 @@
1
1
  export * from './plugin';
2
2
  export * from '@modern-js/plugin';
3
- export * from './loadPlugins';
3
+ export * from './loadPlugins';
4
+ export * from './types/config';
@@ -19,13 +19,13 @@ export declare const loadPlugins: (appDirectory: string, configPlugins: ServerPl
19
19
  filename: string;
20
20
  event: "add" | "unlink" | "change";
21
21
  }[]>;
22
- beforeDevServer: import("@modern-js/plugin").ParallelWorkflow<import("./plugin").ServerOptions, any>;
22
+ beforeDevServer: import("@modern-js/plugin").ParallelWorkflow<import(".").ServerOptions, any>;
23
23
  setupCompiler: import("@modern-js/plugin").ParallelWorkflow<Record<string, unknown>, any[]>;
24
- afterDevServer: import("@modern-js/plugin").ParallelWorkflow<import("./plugin").ServerOptions, any>;
24
+ afterDevServer: import("@modern-js/plugin").ParallelWorkflow<import(".").ServerOptions, any>;
25
25
  beforeRouteSet: import("@modern-js/plugin").AsyncPipeline<import("./plugin").Route[], import("./plugin").Route[]>;
26
26
  afterRouteSet: import("@modern-js/plugin").AsyncPipeline<unknown, unknown>;
27
- beforeProdServer: import("@modern-js/plugin").ParallelWorkflow<import("./plugin").ServerOptions, any>;
28
- afterProdServer: import("@modern-js/plugin").ParallelWorkflow<import("./plugin").ServerOptions, any>;
27
+ beforeProdServer: import("@modern-js/plugin").ParallelWorkflow<import(".").ServerOptions, any>;
28
+ afterProdServer: import("@modern-js/plugin").ParallelWorkflow<import(".").ServerOptions, any>;
29
29
  listen: import("@modern-js/plugin").ParallelWorkflow<{
30
30
  ip: string;
31
31
  port: number;
@@ -59,6 +59,6 @@ export declare const loadPlugins: (appDirectory: string, configPlugins: ServerPl
59
59
  reset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
60
60
  }, {
61
61
  useAppContext: () => import("@modern-js/types").ISAppContext;
62
- useConfigContext: () => import("@modern-js/core").UserConfig;
62
+ useConfigContext: () => import(".").UserConfig;
63
63
  setAppContext: (value: import("@modern-js/types").ISAppContext) => void;
64
64
  }>[];
@@ -3,21 +3,8 @@ import { IncomingMessage, ServerResponse } from 'http';
3
3
  import type { Component } from 'react';
4
4
  import { CommonAPI, ToThreads, AsyncSetup, PluginOptions } from '@modern-js/plugin';
5
5
  import type { ModernServerContext, BaseSSRServerContext, AfterMatchContext, AfterRenderContext, MiddlewareContext, ISAppContext, ServerRoute } from '@modern-js/types';
6
- import type { NormalizedConfig, UserConfig } from '@modern-js/core';
7
6
  import type { Options } from 'http-proxy-middleware';
8
- /** The subset of NormalizedConfig, which really need in server */
9
-
10
- export declare type ServerOptions = {
11
- output: Pick<NormalizedConfig['output'], 'path' | 'assetPrefix'>;
12
- source: Pick<NormalizedConfig['source'], 'alias' | 'envVars' | 'globalVars'>;
13
- tools: {
14
- babel: NormalizedConfig['tools']['babel'];
15
- };
16
- server: NormalizedConfig['server'];
17
- runtime: NormalizedConfig['runtime'];
18
- bff: NormalizedConfig['bff'];
19
- plugins: NormalizedConfig['plugins'];
20
- };
7
+ import type { ServerOptions, UserConfig } from './types/config';
21
8
  export declare type WebAdapter = (ctx: MiddlewareContext) => void | Promise<void>;
22
9
  export declare type Adapter = (req: IncomingMessage, res: ServerResponse) => void | Promise<void>;
23
10
  export declare type WebServerStartInput = {
@@ -48,12 +35,10 @@ export declare const ConfigContext: import("@modern-js/plugin").Context<UserConf
48
35
  /**
49
36
  * Get original content of user config.
50
37
  */
51
-
52
38
  export declare const useConfigContext: () => UserConfig;
53
39
  /**
54
40
  * Get app context, including directories, plugins and some static infos.
55
41
  */
56
-
57
42
  export declare const useAppContext: () => ISAppContext;
58
43
  declare const pluginAPI: {
59
44
  useAppContext: () => ISAppContext;
@@ -114,13 +99,10 @@ declare const serverHooks: {
114
99
  reset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
115
100
  };
116
101
  /** All hooks of server plugin. */
117
-
118
102
  export declare type ServerHooks = typeof serverHooks;
119
103
  /** All hook callbacks of server plugin. */
120
-
121
104
  export declare type ServerHookCallbacks = ToThreads<ServerHooks>;
122
105
  /** All apis for server plugin. */
123
-
124
106
  export declare type PluginAPI = typeof pluginAPI & CommonAPI<ServerHooks>;
125
107
  export declare const createServerManager: () => import("@modern-js/plugin").AsyncManager<{
126
108
  gather: import("@modern-js/plugin").ParallelWorkflow<{
@@ -237,7 +219,6 @@ export declare const serverManager: import("@modern-js/plugin").AsyncManager<{
237
219
  setAppContext: (value: ISAppContext) => void;
238
220
  }>;
239
221
  /** Plugin options of a server plugin. */
240
-
241
222
  export declare type ServerPlugin = PluginOptions<ServerHooks, AsyncSetup<ServerHooks, PluginAPI>>;
242
223
  export declare type ServerConfig = {
243
224
  bff?: Partial<{
@@ -409,7 +390,7 @@ export declare const createPlugin: (setup?: AsyncSetup<{
409
390
  useAppContext: () => ISAppContext;
410
391
  useConfigContext: () => UserConfig;
411
392
  setAppContext: (value: ISAppContext) => void;
412
- }>, Record<string, unknown>> | undefined) => import("@modern-js/plugin").AsyncPlugin<{
393
+ }>, Record<string, unknown>, any, any> | undefined) => import("@modern-js/plugin").AsyncPlugin<{
413
394
  gather: import("@modern-js/plugin").ParallelWorkflow<{
414
395
  addWebMiddleware: (_input: any) => void;
415
396
  addAPIMiddleware: (_input: any) => void;
@@ -0,0 +1,5 @@
1
+ export interface BffUserConfig {
2
+ prefix?: string;
3
+ proxy?: Record<string, string>;
4
+ }
5
+ export declare type BffNormalizedConfig = BffUserConfig;
@@ -0,0 +1,5 @@
1
+ export interface HtmlUserConfig {
2
+ favicon?: string;
3
+ faviconByEntries?: Record<string, string | undefined>;
4
+ }
5
+ export declare type HtmlNormalizedConfig = HtmlUserConfig;
@@ -0,0 +1,34 @@
1
+ import { BffNormalizedConfig, BffUserConfig } from './bff';
2
+ import { HtmlNormalizedConfig, HtmlUserConfig } from './html';
3
+ import { OutputNormalizedConfig, OutputUserConfig } from './output';
4
+ import { ServerNormalizedConfig, ServerUserConfig } from './server';
5
+ import { SourceNormalizedConfig, SourceUserConfig } from './source';
6
+ import { ToolsNormalizedConfig, ToolsUserConfig } from './tools';
7
+ export * from './bff';
8
+ export * from './html';
9
+ export * from './output';
10
+ export * from './server';
11
+ export * from './source';
12
+ export * from './tools';
13
+ interface RuntimeUserConfig {
14
+ [property: string]: any;
15
+ }
16
+ declare type RuntimeNormalizedConfig = RuntimeUserConfig;
17
+ export interface UserConfig {
18
+ output?: OutputUserConfig;
19
+ source?: SourceUserConfig;
20
+ tools?: ToolsUserConfig;
21
+ server?: ServerUserConfig;
22
+ runtime?: RuntimeUserConfig;
23
+ html?: HtmlUserConfig;
24
+ bff?: BffUserConfig;
25
+ }
26
+ export declare type ServerOptions = {
27
+ output: OutputNormalizedConfig;
28
+ source: SourceNormalizedConfig;
29
+ tools: ToolsNormalizedConfig;
30
+ server: ServerNormalizedConfig;
31
+ runtime: RuntimeNormalizedConfig;
32
+ html: HtmlNormalizedConfig;
33
+ bff: BffNormalizedConfig;
34
+ };
@@ -0,0 +1,17 @@
1
+ export interface OutputUserConfig {
2
+ distPath?: {
3
+ root?: string;
4
+ js?: string;
5
+ css?: string;
6
+ svg?: string;
7
+ font?: string;
8
+ html?: string;
9
+ image?: string;
10
+ media?: string;
11
+ server?: string;
12
+ };
13
+ path?: string;
14
+ assetPrefix?: string;
15
+ polyfill?: 'entry' | 'usage' | 'ua' | 'off';
16
+ }
17
+ export declare type OutputNormalizedConfig = OutputUserConfig;
@@ -0,0 +1,27 @@
1
+ import type { WatchOptions } from '@modern-js/utils';
2
+ declare type Route = string | string[] | {
3
+ route?: string | string[];
4
+ disableSpa?: boolean;
5
+ resHeaders?: Record<string, unknown>;
6
+ };
7
+ export declare type Routes = Record<string, Route>;
8
+ export declare type SSR = boolean | {
9
+ mode?: 'string' | 'stream';
10
+ };
11
+ export declare type SSRByEntries = Record<string, SSR>;
12
+ export interface ServerUserConfig {
13
+ routes?: Routes;
14
+ publicRoutes?: Record<string, string>;
15
+ ssr?: SSR;
16
+ ssrByEntries?: SSRByEntries;
17
+ baseUrl?: string | string[];
18
+ port?: number;
19
+ logger?: boolean | Record<string, any>;
20
+ metrics?: boolean | Record<string, any>;
21
+ enableMicroFrontendDebug?: boolean;
22
+ watchOptions?: WatchOptions;
23
+ compiler?: 'babel' | 'typescript';
24
+ disableFrameworkExt?: boolean;
25
+ }
26
+ export declare type ServerNormalizedConfig = ServerUserConfig;
27
+ export {};
@@ -0,0 +1,3 @@
1
+ declare type ArrayOrNot<T> = T | T[];
2
+ export declare type ChainedConfig<Config, Utils = unknown> = ArrayOrNot<Config | (keyof Utils extends never ? (config: Config) => Config | void : (config: Config, utils: Utils) => Config | void)>;
3
+ export {};
@@ -0,0 +1,15 @@
1
+ import type { Alias } from '@modern-js/utils';
2
+ import type { ChainedConfig } from './share';
3
+ declare type JSONPrimitive = string | number | boolean | null;
4
+ declare type JSONArray = Array<JSONValue>;
5
+ declare type JSONObject = {
6
+ [key: string]: JSONValue;
7
+ };
8
+ declare type JSONValue = JSONPrimitive | JSONObject | JSONArray;
9
+ export interface SourceUserConfig {
10
+ alias?: ChainedConfig<Alias>;
11
+ define?: Record<string, any>;
12
+ globalVars?: Record<string, JSONValue>;
13
+ }
14
+ export declare type SourceNormalizedConfig = SourceUserConfig;
15
+ export {};
@@ -0,0 +1,9 @@
1
+ import { BabelConfigUtils } from '@modern-js/babel-preset-app';
2
+ import { BabelTransformOptions } from '@modern-js/types/common';
3
+ import { ChainedConfig } from './share';
4
+ declare type ToolsBabelConfig = ChainedConfig<BabelTransformOptions, BabelConfigUtils>;
5
+ export interface ToolsUserConfig {
6
+ babel?: ToolsBabelConfig;
7
+ }
8
+ export declare type ToolsNormalizedConfig = ToolsUserConfig;
9
+ export {};
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/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -29,20 +29,20 @@
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "@modern-js/plugin": "2.0.0-beta.0",
33
- "@modern-js/utils": "2.0.0-beta.0"
32
+ "@modern-js/plugin": "2.0.0-beta.2",
33
+ "@modern-js/utils": "2.0.0-beta.2"
34
34
  },
35
35
  "devDependencies": {
36
- "@modern-js/core": "2.0.0-beta.0",
37
- "@modern-js/types": "2.0.0-beta.0",
38
- "@scripts/build": "2.0.0-beta.0",
39
- "@scripts/jest-config": "2.0.0-beta.0",
40
36
  "@types/jest": "^27",
41
37
  "@types/node": "^14",
42
38
  "http-proxy-middleware": "^2.0.4",
43
39
  "jest": "^27",
44
40
  "ts-jest": "^27.0.4",
45
- "typescript": "^4"
41
+ "typescript": "^4",
42
+ "@modern-js/types": "2.0.0-beta.2",
43
+ "@modern-js/babel-preset-app": "2.0.0-beta.2",
44
+ "@scripts/build": "2.0.0-beta.2",
45
+ "@scripts/jest-config": "2.0.0-beta.2"
46
46
  },
47
47
  "sideEffects": false,
48
48
  "modernConfig": {
@@ -55,9 +55,9 @@
55
55
  "access": "public"
56
56
  },
57
57
  "scripts": {
58
- "new": "modern new",
59
- "dev": "modern build --watch",
60
- "build": "modern build",
58
+ "new": "modern-lib new",
59
+ "dev": "modern-lib build --watch",
60
+ "build": "modern-lib build",
61
61
  "test": "jest --passWithNoTests"
62
62
  }
63
63
  }