@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.
Files changed (46) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/js/modern/config/index.js +11 -7
  3. package/dist/js/modern/config/mergeConfig.js +1 -1
  4. package/dist/js/modern/config/schema/index.js +1 -1
  5. package/dist/js/modern/config/types/index.js +1 -0
  6. package/dist/js/modern/config/types/less.js +0 -0
  7. package/dist/js/modern/config/types/sass.js +0 -0
  8. package/dist/js/modern/config/types/ssg.js +0 -0
  9. package/dist/js/modern/config/types/test.js +0 -0
  10. package/dist/js/modern/config/types/unbundle.js +0 -0
  11. package/dist/js/modern/context.js +8 -1
  12. package/dist/js/modern/index.js +26 -9
  13. package/dist/js/modern/initWatcher.js +2 -2
  14. package/dist/js/modern/utils/commander.js +15 -15
  15. package/dist/js/node/config/index.js +38 -11
  16. package/dist/js/node/config/mergeConfig.js +2 -4
  17. package/dist/js/node/config/schema/index.js +3 -5
  18. package/dist/js/node/config/types/index.js +5 -0
  19. package/dist/js/node/config/types/less.js +0 -0
  20. package/dist/js/node/config/types/sass.js +0 -0
  21. package/dist/js/node/config/types/ssg.js +0 -0
  22. package/dist/js/node/config/types/test.js +0 -0
  23. package/dist/js/node/config/types/unbundle.js +0 -0
  24. package/dist/js/node/context.js +8 -1
  25. package/dist/js/node/index.js +31 -10
  26. package/dist/js/node/initWatcher.js +2 -3
  27. package/dist/js/node/utils/commander.js +16 -19
  28. package/dist/types/config/index.d.ts +4 -140
  29. package/dist/types/config/types/index.d.ts +239 -0
  30. package/dist/types/config/types/less.d.ts +10 -0
  31. package/dist/types/config/types/sass.d.ts +8 -0
  32. package/dist/types/config/types/ssg.d.ts +13 -0
  33. package/dist/types/config/types/test.d.ts +15 -0
  34. package/dist/types/config/types/unbundle.d.ts +28 -0
  35. package/dist/types/context.d.ts +18 -6
  36. package/dist/types/index.d.ts +25 -1
  37. package/dist/types/initWatcher.d.ts +1 -2
  38. package/dist/types/utils/commander.d.ts +4 -7
  39. package/jest.config.js +0 -1
  40. package/package.json +16 -16
  41. package/tests/config.test.ts +14 -5
  42. package/tests/context.test.ts +17 -2
  43. package/tests/fixtures/index-test/modern.server-runtime.config.js +0 -0
  44. package/tests/index.test.ts +15 -1
  45. package/tests/initWatcher.test.ts +2 -2
  46. package/tests/utils.test.ts +1 -2
@@ -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(appDirectory, [], false);
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(appDirectory, [], false, customOptions);
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',
@@ -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.skip('initWatcher', () => {
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
- test('will trigger add event', async () => {
19
+ xtest('will trigger add event', async () => {
20
20
  let triggeredType = '';
21
21
  let triggeredFile = '';
22
22
  const loaded = {
@@ -1,8 +1,7 @@
1
- import { program, Command } from '../src/utils/commander';
1
+ import { program } from '../src/utils/commander';
2
2
 
3
3
  describe('utils', () => {
4
4
  it('default', () => {
5
5
  expect(program).toBeDefined();
6
- expect(Command).toBeDefined();
7
6
  });
8
7
  });