@modern-js/server-core 1.3.0 → 1.3.1
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 +13 -0
- 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,18 @@
|
|
|
1
1
|
# @modern-js/server-plugin
|
|
2
2
|
|
|
3
|
+
## 1.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 04ae5262: chore: bump @modern-js/utils to v1.4.1 in dependencies
|
|
8
|
+
- 60f7d8bf: feat: add tests dir to npmignore
|
|
9
|
+
- Updated dependencies [b8599d09]
|
|
10
|
+
- Updated dependencies [6cffe99d]
|
|
11
|
+
- Updated dependencies [60f7d8bf]
|
|
12
|
+
- Updated dependencies [3bf4f8b0]
|
|
13
|
+
- @modern-js/utils@1.5.0
|
|
14
|
+
- @modern-js/plugin@1.3.3
|
|
15
|
+
|
|
3
16
|
## 1.3.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
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.1",
|
|
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.5.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@modern-js/core": "1.
|
|
36
|
-
"@modern-js/types": "^1.
|
|
35
|
+
"@modern-js/core": "1.8.0",
|
|
36
|
+
"@modern-js/types": "^1.5.0",
|
|
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
|
-
});
|