@modern-js/core 0.0.0-windows-20211056953 → 0.0.3-20221226

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 (130) hide show
  1. package/CHANGELOG.md +1164 -6
  2. package/dist/bin.d.ts +2 -0
  3. package/dist/bin.js +5 -0
  4. package/dist/config/createDefaultConfig.d.ts +2 -0
  5. package/dist/config/createDefaultConfig.js +9 -0
  6. package/dist/config/createLoadedConfig.d.ts +6 -0
  7. package/dist/config/createLoadedConfig.js +35 -0
  8. package/dist/config/createResolvedConfig.d.ts +3 -0
  9. package/dist/config/createResolvedConfig.js +92 -0
  10. package/dist/config/index.d.ts +3 -0
  11. package/dist/config/index.js +19 -0
  12. package/dist/context.d.ts +35 -0
  13. package/dist/context.js +61 -0
  14. package/dist/index.d.ts +73 -0
  15. package/dist/index.js +150 -0
  16. package/dist/load-configs/index.d.ts +34 -0
  17. package/dist/load-configs/index.js +124 -0
  18. package/dist/{types/loadEnv.d.ts → loadEnv.d.ts} +1 -1
  19. package/dist/loadEnv.js +21 -0
  20. package/dist/loadPlugins.d.ts +18 -0
  21. package/dist/loadPlugins.js +65 -0
  22. package/dist/manager.d.ts +87 -0
  23. package/dist/manager.js +24 -0
  24. package/dist/runBin.d.ts +5 -0
  25. package/dist/runBin.js +51 -0
  26. package/dist/schema/patchSchema.d.ts +19 -0
  27. package/dist/schema/patchSchema.js +57 -0
  28. package/dist/schema/source.d.ts +9 -0
  29. package/dist/schema/source.js +10 -0
  30. package/dist/schema/testing.d.ts +13 -0
  31. package/dist/schema/testing.js +11 -0
  32. package/dist/schema/traverseSchema.d.ts +2 -0
  33. package/dist/schema/traverseSchema.js +20 -0
  34. package/dist/types/config/index.d.ts +49 -125
  35. package/dist/types/config/index.js +2 -0
  36. package/dist/types/config/testing.d.ts +15 -0
  37. package/dist/types/config/testing.js +2 -0
  38. package/dist/types/context.d.ts +28 -14
  39. package/dist/types/context.js +2 -0
  40. package/dist/types/hooks.d.ts +44 -0
  41. package/dist/types/hooks.js +2 -0
  42. package/dist/types/index.d.ts +9 -87
  43. package/dist/types/index.js +21 -0
  44. package/dist/types/plugin.d.ts +26 -0
  45. package/dist/types/plugin.js +2 -0
  46. package/dist/types/pluginAPI.d.ts +18 -0
  47. package/dist/types/pluginAPI.js +2 -0
  48. package/dist/utils/commander.d.ts +4 -0
  49. package/dist/utils/commander.js +20 -0
  50. package/dist/utils/mergeConfig.d.ts +2 -0
  51. package/dist/utils/mergeConfig.js +32 -0
  52. package/dist/utils/repeatKeyWarning.d.ts +3 -0
  53. package/dist/utils/repeatKeyWarning.js +22 -0
  54. package/package.json +52 -48
  55. package/bin/modern-js.js +0 -18
  56. package/dist/js/modern/config/defaults.js +0 -100
  57. package/dist/js/modern/config/index.js +0 -104
  58. package/dist/js/modern/config/mergeConfig.js +0 -20
  59. package/dist/js/modern/config/schema/deploy.js +0 -20
  60. package/dist/js/modern/config/schema/index.js +0 -107
  61. package/dist/js/modern/config/schema/output.js +0 -147
  62. package/dist/js/modern/config/schema/server.js +0 -170
  63. package/dist/js/modern/config/schema/source.js +0 -59
  64. package/dist/js/modern/config/schema/tools.js +0 -33
  65. package/dist/js/modern/context.js +0 -25
  66. package/dist/js/modern/index.js +0 -142
  67. package/dist/js/modern/initWatcher.js +0 -46
  68. package/dist/js/modern/loadEnv.js +0 -12
  69. package/dist/js/modern/loadPlugins.js +0 -66
  70. package/dist/js/modern/utils/commander.js +0 -19
  71. package/dist/js/modern/utils/repeatKeyWarning.js +0 -18
  72. package/dist/js/node/config/defaults.js +0 -107
  73. package/dist/js/node/config/index.js +0 -142
  74. package/dist/js/node/config/mergeConfig.js +0 -32
  75. package/dist/js/node/config/schema/deploy.js +0 -29
  76. package/dist/js/node/config/schema/index.js +0 -129
  77. package/dist/js/node/config/schema/output.js +0 -156
  78. package/dist/js/node/config/schema/server.js +0 -179
  79. package/dist/js/node/config/schema/source.js +0 -68
  80. package/dist/js/node/config/schema/tools.js +0 -40
  81. package/dist/js/node/context.js +0 -52
  82. package/dist/js/node/index.js +0 -247
  83. package/dist/js/node/initWatcher.js +0 -67
  84. package/dist/js/node/loadEnv.js +0 -28
  85. package/dist/js/node/loadPlugins.js +0 -76
  86. package/dist/js/node/utils/commander.js +0 -35
  87. package/dist/js/node/utils/repeatKeyWarning.js +0 -31
  88. package/dist/types/config/defaults.d.ts +0 -25
  89. package/dist/types/config/mergeConfig.d.ts +0 -29
  90. package/dist/types/config/schema/deploy.d.ts +0 -19
  91. package/dist/types/config/schema/index.d.ts +0 -466
  92. package/dist/types/config/schema/output.d.ts +0 -146
  93. package/dist/types/config/schema/server.d.ts +0 -182
  94. package/dist/types/config/schema/source.d.ts +0 -58
  95. package/dist/types/config/schema/tools.d.ts +0 -33
  96. package/dist/types/initWatcher.d.ts +0 -3
  97. package/dist/types/loadPlugins.d.ts +0 -16
  98. package/dist/types/utils/commander.d.ts +0 -7
  99. package/dist/types/utils/repeatKeyWarning.d.ts +0 -3
  100. package/modern.config.js +0 -13
  101. package/src/config/defaults.ts +0 -101
  102. package/src/config/index.ts +0 -296
  103. package/src/config/mergeConfig.ts +0 -68
  104. package/src/config/schema/deploy.ts +0 -17
  105. package/src/config/schema/index.ts +0 -116
  106. package/src/config/schema/output.ts +0 -66
  107. package/src/config/schema/server.ts +0 -106
  108. package/src/config/schema/source.ts +0 -34
  109. package/src/config/schema/tools.ts +0 -15
  110. package/src/context.ts +0 -46
  111. package/src/index.ts +0 -247
  112. package/src/initWatcher.ts +0 -77
  113. package/src/loadEnv.ts +0 -21
  114. package/src/loadPlugins.ts +0 -81
  115. package/src/types.d.ts +0 -0
  116. package/src/utils/commander.ts +0 -22
  117. package/src/utils/repeatKeyWarning.ts +0 -29
  118. package/tests/.eslintrc.js +0 -6
  119. package/tests/fixtures/load-plugin/not-found/package.json +0 -3
  120. package/tests/fixtures/load-plugin/not-found/test-plugin-a.js +0 -1
  121. package/tests/fixtures/load-plugin/user-plugins/package.json +0 -3
  122. package/tests/fixtures/load-plugin/user-plugins/test-plugin-a.js +0 -1
  123. package/tests/fixtures/load-plugin/user-plugins/test-plugin-b.js +0 -3
  124. package/tests/loadEnv.test.ts +0 -100
  125. package/tests/loadPlugin.test.ts +0 -29
  126. package/tests/mergeConfig.test.ts +0 -78
  127. package/tests/repeatKeyWarning.test.ts +0 -68
  128. package/tests/schema.test.ts +0 -109
  129. package/tests/tsconfig.json +0 -13
  130. package/tsconfig.json +0 -14
