@modern-js/server-core 2.4.1-beta.0 → 2.5.1-alpha.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,15 +1,29 @@
1
1
  # @modern-js/server-plugin
2
2
 
3
- ## 2.4.1-beta.0
3
+ ## 2.5.0
4
4
 
5
5
  ### Patch Changes
6
6
 
7
+ - 89ca6cc: refactor: merge build-config into scripts/build
8
+
9
+ refactor: 把 build-config 合并进 scripts/build
10
+
11
+ - 6fca567: feat: support bff handle complete server, include page render
12
+ feat: 支持 bff 处理整个服务,包括页面渲染
13
+ - 30614fa: chore: modify package.json entry fields and build config
14
+ chore: 更改 package.json entry 字段以及构建配置
7
15
  - 11c053b: feat: ssr support deploy worker
8
16
 
9
17
  feat: ssr 支持边缘部署
10
18
 
19
+ - 169c58b: feat: support force csr config
20
+ feat: 支持强制 CSR 的配置
21
+ - Updated dependencies [89ca6cc]
22
+ - Updated dependencies [30614fa]
23
+ - Updated dependencies [1b0ce87]
11
24
  - Updated dependencies [11c053b]
12
- - @modern-js/utils@2.4.1-beta.0
25
+ - @modern-js/plugin@2.5.0
26
+ - @modern-js/utils@2.5.0
13
27
 
14
28
  ## 2.4.0
15
29
 
