@modern-js/core 1.6.0 → 1.7.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 +31 -0
- package/dist/js/modern/config/index.js +11 -7
- package/dist/js/modern/config/mergeConfig.js +1 -1
- package/dist/js/modern/config/schema/index.js +1 -1
- package/dist/js/modern/config/types/index.js +1 -0
- package/dist/js/modern/config/types/less.js +0 -0
- package/dist/js/modern/config/types/sass.js +0 -0
- package/dist/js/modern/config/types/ssg.js +0 -0
- package/dist/js/modern/config/types/test.js +0 -0
- package/dist/js/modern/config/types/unbundle.js +0 -0
- package/dist/js/modern/context.js +8 -1
- package/dist/js/modern/index.js +26 -9
- package/dist/js/modern/initWatcher.js +2 -2
- package/dist/js/modern/utils/commander.js +15 -15
- package/dist/js/node/config/index.js +38 -11
- package/dist/js/node/config/mergeConfig.js +2 -4
- package/dist/js/node/config/schema/index.js +3 -5
- package/dist/js/node/config/types/index.js +5 -0
- package/dist/js/node/config/types/less.js +0 -0
- package/dist/js/node/config/types/sass.js +0 -0
- package/dist/js/node/config/types/ssg.js +0 -0
- package/dist/js/node/config/types/test.js +0 -0
- package/dist/js/node/config/types/unbundle.js +0 -0
- package/dist/js/node/context.js +8 -1
- package/dist/js/node/index.js +31 -10
- package/dist/js/node/initWatcher.js +2 -3
- package/dist/js/node/utils/commander.js +16 -19
- package/dist/types/config/index.d.ts +4 -140
- package/dist/types/config/types/index.d.ts +239 -0
- package/dist/types/config/types/less.d.ts +10 -0
- package/dist/types/config/types/sass.d.ts +8 -0
- package/dist/types/config/types/ssg.d.ts +13 -0
- package/dist/types/config/types/test.d.ts +15 -0
- package/dist/types/config/types/unbundle.d.ts +28 -0
- package/dist/types/context.d.ts +18 -6
- package/dist/types/index.d.ts +25 -1
- package/dist/types/initWatcher.d.ts +1 -2
- package/dist/types/utils/commander.d.ts +4 -7
- package/jest.config.js +0 -1
- package/package.json +16 -16
- package/tests/config.test.ts +14 -5
- package/tests/context.test.ts +17 -2
- package/tests/fixtures/index-test/modern.server-runtime.config.js +0 -0
- package/tests/index.test.ts +15 -1
- package/tests/initWatcher.test.ts +2 -2
- package/tests/utils.test.ts +1 -2
package/tests/context.test.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
|
+
import { DEFAULT_SERVER_CONFIG } from '@modern-js/utils';
|
|
2
3
|
import { initAppContext } from '../src/context';
|
|
3
4
|
|
|
4
5
|
describe('context', () => {
|
|
@@ -7,10 +8,17 @@ describe('context', () => {
|
|
|
7
8
|
__dirname,
|
|
8
9
|
'./fixtures/load-plugin/user-plugins',
|
|
9
10
|
);
|
|
10
|
-
const appContext = initAppContext(
|
|
11
|
+
const appContext = initAppContext({
|
|
12
|
+
appDirectory,
|
|
13
|
+
plugins: [],
|
|
14
|
+
configFile: false,
|
|
15
|
+
serverConfigFile: DEFAULT_SERVER_CONFIG,
|
|
16
|
+
});
|
|
17
|
+
|
|
11
18
|
expect(appContext).toEqual({
|
|
12
19
|
appDirectory,
|
|
13
20
|
configFile: false,
|
|
21
|
+
serverConfigFile: DEFAULT_SERVER_CONFIG,
|
|
14
22
|
ip: expect.any(String),
|
|
15
23
|
port: 0,
|
|
16
24
|
packageName: expect.any(String),
|
|
@@ -44,10 +52,17 @@ describe('context', () => {
|
|
|
44
52
|
metaName: 'jupiter',
|
|
45
53
|
};
|
|
46
54
|
|
|
47
|
-
const appContext = initAppContext(
|
|
55
|
+
const appContext = initAppContext({
|
|
56
|
+
appDirectory,
|
|
57
|
+
plugins: [],
|
|
58
|
+
configFile: false,
|
|
59
|
+
options: customOptions,
|
|
60
|
+
serverConfigFile: DEFAULT_SERVER_CONFIG,
|
|
61
|
+
});
|
|
48
62
|
expect(appContext).toEqual({
|
|
49
63
|
appDirectory,
|
|
50
64
|
configFile: false,
|
|
65
|
+
serverConfigFile: DEFAULT_SERVER_CONFIG,
|
|
51
66
|
ip: expect.any(String),
|
|
52
67
|
port: 0,
|
|
53
68
|
packageName: 'user-plugins',
|
|
File without changes
|
package/tests/index.test.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
|
-
import { cli } from '../src';
|
|
2
|
+
import { cli, mergeOptions } from '../src';
|
|
3
3
|
import { resolveConfig, loadUserConfig } from '../src/config';
|
|
4
4
|
import { loadEnv } from '../src/loadEnv';
|
|
5
5
|
|
|
@@ -67,3 +67,17 @@ describe('@modern-js/core test', () => {
|
|
|
67
67
|
// TODO: add more test cases
|
|
68
68
|
});
|
|
69
69
|
});
|
|
70
|
+
|
|
71
|
+
describe('test mergeOptions', () => {
|
|
72
|
+
it('serverConfigFile must exist', () => {
|
|
73
|
+
const options = mergeOptions({});
|
|
74
|
+
expect(options).toHaveProperty('serverConfigFile');
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('serverConfigFile can be overwritten', () => {
|
|
78
|
+
const options = mergeOptions({
|
|
79
|
+
serverConfigFile: 'test',
|
|
80
|
+
});
|
|
81
|
+
expect(options.serverConfigFile).toBe('test');
|
|
82
|
+
});
|
|
83
|
+
});
|
|
@@ -8,7 +8,7 @@ const mockAppDirectory = path.join(__dirname, './fixtures/index-test');
|
|
|
8
8
|
const mockConfigDir = './config';
|
|
9
9
|
const mockSrcDirectory = path.join(mockAppDirectory, './src');
|
|
10
10
|
|
|
11
|
-
describe
|
|
11
|
+
describe('initWatcher', () => {
|
|
12
12
|
afterAll(() => {
|
|
13
13
|
const file = path.join(mockSrcDirectory, './index.ts');
|
|
14
14
|
if (fs.existsSync(file)) {
|
|
@@ -16,7 +16,7 @@ describe.skip('initWatcher', () => {
|
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
xtest('will trigger add event', async () => {
|
|
20
20
|
let triggeredType = '';
|
|
21
21
|
let triggeredFile = '';
|
|
22
22
|
const loaded = {
|
package/tests/utils.test.ts
CHANGED