@@ -1,78 +0,0 @@
1
- import { mergeConfig } from '@/config/mergeConfig';
2
-
3
- describe('load plugins', () => {
4
- test('should replace property deeply', () => {
5
- expect(
6
- mergeConfig([
7
- {
8
- source: { disableDefaultEntries: false },
9
- output: { polyfill: 'usage' },
10
- },
11
- {
12
- source: { disableDefaultEntries: true },
13
- output: { polyfill: 'entry' },
14
- },
15
- ]),
16
- ).toEqual({
17
- source: { disableDefaultEntries: true },
18
- output: { polyfill: 'entry' },
19
- });
20
- });
21
-
22
- test(`should set value when property value is undefined `, () => {
23
- expect(
24
- mergeConfig([
25
- { source: { entries: { app: './App.tsx' } } },
26
- { source: { entries: { app2: './src/App2.tsx' } } },
27
- { server: { baseUrl: './a' } },
28
- ]),
29
- ).toEqual({
30
- source: {
31
- entries: {
32
- app: './App.tsx',
33
- app2: './src/App2.tsx',
34
- },
35
- },
36
- server: { baseUrl: './a' },
37
- });
38
- });
39
-
40
- test(`should merge array value`, () => {
41
- expect(
42
- mergeConfig([
43
- { source: { envVars: ['a', 'b'] } },
44
- { source: { globalVars: { A: '1' } } },
45
- {
46
- source: {
47
- disableDefaultEntries: true,
48
- envVars: ['c', 'd'],
49
- globalVars: { B: '2' },
50
- },
51
- },
52
- ]),
53
- ).toEqual({
54
- source: {
55
- disableDefaultEntries: true,
56
- envVars: ['a', 'b', 'c', 'd'],
57
- globalVars: {
58
- A: '1',
59
- B: '2',
60
- },
61
- },
62
- });
63
- });
64
-
65
- test(`should merge function and object value`, () => {
66
- const config = mergeConfig([
67
- { source: { alias: { a: 'b' } } },
68
- { source: { alias: () => ({ c: 'd' }) } },
69
- { tools: { webpack: () => ({}) } },
70
- ]);
71
- expect(Array.isArray(config.source.alias)).toBe(true);
72
- expect(config?.source?.alias?.length).toBe(2);
73
- expect(typeof (config.source.alias as Array<any>)[1]).toBe('function');
74
-
75
- expect(Array.isArray(config.tools.webpack)).toBe(true);
76
- expect(config.tools.webpack?.length).toBe(1);
77
- });
78
- });
@@ -1,68 +0,0 @@
1
- import { repeatKeyWarning } from '@/utils/repeatKeyWarning';
2
- import { UserConfig } from '@/config';
3
-
4
- jest.spyOn(process, 'exit').mockImplementation();
5
-
6
- describe('check repeated keys in user config', () => {
7
- test(`should exit with error`, () => {
8
- expect(() => {
9
- repeatKeyWarning(
10
- {
11
- type: 'object',
12
- properties: {
13
- a: {
14
- type: 'object',
15
- properties: {
16
- b: {
17
- type: 'object',
18
- properties: { c: { type: ['boolean', 'object'] } },
19
- },
20
- },
21
- },
22
- },
23
- },
24
- { a: { b: { c: true } } } as UserConfig,
25
- { a: { b: { c: false } } } as UserConfig,
26
- );
27
- }).toThrowError(
28
- 'The same configuration a.b.c exists in modern.config.js and package.json.',
29
- );
30
- });
31
-
32
- test(`should exit succcessfully`, () => {
33
- expect(
34
- repeatKeyWarning(
35
- {
36
- type: 'object',
37
- properties: {
38
- a: {
39
- type: 'object',
40
- properties: { b: { type: 'string' } },
41
- },
42
- },
43
- c: {
44
- type: 'object',
45
- proeperties: {
46
- d: {
47
- type: 'object',
48
- properties: { e: { type: 'string' } },
49
- },
50
- f: { type: 'string' },
51
- },
52
- },
53
- },
54
- {
55
- a: { b: 'name' },
56
- c: { d: { e: 's' } },
57
- } as UserConfig,
58
- {
59
- a: {},
60
- c: {
61
- d: {},
62
- f: 'ss',
63
- },
64
- } as UserConfig,
65
- ),
66
- ).toBeUndefined();
67
- });
68
- });
@@ -1,109 +0,0 @@
1
- import { patchSchema, traverseSchema } from '@/config/schema';
2
-
3
- describe('patch schemas', () => {
4
- test('should add schema succcessfully', () => {
5
- const schema = patchSchema([
6
- {
7
- target: 'foo',
8
- schema: { type: 'string' },
9
- },
10
- {
11
- target: 'deploy.microFrontend.foo',
12
- schema: { type: 'number' },
13
- },
14
- ]);
15
-
16
- expect(schema.properties).toHaveProperty('foo');
17
-
18
- expect(
19
- schema.properties.deploy.properties.microFrontend.properties,
20
- ).toHaveProperty('foo');
21
- });
22
-
23
- test('should throw error when node is undefined', () => {
24
- expect(() => {
25
- patchSchema([
26
- {
27
- target: 'deploy.a.foo',
28
- schema: { type: 'string' },
29
- },
30
- ]);
31
- }).toThrowError(/^add schema deploy\.a error$/);
32
- });
33
-
34
- test(`should throw error on empty target property`, () => {
35
- expect(() => {
36
- patchSchema([
37
- {
38
- target: '',
39
- schema: { type: 'object' },
40
- },
41
- ]);
42
- }).toThrowError('should return target property in plugin schema.');
43
- });
44
-
45
- test(`support schema array in one schema`, () => {
46
- const schema = patchSchema([
47
- [
48
- {
49
- target: 'foo',
50
- schema: { type: 'string' },
51
- },
52
- {
53
- target: 'tools.foo',
54
- schema: { type: 'number' },
55
- },
56
- ],
57
- {
58
- target: 'bar',
59
- schema: { type: 'string' },
60
- },
61
- ]);
62
-
63
- expect(schema.properties).toHaveProperty('foo');
64
- expect(schema.properties).toHaveProperty('bar');
65
- expect(schema.properties.tools.properties).toHaveProperty('foo');
66
- });
67
- });
68
-
69
- describe(`traverse schema`, () => {
70
- test(`should return all avaliable keys of current schema`, () => {
71
- const schema = {
72
- type: 'object',
73
- properties: {
74
- source: {
75
- type: 'object',
76
- properties: { alias: { type: ['object', 'function'] } },
77
- },
78
- a: {
79
- type: 'object',
80
- properties: {
81
- b: {
82
- type: 'object',
83
- properties: { c: { type: 'object' } },
84
- },
85
- d: { type: 'string' },
86
- },
87
- },
88
- runtime: {
89
- type: 'object',
90
- properties: {
91
- router: { type: ['object', 'boolean'] },
92
- state: { type: ['object', 'boolean'] },
93
- },
94
- },
95
- runtimeByEntries: { patternProperties: { '^$': { type: 'string' } } },
96
- dev: { type: ['function', 'string'] },
97
- },
98
- };
99
- expect(traverseSchema(schema as any)).toEqual([
100
- 'source.alias',
101
- 'a.b.c',
102
- 'a.d',
103
- 'runtime.router',
104
- 'runtime.state',
105
- 'runtimeByEntries',
106
- 'dev',
107
- ]);
108
- });
109
- });
@@ -1,13 +0,0 @@
1
- {
2
- "extends": "@modern-js/tsconfig/base",
3
- "compilerOptions": {
4
- "declaration": false,
5
- "jsx": "preserve",
6
- "baseUrl": "./",
7
- "isolatedModules": true,
8
- "esModuleInterop": true,
9
- "paths": {
10
- "@/*": ["../src/*"]
11
- }
12
- }
13
- }
package/tsconfig.json DELETED
@@ -1,14 +0,0 @@
1
- {
2
- "extends": "@modern-js/tsconfig/base",
3
- "compilerOptions": {
4
- "declaration": false,
5
- "jsx": "preserve",
6
- "baseUrl": "./",
7
- "isolatedModules": true,
8
- "esModuleInterop": true,
9
- "paths": {
10
- "@/*": ["./src/*"]
11
- }
12
- },
13
- "include": ["src"]
14
- }