@modern-js/server-core 1.3.0 → 1.3.3
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 +39 -0
- package/dist/js/modern/plugin.js +4 -4
- package/dist/js/node/plugin.js +4 -4
- package/dist/types/plugin.d.ts +14 -14
- package/package.json +5 -5
- 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,44 @@
|
|
|
1
1
|
# @modern-js/server-plugin
|
|
2
2
|
|
|
3
|
+
## 1.3.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 6fa74d5f: add internal metrics and logger
|
|
8
|
+
- Updated dependencies [0ee4bb4e]
|
|
9
|
+
- Updated dependencies [6fa74d5f]
|
|
10
|
+
- @modern-js/utils@1.7.0
|
|
11
|
+
|
|
12
|
+
## 1.3.2
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 895fa0ff: chore: using "workspace:\*" in devDependencies
|
|
17
|
+
- Updated dependencies [2d155c4c]
|
|
18
|
+
- Updated dependencies [123e432d]
|
|
19
|
+
- Updated dependencies [e5a9b26d]
|
|
20
|
+
- Updated dependencies [0b26b93b]
|
|
21
|
+
- Updated dependencies [123e432d]
|
|
22
|
+
- Updated dependencies [f9f66ef9]
|
|
23
|
+
- Updated dependencies [592edabc]
|
|
24
|
+
- Updated dependencies [895fa0ff]
|
|
25
|
+
- Updated dependencies [3578913e]
|
|
26
|
+
- Updated dependencies [1c3beab3]
|
|
27
|
+
- @modern-js/utils@1.6.0
|
|
28
|
+
|
|
29
|
+
## 1.3.1
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- 04ae5262: chore: bump @modern-js/utils to v1.4.1 in dependencies
|
|
34
|
+
- 60f7d8bf: feat: add tests dir to npmignore
|
|
35
|
+
- Updated dependencies [b8599d09]
|
|
36
|
+
- Updated dependencies [6cffe99d]
|
|
37
|
+
- Updated dependencies [60f7d8bf]
|
|
38
|
+
- Updated dependencies [3bf4f8b0]
|
|
39
|
+
- @modern-js/utils@1.5.0
|
|
40
|
+
- @modern-js/plugin@1.3.3
|
|
41
|
+
|
|
3
42
|
## 1.3.0
|
|
4
43
|
|
|
5
44
|
### Minor Changes
|
package/dist/js/modern/plugin.js
CHANGED
|
@@ -15,8 +15,8 @@ const afterDevServer = createParallelWorkflow(); // TODO FIXME
|
|
|
15
15
|
|
|
16
16
|
const beforeRouteSet = createAsyncPipeline();
|
|
17
17
|
const afterRouteSet = createAsyncPipeline();
|
|
18
|
-
const
|
|
19
|
-
const
|
|
18
|
+
const beforeProdServer = createParallelWorkflow();
|
|
19
|
+
const afterProdServer = createParallelWorkflow();
|
|
20
20
|
const listen = createParallelWorkflow();
|
|
21
21
|
const beforeServerReset = createParallelWorkflow();
|
|
22
22
|
const afterServerReset = createParallelWorkflow();
|
|
@@ -63,8 +63,8 @@ const serverHooks = {
|
|
|
63
63
|
afterDevServer,
|
|
64
64
|
beforeRouteSet,
|
|
65
65
|
afterRouteSet,
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
beforeProdServer,
|
|
67
|
+
afterProdServer,
|
|
68
68
|
listen,
|
|
69
69
|
beforeServerReset,
|
|
70
70
|
afterServerReset,
|
package/dist/js/node/plugin.js
CHANGED
|
@@ -24,8 +24,8 @@ const afterDevServer = (0, _plugin.createParallelWorkflow)(); // TODO FIXME
|
|
|
24
24
|
|
|
25
25
|
const beforeRouteSet = (0, _plugin.createAsyncPipeline)();
|
|
26
26
|
const afterRouteSet = (0, _plugin.createAsyncPipeline)();
|
|
27
|
-
const
|
|
28
|
-
const
|
|
27
|
+
const beforeProdServer = (0, _plugin.createParallelWorkflow)();
|
|
28
|
+
const afterProdServer = (0, _plugin.createParallelWorkflow)();
|
|
29
29
|
const listen = (0, _plugin.createParallelWorkflow)();
|
|
30
30
|
const beforeServerReset = (0, _plugin.createParallelWorkflow)();
|
|
31
31
|
const afterServerReset = (0, _plugin.createParallelWorkflow)();
|
|
@@ -80,8 +80,8 @@ const serverHooks = {
|
|
|
80
80
|
afterDevServer,
|
|
81
81
|
beforeRouteSet,
|
|
82
82
|
afterRouteSet,
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
beforeProdServer,
|
|
84
|
+
afterProdServer,
|
|
85
85
|
listen,
|
|
86
86
|
beforeServerReset,
|
|
87
87
|
afterServerReset,
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -64,8 +64,8 @@ declare const serverHooks: {
|
|
|
64
64
|
afterDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
65
65
|
beforeRouteSet: import("@modern-js/plugin").AsyncPipeline<Route[], Route[]>;
|
|
66
66
|
afterRouteSet: import("@modern-js/plugin").AsyncPipeline<unknown, unknown>;
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
beforeProdServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
68
|
+
afterProdServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
69
69
|
listen: import("@modern-js/plugin").ParallelWorkflow<{
|
|
70
70
|
ip: string;
|
|
71
71
|
port: number;
|
|
@@ -128,8 +128,8 @@ export declare const createServerManager: () => import("@modern-js/plugin").Asyn
|
|
|
128
128
|
afterDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
129
129
|
beforeRouteSet: import("@modern-js/plugin").AsyncPipeline<Route[], Route[]>;
|
|
130
130
|
afterRouteSet: import("@modern-js/plugin").AsyncPipeline<unknown, unknown>;
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
beforeProdServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
132
|
+
afterProdServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
133
133
|
listen: import("@modern-js/plugin").ParallelWorkflow<{
|
|
134
134
|
ip: string;
|
|
135
135
|
port: number;
|
|
@@ -186,8 +186,8 @@ export declare const serverManager: import("@modern-js/plugin").AsyncManager<{
|
|
|
186
186
|
afterDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
187
187
|
beforeRouteSet: import("@modern-js/plugin").AsyncPipeline<Route[], Route[]>;
|
|
188
188
|
afterRouteSet: import("@modern-js/plugin").AsyncPipeline<unknown, unknown>;
|
|
189
|
-
|
|
190
|
-
|
|
189
|
+
beforeProdServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
190
|
+
afterProdServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
191
191
|
listen: import("@modern-js/plugin").ParallelWorkflow<{
|
|
192
192
|
ip: string;
|
|
193
193
|
port: number;
|
|
@@ -253,8 +253,8 @@ export declare const createPlugin: (setup?: AsyncSetup<{
|
|
|
253
253
|
afterDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
254
254
|
beforeRouteSet: import("@modern-js/plugin").AsyncPipeline<Route[], Route[]>;
|
|
255
255
|
afterRouteSet: import("@modern-js/plugin").AsyncPipeline<unknown, unknown>;
|
|
256
|
-
|
|
257
|
-
|
|
256
|
+
beforeProdServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
257
|
+
afterProdServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
258
258
|
listen: import("@modern-js/plugin").ParallelWorkflow<{
|
|
259
259
|
ip: string;
|
|
260
260
|
port: number;
|
|
@@ -310,8 +310,8 @@ export declare const createPlugin: (setup?: AsyncSetup<{
|
|
|
310
310
|
afterDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
311
311
|
beforeRouteSet: import("@modern-js/plugin").AsyncPipeline<Route[], Route[]>;
|
|
312
312
|
afterRouteSet: import("@modern-js/plugin").AsyncPipeline<unknown, unknown>;
|
|
313
|
-
|
|
314
|
-
|
|
313
|
+
beforeProdServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
314
|
+
afterProdServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
315
315
|
listen: import("@modern-js/plugin").ParallelWorkflow<{
|
|
316
316
|
ip: string;
|
|
317
317
|
port: number;
|
|
@@ -364,8 +364,8 @@ export declare const createPlugin: (setup?: AsyncSetup<{
|
|
|
364
364
|
afterDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
365
365
|
beforeRouteSet: import("@modern-js/plugin").AsyncPipeline<Route[], Route[]>;
|
|
366
366
|
afterRouteSet: import("@modern-js/plugin").AsyncPipeline<unknown, unknown>;
|
|
367
|
-
|
|
368
|
-
|
|
367
|
+
beforeProdServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
368
|
+
afterProdServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
369
369
|
listen: import("@modern-js/plugin").ParallelWorkflow<{
|
|
370
370
|
ip: string;
|
|
371
371
|
port: number;
|
|
@@ -421,8 +421,8 @@ export declare const createPlugin: (setup?: AsyncSetup<{
|
|
|
421
421
|
afterDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
422
422
|
beforeRouteSet: import("@modern-js/plugin").AsyncPipeline<Route[], Route[]>;
|
|
423
423
|
afterRouteSet: import("@modern-js/plugin").AsyncPipeline<unknown, unknown>;
|
|
424
|
-
|
|
425
|
-
|
|
424
|
+
beforeProdServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
425
|
+
afterProdServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
426
426
|
listen: import("@modern-js/plugin").ParallelWorkflow<{
|
|
427
427
|
ip: string;
|
|
428
428
|
port: number;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.3.
|
|
14
|
+
"version": "1.3.3",
|
|
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.7.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@modern-js/core": "1.
|
|
36
|
-
"@modern-js/types": "
|
|
35
|
+
"@modern-js/core": "1.10.0",
|
|
36
|
+
"@modern-js/types": "1.5.2",
|
|
37
37
|
"@scripts/build": "0.0.0",
|
|
38
38
|
"@scripts/jest-config": "0.0.0",
|
|
39
39
|
"@types/jest": "^26",
|
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
|
-
});
|