@@ -0,0 +1,20 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var src_exports = {};
16
+ module.exports = __toCommonJS(src_exports);
17
+ __reExport(src_exports, require("./plugin"), module.exports);
18
+ __reExport(src_exports, require("@modern-js/plugin"), module.exports);
19
+ __reExport(src_exports, require("./loadPlugins"), module.exports);
20
+ __reExport(src_exports, require("./types/config"), module.exports);
@@ -0,0 +1,52 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var loadPlugins_exports = {};
19
+ __export(loadPlugins_exports, {
20
+ loadPlugins: () => loadPlugins
21
+ });
22
+ module.exports = __toCommonJS(loadPlugins_exports);
23
+ var import_utils = require("@modern-js/utils");
24
+ var import_plugin = require("./plugin");
25
+ const resolvePlugin = (p, appDirectory) => {
26
+ const isPluginInstance = typeof p !== "string";
27
+ if (isPluginInstance) {
28
+ return {
29
+ module: (0, import_plugin.createPlugin)(p.setup, p)
30
+ };
31
+ }
32
+ const pluginPath = (0, import_utils.tryResolve)(p, appDirectory);
33
+ const module2 = (0, import_utils.compatRequire)(pluginPath);
34
+ const pluginInstance = module2();
35
+ return {
36
+ module: (0, import_plugin.createPlugin)(pluginInstance.setup, pluginInstance)
37
+ };
38
+ };
39
+ const loadPlugins = (appDirectory, configPlugins, options) => {
40
+ const loadedPlugins = (0, import_utils.getInternalPlugins)(
41
+ appDirectory,
42
+ options.internalPlugins
43
+ );
44
+ return [...loadedPlugins, ...configPlugins].map((plugin) => {
45
+ const { module: module2 } = resolvePlugin(plugin, appDirectory);
46
+ return module2;
47
+ });
48
+ };
49
+ // Annotate the CommonJS export names for ESM import in node:
50
+ 0 && (module.exports = {
51
+ loadPlugins
52
+ });
@@ -0,0 +1,116 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var plugin_exports = {};
19
+ __export(plugin_exports, {
20
+ AppContext: () => AppContext,
21
+ ConfigContext: () => ConfigContext,
22
+ createPlugin: () => createPlugin,
23
+ createServerManager: () => createServerManager,
24
+ serverManager: () => serverManager,
25
+ setAppContext: () => setAppContext,
26
+ useAppContext: () => useAppContext,
27
+ useConfigContext: () => useConfigContext
28
+ });
29
+ module.exports = __toCommonJS(plugin_exports);
30
+ var import_plugin = require("@modern-js/plugin");
31
+ const gather = (0, import_plugin.createParallelWorkflow)();
32
+ const config = (0, import_plugin.createWaterfall)();
33
+ const prepare = (0, import_plugin.createWaterfall)();
34
+ const preparebeforeRouteHandler = (0, import_plugin.createAsyncPipeline)();
35
+ const prepareWebServer = (0, import_plugin.createAsyncPipeline)();
36
+ const prepareApiServer = (0, import_plugin.createAsyncPipeline)();
37
+ const onApiChange = (0, import_plugin.createWaterfall)();
38
+ const repack = (0, import_plugin.createWaterfall)();
39
+ const beforeDevServer = (0, import_plugin.createParallelWorkflow)();
40
+ const setupCompiler = (0, import_plugin.createParallelWorkflow)();
41
+ const afterDevServer = (0, import_plugin.createParallelWorkflow)();
42
+ const beforeRouteSet = (0, import_plugin.createAsyncPipeline)();
43
+ const afterRouteSet = (0, import_plugin.createAsyncPipeline)();
44
+ const beforeProdServer = (0, import_plugin.createParallelWorkflow)();
45
+ const afterProdServer = (0, import_plugin.createParallelWorkflow)();
46
+ const listen = (0, import_plugin.createParallelWorkflow)();
47
+ const beforeServerReset = (0, import_plugin.createParallelWorkflow)();
48
+ const afterServerReset = (0, import_plugin.createParallelWorkflow)();
49
+ const extendSSRContext = (0, import_plugin.createAsyncWaterfall)();
50
+ const extendContext = (0, import_plugin.createAsyncPipeline)();
51
+ const handleError = (0, import_plugin.createParallelWorkflow)();
52
+ const beforeMatch = (0, import_plugin.createAsyncPipeline)();
53
+ const afterMatch = (0, import_plugin.createAsyncPipeline)();
54
+ const prefetch = (0, import_plugin.createParallelWorkflow)();
55
+ const renderToString = (0, import_plugin.createAsyncPipeline)();
56
+ const beforeRender = (0, import_plugin.createAsyncPipeline)();
57
+ const afterRender = (0, import_plugin.createAsyncPipeline)();
58
+ const beforeSend = (0, import_plugin.createAsyncPipeline)();
59
+ const afterSend = (0, import_plugin.createParallelWorkflow)();
60
+ const reset = (0, import_plugin.createParallelWorkflow)();
61
+ const AppContext = (0, import_plugin.createContext)({});
62
+ const setAppContext = (value) => AppContext.set(value);
63
+ const ConfigContext = (0, import_plugin.createContext)({});
64
+ const useConfigContext = () => ConfigContext.use().value;
65
+ const useAppContext = () => AppContext.use().value;
66
+ const pluginAPI = {
67
+ useAppContext,
68
+ useConfigContext,
69
+ setAppContext
70
+ };
71
+ const serverHooks = {
72
+ gather,
73
+ config,
74
+ prepare,
75
+ preparebeforeRouteHandler,
76
+ prepareWebServer,
77
+ prepareApiServer,
78
+ repack,
79
+ onApiChange,
80
+ beforeDevServer,
81
+ setupCompiler,
82
+ afterDevServer,
83
+ beforeRouteSet,
84
+ afterRouteSet,
85
+ beforeProdServer,
86
+ afterProdServer,
87
+ listen,
88
+ beforeServerReset,
89
+ afterServerReset,
90
+ extendSSRContext,
91
+ extendContext,
92
+ handleError,
93
+ beforeMatch,
94
+ afterMatch,
95
+ prefetch,
96
+ renderToString,
97
+ beforeRender,
98
+ afterRender,
99
+ beforeSend,
100
+ afterSend,
101
+ reset
102
+ };
103
+ const createServerManager = () => (0, import_plugin.createAsyncManager)(serverHooks, pluginAPI);
104
+ const serverManager = createServerManager();
105
+ const { createPlugin } = serverManager;
106
+ // Annotate the CommonJS export names for ESM import in node:
107
+ 0 && (module.exports = {
108
+ AppContext,
109
+ ConfigContext,
110
+ createPlugin,
111
+ createServerManager,
112
+ serverManager,
113
+ setAppContext,
114
+ useAppContext,
115
+ useConfigContext
116
+ });
@@ -0,0 +1,15 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+ var bff_exports = {};
15
+ module.exports = __toCommonJS(bff_exports);
@@ -0,0 +1,15 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+ var html_exports = {};
15
+ module.exports = __toCommonJS(html_exports);
@@ -0,0 +1,22 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var config_exports = {};
16
+ module.exports = __toCommonJS(config_exports);
17
+ __reExport(config_exports, require("./bff"), module.exports);
18
+ __reExport(config_exports, require("./html"), module.exports);
19
+ __reExport(config_exports, require("./output"), module.exports);
20
+ __reExport(config_exports, require("./server"), module.exports);
21
+ __reExport(config_exports, require("./source"), module.exports);
22
+ __reExport(config_exports, require("./tools"), module.exports);
@@ -0,0 +1,15 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+ var output_exports = {};
15
+ module.exports = __toCommonJS(output_exports);
@@ -0,0 +1,15 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+ var server_exports = {};
15
+ module.exports = __toCommonJS(server_exports);
@@ -0,0 +1,15 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+ var share_exports = {};
15
+ module.exports = __toCommonJS(share_exports);
@@ -0,0 +1,15 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+ var source_exports = {};
15
+ module.exports = __toCommonJS(source_exports);
@@ -0,0 +1,15 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+ var tools_exports = {};
15
+ module.exports = __toCommonJS(tools_exports);
@@ -0,0 +1,4 @@
1
+ export * from "./plugin";
2
+ export * from "@modern-js/plugin";
3
+ export * from "./loadPlugins";
4
+ export * from "./types/config";
@@ -0,0 +1,33 @@
1
+ import {
2
+ compatRequire,
3
+ getInternalPlugins,
4
+ tryResolve
5
+ } from "@modern-js/utils";
6
+ import { createPlugin } from "./plugin";
7
+ const resolvePlugin = (p, appDirectory) => {
8
+ const isPluginInstance = typeof p !== "string";
9
+ if (isPluginInstance) {
10
+ return {
11
+ module: createPlugin(p.setup, p)
12
+ };
13
+ }
14
+ const pluginPath = tryResolve(p, appDirectory);
15
+ const module = compatRequire(pluginPath);
16
+ const pluginInstance = module();
17
+ return {
18
+ module: createPlugin(pluginInstance.setup, pluginInstance)
19
+ };
20
+ };
21
+ const loadPlugins = (appDirectory, configPlugins, options) => {
22
+ const loadedPlugins = getInternalPlugins(
23
+ appDirectory,
24
+ options.internalPlugins
25
+ );
26
+ return [...loadedPlugins, ...configPlugins].map((plugin) => {
27
+ const { module } = resolvePlugin(plugin, appDirectory);
28
+ return module;
29
+ });
30
+ };
31
+ export {
32
+ loadPlugins
33
+ };
@@ -0,0 +1,93 @@
1
+ import {
2
+ createContext,
3
+ createAsyncManager,
4
+ createAsyncPipeline,
5
+ createAsyncWaterfall,
6
+ createParallelWorkflow,
7
+ createWaterfall
8
+ } from "@modern-js/plugin";
9
+ const gather = createParallelWorkflow();
10
+ const config = createWaterfall();
11
+ const prepare = createWaterfall();
12
+ const preparebeforeRouteHandler = createAsyncPipeline();
13
+ const prepareWebServer = createAsyncPipeline();
14
+ const prepareApiServer = createAsyncPipeline();
15
+ const onApiChange = createWaterfall();
16
+ const repack = createWaterfall();
17
+ const beforeDevServer = createParallelWorkflow();
18
+ const setupCompiler = createParallelWorkflow();
19
+ const afterDevServer = createParallelWorkflow();
20
+ const beforeRouteSet = createAsyncPipeline();
21
+ const afterRouteSet = createAsyncPipeline();
22
+ const beforeProdServer = createParallelWorkflow();
23
+ const afterProdServer = createParallelWorkflow();
24
+ const listen = createParallelWorkflow();
25
+ const beforeServerReset = createParallelWorkflow();
26
+ const afterServerReset = createParallelWorkflow();
27
+ const extendSSRContext = createAsyncWaterfall();
28
+ const extendContext = createAsyncPipeline();
29
+ const handleError = createParallelWorkflow();
30
+ const beforeMatch = createAsyncPipeline();
31
+ const afterMatch = createAsyncPipeline();
32
+ const prefetch = createParallelWorkflow();
33
+ const renderToString = createAsyncPipeline();
34
+ const beforeRender = createAsyncPipeline();
35
+ const afterRender = createAsyncPipeline();
36
+ const beforeSend = createAsyncPipeline();
37
+ const afterSend = createParallelWorkflow();
38
+ const reset = createParallelWorkflow();
39
+ const AppContext = createContext({});
40
+ const setAppContext = (value) => AppContext.set(value);
41
+ const ConfigContext = createContext({});
42
+ const useConfigContext = () => ConfigContext.use().value;
43
+ const useAppContext = () => AppContext.use().value;
44
+ const pluginAPI = {
45
+ useAppContext,
46
+ useConfigContext,
47
+ setAppContext
48
+ };
49
+ const serverHooks = {
50
+ gather,
51
+ config,
52
+ prepare,
53
+ preparebeforeRouteHandler,
54
+ prepareWebServer,
55
+ prepareApiServer,
56
+ repack,
57
+ onApiChange,
58
+ beforeDevServer,
59
+ setupCompiler,
60
+ afterDevServer,
61
+ beforeRouteSet,
62
+ afterRouteSet,
63
+ beforeProdServer,
64
+ afterProdServer,
65
+ listen,
66
+ beforeServerReset,
67
+ afterServerReset,
68
+ extendSSRContext,
69
+ extendContext,
70
+ handleError,
71
+ beforeMatch,
72
+ afterMatch,
73
+ prefetch,
74
+ renderToString,
75
+ beforeRender,
76
+ afterRender,
77
+ beforeSend,
78
+ afterSend,
79
+ reset
80
+ };
81
+ const createServerManager = () => createAsyncManager(serverHooks, pluginAPI);
82
+ const serverManager = createServerManager();
83
+ const { createPlugin } = serverManager;
84
+ export {
85
+ AppContext,
86
+ ConfigContext,
87
+ createPlugin,
88
+ createServerManager,
89
+ serverManager,
90
+ setAppContext,
91
+ useAppContext,
92
+ useConfigContext
93
+ };
File without changes
File without changes
@@ -0,0 +1,6 @@
1
+ export * from "./bff";
2
+ export * from "./html";
3
+ export * from "./output";
4
+ export * from "./server";
5
+ export * from "./source";
6
+ export * from "./tools";
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -13,6 +13,7 @@ const preparebeforeRouteHandler = createAsyncPipeline();
13
13
  const prepareWebServer = createAsyncPipeline();
