@modern-js/server-core 1.2.6-canary.0 → 1.3.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 +47 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/loadPlugins.d.ts +1 -1
- package/dist/types/plugin.d.ts +407 -401
- package/package.json +6 -7
- package/tests/.eslintrc.js +0 -6
- package/tests/fixtures/load-plugins/test-a/index.js +0 -3
- package/tests/fixtures/load-plugins/test-a/package.json +0 -3
- package/tests/loadPlugin.test.ts +0 -33
- package/tests/server-plugin.test.ts +0 -60
- package/tests/tsconfig.json +0 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
# @modern-js/server-plugin
|
|
2
2
|
|
|
3
|
+
## 1.3.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 895fa0ff: chore: using "workspace:\*" in devDependencies
|
|
8
|
+
- Updated dependencies [2d155c4c]
|
|
9
|
+
- Updated dependencies [123e432d]
|
|
10
|
+
- Updated dependencies [e5a9b26d]
|
|
11
|
+
- Updated dependencies [0b26b93b]
|
|
12
|
+
- Updated dependencies [123e432d]
|
|
13
|
+
- Updated dependencies [f9f66ef9]
|
|
14
|
+
- Updated dependencies [592edabc]
|
|
15
|
+
- Updated dependencies [895fa0ff]
|
|
16
|
+
- Updated dependencies [3578913e]
|
|
17
|
+
- Updated dependencies [1c3beab3]
|
|
18
|
+
- @modern-js/utils@1.6.0
|
|
19
|
+
|
|
20
|
+
## 1.3.1
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- 04ae5262: chore: bump @modern-js/utils to v1.4.1 in dependencies
|
|
25
|
+
- 60f7d8bf: feat: add tests dir to npmignore
|
|
26
|
+
- Updated dependencies [b8599d09]
|
|
27
|
+
- Updated dependencies [6cffe99d]
|
|
28
|
+
- Updated dependencies [60f7d8bf]
|
|
29
|
+
- Updated dependencies [3bf4f8b0]
|
|
30
|
+
- @modern-js/utils@1.5.0
|
|
31
|
+
- @modern-js/plugin@1.3.3
|
|
32
|
+
|
|
33
|
+
## 1.3.0
|
|
34
|
+
|
|
35
|
+
### Minor Changes
|
|
36
|
+
|
|
37
|
+
- d2d1d6b2: feat: support server config
|
|
38
|
+
|
|
39
|
+
### Patch Changes
|
|
40
|
+
|
|
41
|
+
- d2d1d6b2: feat: add prepare hook
|
|
42
|
+
- Updated dependencies [77ff9754]
|
|
43
|
+
- Updated dependencies [d2d1d6b2]
|
|
44
|
+
- Updated dependencies [07a4887e]
|
|
45
|
+
- Updated dependencies [ea2ae711]
|
|
46
|
+
- Updated dependencies [17d0cc46]
|
|
47
|
+
- Updated dependencies [d2d1d6b2]
|
|
48
|
+
- @modern-js/utils@1.4.0
|
|
49
|
+
|
|
3
50
|
## 1.2.5
|
|
4
51
|
|
|
5
52
|
### Patch Changes
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/plugin.d.ts
CHANGED
|
@@ -7,29 +7,29 @@ import type { NormalizedConfig, UserConfig } from '@modern-js/core';
|
|
|
7
7
|
import type { ISAppContext } from '@modern-js/types';
|
|
8
8
|
import type { Options } from 'http-proxy-middleware';
|
|
9
9
|
declare type ServerInitInput = {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
loggerOptions: any;
|
|
11
|
+
metricsOptions: any;
|
|
12
12
|
};
|
|
13
13
|
declare type InitExtension = {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
logger: Logger;
|
|
15
|
+
metrics: Metrics;
|
|
16
16
|
};
|
|
17
17
|
export declare type Adapter = (req: IncomingMessage, res: ServerResponse) => void | Promise<void>;
|
|
18
18
|
export declare type WebServerStartInput = {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
pwd: string;
|
|
20
|
+
config: Record<string, any>;
|
|
21
21
|
};
|
|
22
22
|
export declare type APIServerStartInput = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
pwd: string;
|
|
24
|
+
mode: 'function' | 'framework';
|
|
25
|
+
prefix?: string;
|
|
26
|
+
config?: {
|
|
27
|
+
middleware?: Array<any>;
|
|
28
|
+
};
|
|
29
29
|
};
|
|
30
30
|
export declare type Route = Record<string, unknown>;
|
|
31
31
|
export declare type RequestResult = {
|
|
32
|
-
|
|
32
|
+
isfinish: boolean;
|
|
33
33
|
};
|
|
34
34
|
export declare type SSRServerContext = Record<string, unknown>;
|
|
35
35
|
export declare type RenderContext = Record<string, unknown>;
|
|
@@ -38,424 +38,430 @@ export declare const ConfigContext: import("@modern-js/plugin").Context<UserConf
|
|
|
38
38
|
/**
|
|
39
39
|
* Get original content of user config.
|
|
40
40
|
*/
|
|
41
|
+
|
|
41
42
|
export declare const useConfigContext: () => UserConfig;
|
|
42
43
|
/**
|
|
43
44
|
* Get app context, including directories, plugins and some static infos.
|
|
44
45
|
*/
|
|
46
|
+
|
|
45
47
|
export declare const useAppContext: () => ISAppContext;
|
|
46
48
|
declare const pluginAPI: {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
useAppContext: () => ISAppContext;
|
|
50
|
+
useConfigContext: () => UserConfig;
|
|
49
51
|
};
|
|
50
52
|
declare const serverHooks: {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
53
|
+
gather: import("@modern-js/plugin").ParallelWorkflow<{
|
|
54
|
+
addWebMiddleware: (_input: any) => void;
|
|
55
|
+
addAPIMiddleware: (_input: any) => void;
|
|
56
|
+
}, unknown>;
|
|
57
|
+
config: import("@modern-js/plugin").Waterfall<ServerConfig>;
|
|
58
|
+
prepare: import("@modern-js/plugin").Waterfall<void>;
|
|
59
|
+
create: import("@modern-js/plugin").AsyncPipeline<ServerInitInput, InitExtension>;
|
|
60
|
+
prepareWebServer: import("@modern-js/plugin").AsyncPipeline<WebServerStartInput, Adapter>;
|
|
61
|
+
prepareApiServer: import("@modern-js/plugin").AsyncPipeline<APIServerStartInput, Adapter>;
|
|
62
|
+
beforeDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
63
|
+
setupCompiler: import("@modern-js/plugin").ParallelWorkflow<Record<string, unknown>, any[]>;
|
|
64
|
+
afterDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
65
|
+
beforeRouteSet: import("@modern-js/plugin").AsyncPipeline<Route[], Route[]>;
|
|
66
|
+
afterRouteSet: import("@modern-js/plugin").AsyncPipeline<unknown, unknown>;
|
|
67
|
+
preServerInit: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
68
|
+
postServerInit: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
69
|
+
listen: import("@modern-js/plugin").ParallelWorkflow<{
|
|
70
|
+
ip: string;
|
|
71
|
+
port: number;
|
|
72
|
+
}, any[]>;
|
|
73
|
+
beforeServerReset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
|
|
74
|
+
afterServerReset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
|
|
75
|
+
extendSSRContext: import("@modern-js/plugin").AsyncWaterfall<BaseSSRServerContext>;
|
|
76
|
+
extendContext: import("@modern-js/plugin").AsyncPipeline<ModernServerContext, ModernServerContext>;
|
|
77
|
+
handleError: import("@modern-js/plugin").ParallelWorkflow<{
|
|
78
|
+
error: Error;
|
|
79
|
+
}, unknown>;
|
|
80
|
+
beforeMatch: import("@modern-js/plugin").AsyncPipeline<{
|
|
81
|
+
context: ModernServerContext;
|
|
82
|
+
}, any>;
|
|
83
|
+
afterMatch: import("@modern-js/plugin").AsyncPipeline<{
|
|
84
|
+
context: ModernServerContext;
|
|
85
|
+
routeAPI: any;
|
|
86
|
+
}, any>;
|
|
87
|
+
prefetch: import("@modern-js/plugin").ParallelWorkflow<{
|
|
88
|
+
context: SSRServerContext;
|
|
89
|
+
}, unknown>;
|
|
90
|
+
renderToString: import("@modern-js/plugin").AsyncPipeline<{
|
|
91
|
+
App: Component;
|
|
92
|
+
context: RenderContext;
|
|
93
|
+
}, string>;
|
|
94
|
+
beforeRender: import("@modern-js/plugin").AsyncPipeline<{
|
|
95
|
+
context: ModernServerContext;
|
|
96
|
+
}, any>;
|
|
97
|
+
afterRender: import("@modern-js/plugin").AsyncPipeline<{
|
|
98
|
+
context: ModernServerContext;
|
|
99
|
+
templateAPI: any;
|
|
100
|
+
}, any>;
|
|
101
|
+
beforeSend: import("@modern-js/plugin").AsyncPipeline<ModernServerContext, RequestResult>;
|
|
102
|
+
afterSend: import("@modern-js/plugin").ParallelWorkflow<{
|
|
103
|
+
context: ModernServerContext;
|
|
104
|
+
}, unknown>;
|
|
105
|
+
reset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
|
|
104
106
|
};
|
|
105
107
|
/** All hooks of server plugin. */
|
|
108
|
+
|
|
106
109
|
export declare type ServerHooks = typeof serverHooks;
|
|
107
110
|
/** All hook callbacks of server plugin. */
|
|
111
|
+
|
|
108
112
|
export declare type ServerHookCallbacks = ToThreads<ServerHooks>;
|
|
109
113
|
/** All apis for server plugin. */
|
|
114
|
+
|
|
110
115
|
export declare type PluginAPI = typeof pluginAPI & CommonAPI<ServerHooks>;
|
|
111
116
|
export declare const createServerManager: () => import("@modern-js/plugin").AsyncManager<{
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
117
|
+
gather: import("@modern-js/plugin").ParallelWorkflow<{
|
|
118
|
+
addWebMiddleware: (_input: any) => void;
|
|
119
|
+
addAPIMiddleware: (_input: any) => void;
|
|
120
|
+
}, unknown>;
|
|
121
|
+
config: import("@modern-js/plugin").Waterfall<ServerConfig>;
|
|
122
|
+
prepare: import("@modern-js/plugin").Waterfall<void>;
|
|
123
|
+
create: import("@modern-js/plugin").AsyncPipeline<ServerInitInput, InitExtension>;
|
|
124
|
+
prepareWebServer: import("@modern-js/plugin").AsyncPipeline<WebServerStartInput, Adapter>;
|
|
125
|
+
prepareApiServer: import("@modern-js/plugin").AsyncPipeline<APIServerStartInput, Adapter>;
|
|
126
|
+
beforeDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
127
|
+
setupCompiler: import("@modern-js/plugin").ParallelWorkflow<Record<string, unknown>, any[]>;
|
|
128
|
+
afterDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
129
|
+
beforeRouteSet: import("@modern-js/plugin").AsyncPipeline<Route[], Route[]>;
|
|
130
|
+
afterRouteSet: import("@modern-js/plugin").AsyncPipeline<unknown, unknown>;
|
|
131
|
+
preServerInit: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
132
|
+
postServerInit: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
133
|
+
listen: import("@modern-js/plugin").ParallelWorkflow<{
|
|
134
|
+
ip: string;
|
|
135
|
+
port: number;
|
|
136
|
+
}, any[]>;
|
|
137
|
+
beforeServerReset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
|
|
138
|
+
afterServerReset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
|
|
139
|
+
extendSSRContext: import("@modern-js/plugin").AsyncWaterfall<BaseSSRServerContext>;
|
|
140
|
+
extendContext: import("@modern-js/plugin").AsyncPipeline<ModernServerContext, ModernServerContext>;
|
|
141
|
+
handleError: import("@modern-js/plugin").ParallelWorkflow<{
|
|
142
|
+
error: Error;
|
|
143
|
+
}, unknown>;
|
|
144
|
+
beforeMatch: import("@modern-js/plugin").AsyncPipeline<{
|
|
145
|
+
context: ModernServerContext;
|
|
146
|
+
}, any>;
|
|
147
|
+
afterMatch: import("@modern-js/plugin").AsyncPipeline<{
|
|
148
|
+
context: ModernServerContext;
|
|
149
|
+
routeAPI: any;
|
|
150
|
+
}, any>;
|
|
151
|
+
prefetch: import("@modern-js/plugin").ParallelWorkflow<{
|
|
152
|
+
context: SSRServerContext;
|
|
153
|
+
}, unknown>;
|
|
154
|
+
renderToString: import("@modern-js/plugin").AsyncPipeline<{
|
|
155
|
+
App: Component;
|
|
156
|
+
context: RenderContext;
|
|
157
|
+
}, string>;
|
|
158
|
+
beforeRender: import("@modern-js/plugin").AsyncPipeline<{
|
|
159
|
+
context: ModernServerContext;
|
|
160
|
+
}, any>;
|
|
161
|
+
afterRender: import("@modern-js/plugin").AsyncPipeline<{
|
|
162
|
+
context: ModernServerContext;
|
|
163
|
+
templateAPI: any;
|
|
164
|
+
}, any>;
|
|
165
|
+
beforeSend: import("@modern-js/plugin").AsyncPipeline<ModernServerContext, RequestResult>;
|
|
166
|
+
afterSend: import("@modern-js/plugin").ParallelWorkflow<{
|
|
167
|
+
context: ModernServerContext;
|
|
168
|
+
}, unknown>;
|
|
169
|
+
reset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
|
|
165
170
|
}, {
|
|
166
|
-
|
|
167
|
-
|
|
171
|
+
useAppContext: () => ISAppContext;
|
|
172
|
+
useConfigContext: () => UserConfig;
|
|
168
173
|
}>;
|
|
169
174
|
export declare const serverManager: import("@modern-js/plugin").AsyncManager<{
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
175
|
+
gather: import("@modern-js/plugin").ParallelWorkflow<{
|
|
176
|
+
addWebMiddleware: (_input: any) => void;
|
|
177
|
+
addAPIMiddleware: (_input: any) => void;
|
|
178
|
+
}, unknown>;
|
|
179
|
+
config: import("@modern-js/plugin").Waterfall<ServerConfig>;
|
|
180
|
+
prepare: import("@modern-js/plugin").Waterfall<void>;
|
|
181
|
+
create: import("@modern-js/plugin").AsyncPipeline<ServerInitInput, InitExtension>;
|
|
182
|
+
prepareWebServer: import("@modern-js/plugin").AsyncPipeline<WebServerStartInput, Adapter>;
|
|
183
|
+
prepareApiServer: import("@modern-js/plugin").AsyncPipeline<APIServerStartInput, Adapter>;
|
|
184
|
+
beforeDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
185
|
+
setupCompiler: import("@modern-js/plugin").ParallelWorkflow<Record<string, unknown>, any[]>;
|
|
186
|
+
afterDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
187
|
+
beforeRouteSet: import("@modern-js/plugin").AsyncPipeline<Route[], Route[]>;
|
|
188
|
+
afterRouteSet: import("@modern-js/plugin").AsyncPipeline<unknown, unknown>;
|
|
189
|
+
preServerInit: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
190
|
+
postServerInit: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
191
|
+
listen: import("@modern-js/plugin").ParallelWorkflow<{
|
|
192
|
+
ip: string;
|
|
193
|
+
port: number;
|
|
194
|
+
}, any[]>;
|
|
195
|
+
beforeServerReset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
|
|
196
|
+
afterServerReset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
|
|
197
|
+
extendSSRContext: import("@modern-js/plugin").AsyncWaterfall<BaseSSRServerContext>;
|
|
198
|
+
extendContext: import("@modern-js/plugin").AsyncPipeline<ModernServerContext, ModernServerContext>;
|
|
199
|
+
handleError: import("@modern-js/plugin").ParallelWorkflow<{
|
|
200
|
+
error: Error;
|
|
201
|
+
}, unknown>;
|
|
202
|
+
beforeMatch: import("@modern-js/plugin").AsyncPipeline<{
|
|
203
|
+
context: ModernServerContext;
|
|
204
|
+
}, any>;
|
|
205
|
+
afterMatch: import("@modern-js/plugin").AsyncPipeline<{
|
|
206
|
+
context: ModernServerContext;
|
|
207
|
+
routeAPI: any;
|
|
208
|
+
}, any>;
|
|
209
|
+
prefetch: import("@modern-js/plugin").ParallelWorkflow<{
|
|
210
|
+
context: SSRServerContext;
|
|
211
|
+
}, unknown>;
|
|
212
|
+
renderToString: import("@modern-js/plugin").AsyncPipeline<{
|
|
213
|
+
App: Component;
|
|
214
|
+
context: RenderContext;
|
|
215
|
+
}, string>;
|
|
216
|
+
beforeRender: import("@modern-js/plugin").AsyncPipeline<{
|
|
217
|
+
context: ModernServerContext;
|
|
218
|
+
}, any>;
|
|
219
|
+
afterRender: import("@modern-js/plugin").AsyncPipeline<{
|
|
220
|
+
context: ModernServerContext;
|
|
221
|
+
templateAPI: any;
|
|
222
|
+
}, any>;
|
|
223
|
+
beforeSend: import("@modern-js/plugin").AsyncPipeline<ModernServerContext, RequestResult>;
|
|
224
|
+
afterSend: import("@modern-js/plugin").ParallelWorkflow<{
|
|
225
|
+
context: ModernServerContext;
|
|
226
|
+
}, unknown>;
|
|
227
|
+
reset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
|
|
223
228
|
}, {
|
|
224
|
-
|
|
225
|
-
|
|
229
|
+
useAppContext: () => ISAppContext;
|
|
230
|
+
useConfigContext: () => UserConfig;
|
|
226
231
|
}>;
|
|
227
232
|
/** Plugin options of a server plugin. */
|
|
233
|
+
|
|
228
234
|
export declare type ServerPlugin = PluginOptions<ServerHooks, AsyncSetup<ServerHooks, PluginAPI>>;
|
|
229
235
|
export declare type ServerConfig = {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
236
|
+
bff?: Partial<{
|
|
237
|
+
proxy: Record<string, Options>;
|
|
238
|
+
}>;
|
|
239
|
+
plugins?: ServerPlugin[];
|
|
234
240
|
};
|
|
235
241
|
export declare const createPlugin: (setup?: AsyncSetup<{
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
242
|
+
gather: import("@modern-js/plugin").ParallelWorkflow<{
|
|
243
|
+
addWebMiddleware: (_input: any) => void;
|
|
244
|
+
addAPIMiddleware: (_input: any) => void;
|
|
245
|
+
}, unknown>;
|
|
246
|
+
config: import("@modern-js/plugin").Waterfall<ServerConfig>;
|
|
247
|
+
prepare: import("@modern-js/plugin").Waterfall<void>;
|
|
248
|
+
create: import("@modern-js/plugin").AsyncPipeline<ServerInitInput, InitExtension>;
|
|
249
|
+
prepareWebServer: import("@modern-js/plugin").AsyncPipeline<WebServerStartInput, Adapter>;
|
|
250
|
+
prepareApiServer: import("@modern-js/plugin").AsyncPipeline<APIServerStartInput, Adapter>;
|
|
251
|
+
beforeDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
252
|
+
setupCompiler: import("@modern-js/plugin").ParallelWorkflow<Record<string, unknown>, any[]>;
|
|
253
|
+
afterDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
254
|
+
beforeRouteSet: import("@modern-js/plugin").AsyncPipeline<Route[], Route[]>;
|
|
255
|
+
afterRouteSet: import("@modern-js/plugin").AsyncPipeline<unknown, unknown>;
|
|
256
|
+
preServerInit: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
257
|
+
postServerInit: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
258
|
+
listen: import("@modern-js/plugin").ParallelWorkflow<{
|
|
259
|
+
ip: string;
|
|
260
|
+
port: number;
|
|
261
|
+
}, any[]>;
|
|
262
|
+
beforeServerReset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
|
|
263
|
+
afterServerReset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
|
|
264
|
+
extendSSRContext: import("@modern-js/plugin").AsyncWaterfall<BaseSSRServerContext>;
|
|
265
|
+
extendContext: import("@modern-js/plugin").AsyncPipeline<ModernServerContext, ModernServerContext>;
|
|
266
|
+
handleError: import("@modern-js/plugin").ParallelWorkflow<{
|
|
267
|
+
error: Error;
|
|
268
|
+
}, unknown>;
|
|
269
|
+
beforeMatch: import("@modern-js/plugin").AsyncPipeline<{
|
|
270
|
+
context: ModernServerContext;
|
|
271
|
+
}, any>;
|
|
272
|
+
afterMatch: import("@modern-js/plugin").AsyncPipeline<{
|
|
273
|
+
context: ModernServerContext;
|
|
274
|
+
routeAPI: any;
|
|
275
|
+
}, any>;
|
|
276
|
+
prefetch: import("@modern-js/plugin").ParallelWorkflow<{
|
|
277
|
+
context: SSRServerContext;
|
|
278
|
+
}, unknown>;
|
|
279
|
+
renderToString: import("@modern-js/plugin").AsyncPipeline<{
|
|
280
|
+
App: Component;
|
|
281
|
+
context: RenderContext;
|
|
282
|
+
}, string>;
|
|
283
|
+
beforeRender: import("@modern-js/plugin").AsyncPipeline<{
|
|
284
|
+
context: ModernServerContext;
|
|
285
|
+
}, any>;
|
|
286
|
+
afterRender: import("@modern-js/plugin").AsyncPipeline<{
|
|
287
|
+
context: ModernServerContext;
|
|
288
|
+
templateAPI: any;
|
|
289
|
+
}, any>;
|
|
290
|
+
beforeSend: import("@modern-js/plugin").AsyncPipeline<ModernServerContext, RequestResult>;
|
|
291
|
+
afterSend: import("@modern-js/plugin").ParallelWorkflow<{
|
|
292
|
+
context: ModernServerContext;
|
|
293
|
+
}, unknown>;
|
|
294
|
+
reset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
|
|
289
295
|
}, {
|
|
290
|
-
|
|
291
|
-
|
|
296
|
+
useAppContext: () => ISAppContext;
|
|
297
|
+
useConfigContext: () => UserConfig;
|
|
292
298
|
}> | undefined, options?: PluginOptions<{
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
299
|
+
gather: import("@modern-js/plugin").ParallelWorkflow<{
|
|
300
|
+
addWebMiddleware: (_input: any) => void;
|
|
301
|
+
addAPIMiddleware: (_input: any) => void;
|
|
302
|
+
}, unknown>;
|
|
303
|
+
config: import("@modern-js/plugin").Waterfall<ServerConfig>;
|
|
304
|
+
prepare: import("@modern-js/plugin").Waterfall<void>;
|
|
305
|
+
create: import("@modern-js/plugin").AsyncPipeline<ServerInitInput, InitExtension>;
|
|
306
|
+
prepareWebServer: import("@modern-js/plugin").AsyncPipeline<WebServerStartInput, Adapter>;
|
|
307
|
+
prepareApiServer: import("@modern-js/plugin").AsyncPipeline<APIServerStartInput, Adapter>;
|
|
308
|
+
beforeDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
309
|
+
setupCompiler: import("@modern-js/plugin").ParallelWorkflow<Record<string, unknown>, any[]>;
|
|
310
|
+
afterDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
311
|
+
beforeRouteSet: import("@modern-js/plugin").AsyncPipeline<Route[], Route[]>;
|
|
312
|
+
afterRouteSet: import("@modern-js/plugin").AsyncPipeline<unknown, unknown>;
|
|
313
|
+
preServerInit: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
314
|
+
postServerInit: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
315
|
+
listen: import("@modern-js/plugin").ParallelWorkflow<{
|
|
316
|
+
ip: string;
|
|
317
|
+
port: number;
|
|
318
|
+
}, any[]>;
|
|
319
|
+
beforeServerReset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
|
|
320
|
+
afterServerReset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
|
|
321
|
+
extendSSRContext: import("@modern-js/plugin").AsyncWaterfall<BaseSSRServerContext>;
|
|
322
|
+
extendContext: import("@modern-js/plugin").AsyncPipeline<ModernServerContext, ModernServerContext>;
|
|
323
|
+
handleError: import("@modern-js/plugin").ParallelWorkflow<{
|
|
324
|
+
error: Error;
|
|
325
|
+
}, unknown>;
|
|
326
|
+
beforeMatch: import("@modern-js/plugin").AsyncPipeline<{
|
|
327
|
+
context: ModernServerContext;
|
|
328
|
+
}, any>;
|
|
329
|
+
afterMatch: import("@modern-js/plugin").AsyncPipeline<{
|
|
330
|
+
context: ModernServerContext;
|
|
331
|
+
routeAPI: any;
|
|
332
|
+
}, any>;
|
|
333
|
+
prefetch: import("@modern-js/plugin").ParallelWorkflow<{
|
|
334
|
+
context: SSRServerContext;
|
|
335
|
+
}, unknown>;
|
|
336
|
+
renderToString: import("@modern-js/plugin").AsyncPipeline<{
|
|
337
|
+
App: Component;
|
|
338
|
+
context: RenderContext;
|
|
339
|
+
}, string>;
|
|
340
|
+
beforeRender: import("@modern-js/plugin").AsyncPipeline<{
|
|
341
|
+
context: ModernServerContext;
|
|
342
|
+
}, any>;
|
|
343
|
+
afterRender: import("@modern-js/plugin").AsyncPipeline<{
|
|
344
|
+
context: ModernServerContext;
|
|
345
|
+
templateAPI: any;
|
|
346
|
+
}, any>;
|
|
347
|
+
beforeSend: import("@modern-js/plugin").AsyncPipeline<ModernServerContext, RequestResult>;
|
|
348
|
+
afterSend: import("@modern-js/plugin").ParallelWorkflow<{
|
|
349
|
+
context: ModernServerContext;
|
|
350
|
+
}, unknown>;
|
|
351
|
+
reset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
|
|
346
352
|
}, AsyncSetup<{
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
353
|
+
gather: import("@modern-js/plugin").ParallelWorkflow<{
|
|
354
|
+
addWebMiddleware: (_input: any) => void;
|
|
355
|
+
addAPIMiddleware: (_input: any) => void;
|
|
356
|
+
}, unknown>;
|
|
357
|
+
config: import("@modern-js/plugin").Waterfall<ServerConfig>;
|
|
358
|
+
prepare: import("@modern-js/plugin").Waterfall<void>;
|
|
359
|
+
create: import("@modern-js/plugin").AsyncPipeline<ServerInitInput, InitExtension>;
|
|
360
|
+
prepareWebServer: import("@modern-js/plugin").AsyncPipeline<WebServerStartInput, Adapter>;
|
|
361
|
+
prepareApiServer: import("@modern-js/plugin").AsyncPipeline<APIServerStartInput, Adapter>;
|
|
362
|
+
beforeDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
363
|
+
setupCompiler: import("@modern-js/plugin").ParallelWorkflow<Record<string, unknown>, any[]>;
|
|
364
|
+
afterDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
365
|
+
beforeRouteSet: import("@modern-js/plugin").AsyncPipeline<Route[], Route[]>;
|
|
366
|
+
afterRouteSet: import("@modern-js/plugin").AsyncPipeline<unknown, unknown>;
|
|
367
|
+
preServerInit: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
368
|
+
postServerInit: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
369
|
+
listen: import("@modern-js/plugin").ParallelWorkflow<{
|
|
370
|
+
ip: string;
|
|
371
|
+
port: number;
|
|
372
|
+
}, any[]>;
|
|
373
|
+
beforeServerReset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
|
|
374
|
+
afterServerReset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
|
|
375
|
+
extendSSRContext: import("@modern-js/plugin").AsyncWaterfall<BaseSSRServerContext>;
|
|
376
|
+
extendContext: import("@modern-js/plugin").AsyncPipeline<ModernServerContext, ModernServerContext>;
|
|
377
|
+
handleError: import("@modern-js/plugin").ParallelWorkflow<{
|
|
378
|
+
error: Error;
|
|
379
|
+
}, unknown>;
|
|
380
|
+
beforeMatch: import("@modern-js/plugin").AsyncPipeline<{
|
|
381
|
+
context: ModernServerContext;
|
|
382
|
+
}, any>;
|
|
383
|
+
afterMatch: import("@modern-js/plugin").AsyncPipeline<{
|
|
384
|
+
context: ModernServerContext;
|
|
385
|
+
routeAPI: any;
|
|
386
|
+
}, any>;
|
|
387
|
+
prefetch: import("@modern-js/plugin").ParallelWorkflow<{
|
|
388
|
+
context: SSRServerContext;
|
|
389
|
+
}, unknown>;
|
|
390
|
+
renderToString: import("@modern-js/plugin").AsyncPipeline<{
|
|
391
|
+
App: Component;
|
|
392
|
+
context: RenderContext;
|
|
393
|
+
}, string>;
|
|
394
|
+
beforeRender: import("@modern-js/plugin").AsyncPipeline<{
|
|
395
|
+
context: ModernServerContext;
|
|
396
|
+
}, any>;
|
|
397
|
+
afterRender: import("@modern-js/plugin").AsyncPipeline<{
|
|
398
|
+
context: ModernServerContext;
|
|
399
|
+
templateAPI: any;
|
|
400
|
+
}, any>;
|
|
401
|
+
beforeSend: import("@modern-js/plugin").AsyncPipeline<ModernServerContext, RequestResult>;
|
|
402
|
+
afterSend: import("@modern-js/plugin").ParallelWorkflow<{
|
|
403
|
+
context: ModernServerContext;
|
|
404
|
+
}, unknown>;
|
|
405
|
+
reset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
|
|
400
406
|
}, {
|
|
401
|
-
|
|
402
|
-
|
|
407
|
+
useAppContext: () => ISAppContext;
|
|
408
|
+
useConfigContext: () => UserConfig;
|
|
403
409
|
}>> | undefined) => import("@modern-js/plugin").AsyncPlugin<{
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
410
|
+
gather: import("@modern-js/plugin").ParallelWorkflow<{
|
|
411
|
+
addWebMiddleware: (_input: any) => void;
|
|
412
|
+
addAPIMiddleware: (_input: any) => void;
|
|
413
|
+
}, unknown>;
|
|
414
|
+
config: import("@modern-js/plugin").Waterfall<ServerConfig>;
|
|
415
|
+
prepare: import("@modern-js/plugin").Waterfall<void>;
|
|
416
|
+
create: import("@modern-js/plugin").AsyncPipeline<ServerInitInput, InitExtension>;
|
|
417
|
+
prepareWebServer: import("@modern-js/plugin").AsyncPipeline<WebServerStartInput, Adapter>;
|
|
418
|
+
prepareApiServer: import("@modern-js/plugin").AsyncPipeline<APIServerStartInput, Adapter>;
|
|
419
|
+
beforeDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
420
|
+
setupCompiler: import("@modern-js/plugin").ParallelWorkflow<Record<string, unknown>, any[]>;
|
|
421
|
+
afterDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
422
|
+
beforeRouteSet: import("@modern-js/plugin").AsyncPipeline<Route[], Route[]>;
|
|
423
|
+
afterRouteSet: import("@modern-js/plugin").AsyncPipeline<unknown, unknown>;
|
|
424
|
+
preServerInit: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
425
|
+
postServerInit: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
426
|
+
listen: import("@modern-js/plugin").ParallelWorkflow<{
|
|
427
|
+
ip: string;
|
|
428
|
+
port: number;
|
|
429
|
+
}, any[]>;
|
|
430
|
+
beforeServerReset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
|
|
431
|
+
afterServerReset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
|
|
432
|
+
extendSSRContext: import("@modern-js/plugin").AsyncWaterfall<BaseSSRServerContext>;
|
|
433
|
+
extendContext: import("@modern-js/plugin").AsyncPipeline<ModernServerContext, ModernServerContext>;
|
|
434
|
+
handleError: import("@modern-js/plugin").ParallelWorkflow<{
|
|
435
|
+
error: Error;
|
|
436
|
+
}, unknown>;
|
|
437
|
+
beforeMatch: import("@modern-js/plugin").AsyncPipeline<{
|
|
438
|
+
context: ModernServerContext;
|
|
439
|
+
}, any>;
|
|
440
|
+
afterMatch: import("@modern-js/plugin").AsyncPipeline<{
|
|
441
|
+
context: ModernServerContext;
|
|
442
|
+
routeAPI: any;
|
|
443
|
+
}, any>;
|
|
444
|
+
prefetch: import("@modern-js/plugin").ParallelWorkflow<{
|
|
445
|
+
context: SSRServerContext;
|
|
446
|
+
}, unknown>;
|
|
447
|
+
renderToString: import("@modern-js/plugin").AsyncPipeline<{
|
|
448
|
+
App: Component;
|
|
449
|
+
context: RenderContext;
|
|
450
|
+
}, string>;
|
|
451
|
+
beforeRender: import("@modern-js/plugin").AsyncPipeline<{
|
|
452
|
+
context: ModernServerContext;
|
|
453
|
+
}, any>;
|
|
454
|
+
afterRender: import("@modern-js/plugin").AsyncPipeline<{
|
|
455
|
+
context: ModernServerContext;
|
|
456
|
+
templateAPI: any;
|
|
457
|
+
}, any>;
|
|
458
|
+
beforeSend: import("@modern-js/plugin").AsyncPipeline<ModernServerContext, RequestResult>;
|
|
459
|
+
afterSend: import("@modern-js/plugin").ParallelWorkflow<{
|
|
460
|
+
context: ModernServerContext;
|
|
461
|
+
}, unknown>;
|
|
462
|
+
reset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
|
|
457
463
|
}, {
|
|
458
|
-
|
|
459
|
-
|
|
464
|
+
useAppContext: () => ISAppContext;
|
|
465
|
+
useConfigContext: () => UserConfig;
|
|
460
466
|
}>;
|
|
461
|
-
export {};
|
|
467
|
+
export {};
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.2
|
|
14
|
+
"version": "1.3.2",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@modern-js/plugin": "^1.3.
|
|
32
|
-
"@modern-js/utils": "^1.
|
|
31
|
+
"@modern-js/plugin": "^1.3.3",
|
|
32
|
+
"@modern-js/utils": "^1.6.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@modern-js/core": "1.
|
|
36
|
-
"@modern-js/types": "
|
|
35
|
+
"@modern-js/core": "1.9.0",
|
|
36
|
+
"@modern-js/types": "1.5.1",
|
|
37
37
|
"@scripts/build": "0.0.0",
|
|
38
38
|
"@scripts/jest-config": "0.0.0",
|
|
39
39
|
"@types/jest": "^26",
|
|
@@ -53,8 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"registry": "https://registry.npmjs.org/",
|
|
56
|
-
"access": "public"
|
|
57
|
-
"types": "./dist/types/index.d.ts"
|
|
56
|
+
"access": "public"
|
|
58
57
|
},
|
|
59
58
|
"scripts": {
|
|
60
59
|
"new": "modern new",
|
package/tests/.eslintrc.js
DELETED
package/tests/loadPlugin.test.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import { loadPlugins } from '../src/loadPlugins';
|
|
3
|
-
|
|
4
|
-
const modulePath = path.join(__dirname, './fixtures/load-plugins');
|
|
5
|
-
describe('test load plugin', () => {
|
|
6
|
-
it('should load string plugin correctly', () => {
|
|
7
|
-
const loaded = loadPlugins(['test-a'], modulePath);
|
|
8
|
-
expect(loaded[0].pluginPath).toBe(
|
|
9
|
-
path.join(__dirname, './fixtures/load-plugins/test-a/index.js'),
|
|
10
|
-
);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it('should load plugin instance correctly', () => {
|
|
14
|
-
const loaded = loadPlugins(
|
|
15
|
-
[
|
|
16
|
-
{
|
|
17
|
-
name: 'modern',
|
|
18
|
-
},
|
|
19
|
-
],
|
|
20
|
-
modulePath,
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
expect(loaded[0].name).toBe('modern');
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('should throw error if plugin not found', () => {
|
|
27
|
-
try {
|
|
28
|
-
loadPlugins(['test-b'], modulePath);
|
|
29
|
-
} catch (e: any) {
|
|
30
|
-
expect(e.message).toMatch('Can not find plugin test-b.');
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
});
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { serverManager } from '../src';
|
|
2
|
-
import { ServerConfig } from '../src/plugin';
|
|
3
|
-
|
|
4
|
-
describe('Default cases', () => {
|
|
5
|
-
it('Have returns plugins', async () => {
|
|
6
|
-
let count = 0;
|
|
7
|
-
|
|
8
|
-
serverManager.usePlugin(
|
|
9
|
-
serverManager.createPlugin(() => ({
|
|
10
|
-
prepareApiServer: () => {
|
|
11
|
-
count = 1;
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
13
|
-
return () => {};
|
|
14
|
-
},
|
|
15
|
-
})),
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
const runner = await serverManager.init();
|
|
19
|
-
await runner.prepareApiServer({ pwd: '', mode: 'function', config: {} });
|
|
20
|
-
|
|
21
|
-
expect(count).toBe(1);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('config hook should works correctly', async () => {
|
|
25
|
-
const proxy = {
|
|
26
|
-
'/bff': {
|
|
27
|
-
target: 'https://modernjs.dev',
|
|
28
|
-
changeOrigin: true,
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
const expectedServerConfig = {
|
|
32
|
-
bff: {
|
|
33
|
-
proxy,
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
let receivedServerConfig: ServerConfig = {};
|
|
37
|
-
|
|
38
|
-
serverManager.usePlugin(
|
|
39
|
-
serverManager.createPlugin(() => ({
|
|
40
|
-
config(serverConfig) {
|
|
41
|
-
serverConfig.bff = {
|
|
42
|
-
proxy,
|
|
43
|
-
};
|
|
44
|
-
return serverConfig;
|
|
45
|
-
},
|
|
46
|
-
})),
|
|
47
|
-
|
|
48
|
-
serverManager.createPlugin(() => ({
|
|
49
|
-
config(serverConfig) {
|
|
50
|
-
receivedServerConfig = serverConfig;
|
|
51
|
-
return receivedServerConfig;
|
|
52
|
-
},
|
|
53
|
-
})),
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
const runner = await serverManager.init();
|
|
57
|
-
runner.config({});
|
|
58
|
-
expect(expectedServerConfig).toEqual(receivedServerConfig);
|
|
59
|
-
});
|
|
60
|
-
});
|