14
14
  const prepareApiServer = createAsyncPipeline();
15
15
  const onApiChange = createWaterfall();
16
+ const repack = createWaterfall();
16
17
  const beforeDevServer = createParallelWorkflow();
17
18
  const setupCompiler = createParallelWorkflow();
18
19
  const afterDevServer = createParallelWorkflow();
@@ -52,6 +53,7 @@ const serverHooks = {
52
53
  preparebeforeRouteHandler,
53
54
  prepareWebServer,
54
55
  prepareApiServer,
56
+ repack,
55
57
  onApiChange,
56
58
  beforeDevServer,
57
59
  setupCompiler,
@@ -35,6 +35,7 @@ const preparebeforeRouteHandler = (0, import_plugin.createAsyncPipeline)();
35
35
  const prepareWebServer = (0, import_plugin.createAsyncPipeline)();
36
36
  const prepareApiServer = (0, import_plugin.createAsyncPipeline)();
37
37
  const onApiChange = (0, import_plugin.createWaterfall)();
38
+ const repack = (0, import_plugin.createWaterfall)();
38
39
  const beforeDevServer = (0, import_plugin.createParallelWorkflow)();
39
40
  const setupCompiler = (0, import_plugin.createParallelWorkflow)();
40
41
  const afterDevServer = (0, import_plugin.createParallelWorkflow)();
@@ -74,6 +75,7 @@ const serverHooks = {
74
75
  preparebeforeRouteHandler,
75
76
  prepareWebServer,
76
77
  prepareApiServer,
78
+ repack,
77
79
  onApiChange,
78
80
  beforeDevServer,
79
81
  setupCompiler,
@@ -2,9 +2,8 @@
2
2
  import { IncomingMessage, ServerResponse } from 'http';
3
3
  import type { Component } from 'react';
4
4
  import { CommonAPI, ToThreads, AsyncSetup, PluginOptions } from '@modern-js/plugin';
5
- import type { ModernServerContext, BaseSSRServerContext, AfterMatchContext, AfterRenderContext, MiddlewareContext, ISAppContext, ServerRoute } from '@modern-js/types';
6
- import type { Options } from 'http-proxy-middleware';
7
- import type { ServerOptions, UserConfig } from './types/config';
5
+ import type { ModernServerContext, BaseSSRServerContext, AfterMatchContext, AfterRenderContext, MiddlewareContext, ISAppContext, ServerRoute, HttpMethodDecider } from '@modern-js/types';
6
+ import type { BffUserConfig, ServerOptions, UserConfig } from './types/config';
8
7
  export type WebAdapter = (ctx: MiddlewareContext) => void | Promise<void>;
9
8
  export type Adapter = (req: IncomingMessage, res: ServerResponse) => void | Promise<void>;
10
9
  export type WebServerStartInput = {
@@ -15,9 +14,11 @@ export type BeforeRouteHandler = (context: ModernServerContext) => Promise<void>
15
14
  export type APIServerStartInput = {
16
15
  pwd: string;
17
16
  prefix?: string;
17
+ httpMethodDecider?: HttpMethodDecider;
18
18
  config?: {
19
19
  middleware?: Array<any>;
20
20
  };
21
+ render?: (req: IncomingMessage, res: ServerResponse, url?: string) => Promise<string | null>;
21
22
  };
22
23
  type Change = {
23
24
  filename: string;
@@ -60,6 +61,7 @@ declare const serverHooks: {
60
61
  }, BeforeRouteHandler>;
61
62
  prepareWebServer: import("@modern-js/plugin").AsyncPipeline<WebServerStartInput, WebAdapter>;
62
63
  prepareApiServer: import("@modern-js/plugin").AsyncPipeline<APIServerStartInput, Adapter>;
64
+ repack: import("@modern-js/plugin").Waterfall<void>;
63
65
  onApiChange: import("@modern-js/plugin").Waterfall<Change[]>;
64
66
  beforeDevServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
65
67
  setupCompiler: import("@modern-js/plugin").ParallelWorkflow<Record<string, unknown>, any[]>;
@@ -122,6 +124,7 @@ export declare const createServerManager: () => import("@modern-js/plugin").Asyn
122
124
  }, BeforeRouteHandler>;
123
125
  prepareWebServer: import("@modern-js/plugin").AsyncPipeline<WebServerStartInput, WebAdapter>;
124
126
  prepareApiServer: import("@modern-js/plugin").AsyncPipeline<APIServerStartInput, Adapter>;
127
+ repack: import("@modern-js/plugin").Waterfall<void>;
125
128
  onApiChange: import("@modern-js/plugin").Waterfall<Change[]>;
126
129
  beforeDevServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
127
130
  setupCompiler: import("@modern-js/plugin").ParallelWorkflow<Record<string, unknown>, any[]>;
@@ -179,6 +182,7 @@ export declare const serverManager: import("@modern-js/plugin").AsyncManager<{
179
182
  }, BeforeRouteHandler>;
180
183
  prepareWebServer: import("@modern-js/plugin").AsyncPipeline<WebServerStartInput, WebAdapter>;
181
184
  prepareApiServer: import("@modern-js/plugin").AsyncPipeline<APIServerStartInput, Adapter>;
185
+ repack: import("@modern-js/plugin").Waterfall<void>;
182
186
  onApiChange: import("@modern-js/plugin").Waterfall<Change[]>;
183
187
  beforeDevServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
184
188
  setupCompiler: import("@modern-js/plugin").ParallelWorkflow<Record<string, unknown>, any[]>;
@@ -227,9 +231,7 @@ export declare const serverManager: import("@modern-js/plugin").AsyncManager<{
227
231
 
228
232
  export type ServerPlugin = PluginOptions<ServerHooks, AsyncSetup<ServerHooks, PluginAPI>>;
229
233
  export type ServerConfig = {
230
- bff?: Partial<{
231
- proxy: Record<string, Options>;
232
- }>;
234
+ bff?: BffUserConfig;
233
235
  plugins?: ServerPlugin[];
234
236
  };
235
237
  export declare const createPlugin: (setup?: AsyncSetup<{
@@ -245,6 +247,7 @@ export declare const createPlugin: (setup?: AsyncSetup<{
245
247
  }, BeforeRouteHandler>;
246
248
  prepareWebServer: import("@modern-js/plugin").AsyncPipeline<WebServerStartInput, WebAdapter>;
247
249
  prepareApiServer: import("@modern-js/plugin").AsyncPipeline<APIServerStartInput, Adapter>;
250
+ repack: import("@modern-js/plugin").Waterfall<void>;
248
251
  onApiChange: import("@modern-js/plugin").Waterfall<Change[]>;
249
252
  beforeDevServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
250
253
  setupCompiler: import("@modern-js/plugin").ParallelWorkflow<Record<string, unknown>, any[]>;
@@ -301,6 +304,7 @@ export declare const createPlugin: (setup?: AsyncSetup<{
301
304
  }, BeforeRouteHandler>;
302
305
  prepareWebServer: import("@modern-js/plugin").AsyncPipeline<WebServerStartInput, WebAdapter>;
303
306
  prepareApiServer: import("@modern-js/plugin").AsyncPipeline<APIServerStartInput, Adapter>;
307
+ repack: import("@modern-js/plugin").Waterfall<void>;
304
308
  onApiChange: import("@modern-js/plugin").Waterfall<Change[]>;
305
309
  beforeDevServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
306
310
  setupCompiler: import("@modern-js/plugin").ParallelWorkflow<Record<string, unknown>, any[]>;
@@ -353,6 +357,7 @@ export declare const createPlugin: (setup?: AsyncSetup<{
353
357
  }, BeforeRouteHandler>;
354
358
  prepareWebServer: import("@modern-js/plugin").AsyncPipeline<WebServerStartInput, WebAdapter>;
355
359
  prepareApiServer: import("@modern-js/plugin").AsyncPipeline<APIServerStartInput, Adapter>;
360
+ repack: import("@modern-js/plugin").Waterfall<void>;
356
361
  onApiChange: import("@modern-js/plugin").Waterfall<Change[]>;
357
362
  beforeDevServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
358
363
  setupCompiler: import("@modern-js/plugin").ParallelWorkflow<Record<string, unknown>, any[]>;
@@ -409,6 +414,7 @@ export declare const createPlugin: (setup?: AsyncSetup<{
409
414
  }, BeforeRouteHandler>;
410
415
  prepareWebServer: import("@modern-js/plugin").AsyncPipeline<WebServerStartInput, WebAdapter>;
411
416
  prepareApiServer: import("@modern-js/plugin").AsyncPipeline<APIServerStartInput, Adapter>;
417
+ repack: import("@modern-js/plugin").Waterfall<void>;
412
418
  onApiChange: import("@modern-js/plugin").Waterfall<Change[]>;
413
419
  beforeDevServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
414
420
  setupCompiler: import("@modern-js/plugin").ParallelWorkflow<Record<string, unknown>, any[]>;
@@ -1,5 +1,9 @@
1
+ import type { Options } from 'http-proxy-middleware';
2
+ import type { HttpMethodDecider } from '@modern-js/types';
1
3
  export interface BffUserConfig {
2
4
  prefix?: string;
3
- proxy?: Record<string, string>;
5
+ proxy?: Record<string, Options>;
6
+ httpMethodDecider?: HttpMethodDecider;
7
+ enableHandleWeb?: boolean;
4
8
  }
5
9
  export type BffNormalizedConfig = BffUserConfig;
@@ -6,6 +6,7 @@ type Route = string | string[] | {
6
6
  };
7
7
  export type Routes = Record<string, Route>;
8
8
  export type SSR = boolean | {
9
+ forceCSR?: boolean;
9
10
  mode?: 'string' | 'stream';
10
11
  };
11
12
  export type SSRByEntries = Record<string, SSR>;
package/package.json CHANGED
@@ -11,38 +11,37 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.4.1-beta.0",
14
+ "version": "2.5.1-alpha.0",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
- "main": "./dist/js/node/index.js",
18
- "module": "./dist/js/treeshaking/index.js",
19
- "jsnext:modern": "./dist/js/modern/index.js",
17
+ "main": "./dist/cjs/index.js",
18
+ "module": "./dist/esm/index.js",
20
19
  "exports": {
21
20
  ".": {
22
21
  "node": {
23
22
  "jsnext:source": "./src/index.ts",
24
- "import": "./dist/js/modern/index.js",
25
- "require": "./dist/js/node/index.js"
23
+ "import": "./dist/esm/index.js",
24
+ "require": "./dist/cjs/index.js"
26
25
  },
27
26
  "types": "./dist/types/index.d.ts",
28
- "default": "./dist/js/node/index.js"
27
+ "default": "./dist/cjs/index.js"
29
28
  }
30
29
  },
31
30
  "dependencies": {
32
- "@modern-js/plugin": "2.4.0",
33
- "@modern-js/utils": "2.4.1-beta.0"
31
+ "@modern-js/plugin": "2.5.0",
32
+ "@modern-js/utils": "2.5.0"
34
33
  },
35
34
  "devDependencies": {
35
+ "@modern-js/types": "2.5.0",
36
+ "@modern-js/babel-preset-app": "2.5.0",
37
+ "@scripts/build": "2.5.0",
38
+ "@scripts/jest-config": "2.5.0",
36
39
  "@types/jest": "^27",
37
40
  "@types/node": "^14",
38
41
  "http-proxy-middleware": "^2.0.4",
39
42
  "jest": "^27",
40
43
  "ts-jest": "^27.0.4",
41
- "typescript": "^4",
42
- "@modern-js/types": "2.4.0",
43
- "@modern-js/babel-preset-app": "2.4.1-beta.0",
44
- "@scripts/build": "2.4.0",
45
- "@scripts/jest-config": "2.4.0"
44
+ "typescript": "^4"
46
45
  },
47
46
  "sideEffects": false,
48
47
  "publishConfig": {