@modern-js/app-tools 1.4.2 → 1.4.5

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 (36) hide show
  1. package/.eslintrc.js +8 -0
  2. package/CHANGELOG.md +84 -0
  3. package/dist/js/modern/commands/build.js +24 -19
  4. package/dist/js/modern/commands/deploy.js +4 -4
  5. package/dist/js/modern/commands/dev.js +12 -11
  6. package/dist/js/modern/commands/start.js +5 -9
  7. package/dist/js/modern/{lifecycle.js → hooks.js} +10 -13
  8. package/dist/js/modern/index.js +74 -73
  9. package/dist/js/modern/locale/zh.js +1 -1
  10. package/dist/js/modern/utils/createCompiler.js +6 -5
  11. package/dist/js/modern/utils/printInstructions.js +3 -3
  12. package/dist/js/node/commands/build.js +19 -17
  13. package/dist/js/node/commands/deploy.js +4 -5
  14. package/dist/js/node/commands/dev.js +17 -16
  15. package/dist/js/node/commands/start.js +6 -11
  16. package/dist/js/node/{lifecycle.js → hooks.js} +12 -18
  17. package/dist/js/node/index.js +81 -77
  18. package/dist/js/node/locale/zh.js +1 -1
  19. package/dist/js/node/utils/createCompiler.js +6 -6
  20. package/dist/js/node/utils/printInstructions.js +3 -4
  21. package/dist/types/commands/build.d.ts +3 -5
  22. package/dist/types/commands/deploy.d.ts +2 -1
  23. package/dist/types/commands/dev.d.ts +2 -1
  24. package/dist/types/commands/start.d.ts +2 -1
  25. package/dist/types/{lifecycle.d.ts → hooks.d.ts} +19 -1
  26. package/dist/types/index.d.ts +2 -19
  27. package/dist/types/utils/createCompiler.d.ts +3 -1
  28. package/dist/types/utils/createServer.d.ts +2 -2
  29. package/dist/types/utils/printInstructions.d.ts +2 -2
  30. package/dist/types/utils/routes.d.ts +1 -1
  31. package/dist/types/utils/types.d.ts +4 -1
  32. package/lib/types.d.ts +92 -0
  33. package/modern.config.js +1 -0
  34. package/package.json +12 -18
  35. package/tests/.eslintrc.js +8 -0
  36. package/tests/commands/build.test.ts +25 -20
package/lib/types.d.ts CHANGED
@@ -56,6 +56,98 @@ declare module '*.svg' {
56
56
  export default src;
57
57
  }
58
58
 
59
+ declare module '*.bmp?inline' {
60
+ const src: string;
61
+ export default src;
62
+ }
63
+
64
+ declare module '*.gif?inline' {
65
+ const src: string;
66
+ export default src;
67
+ }
68
+
69
+ declare module '*.jpg?inline' {
70
+ const src: string;
71
+ export default src;
72
+ }
73
+
74
+ declare module '*.jpeg?inline' {
75
+ const src: string;
76
+ export default src;
77
+ }
78
+
79
+ declare module '*.png?inline' {
80
+ const src: string;
81
+ export default src;
82
+ }
83
+
84
+ declare module '*.ico?inline' {
85
+ const src: string;
86
+ export default src;
87
+ }
88
+
89
+ declare module '*.webp?inline' {
90
+ const src: string;
91
+ export default src;
92
+ }
93
+
94
+ declare module '*.svg?inline' {
95
+ import * as React from 'react';
96
+
97
+ export const ReactComponent: React.FunctionComponent<
98
+ React.SVGProps<SVGSVGElement>
99
+ >;
100
+
101
+ const src: string;
102
+ export default src;
103
+ }
104
+
105
+ declare module '*.bmp?url' {
106
+ const src: string;
107
+ export default src;
108
+ }
109
+
110
+ declare module '*.gif?url' {
111
+ const src: string;
112
+ export default src;
113
+ }
114
+
115
+ declare module '*.jpg?url' {
116
+ const src: string;
117
+ export default src;
118
+ }
119
+
120
+ declare module '*.jpeg?url' {
121
+ const src: string;
122
+ export default src;
123
+ }
124
+
125
+ declare module '*.png?url' {
126
+ const src: string;
127
+ export default src;
128
+ }
129
+
130
+ declare module '*.ico?url' {
131
+ const src: string;
132
+ export default src;
133
+ }
134
+
135
+ declare module '*.webp?url' {
136
+ const src: string;
137
+ export default src;
138
+ }
139
+
140
+ declare module '*.svg?url' {
141
+ import * as React from 'react';
142
+
143
+ export const ReactComponent: React.FunctionComponent<
144
+ React.SVGProps<SVGSVGElement>
145
+ >;
146
+
147
+ const src: string;
148
+ export default src;
149
+ }
150
+
59
151
  declare module '*.css' {
60
152
  const classes: { readonly [key: string]: string };
61
153
  export default classes;
package/modern.config.js CHANGED
@@ -1,6 +1,7 @@
1
1
  /** @type {import('@modern-js/module-tools').UserConfig} */
2
2
  module.exports = {
3
3
  output: {
4
+ packageMode: 'node-js',
4
5
  disableSourceMap: true,
5
6
  },
6
7
  };
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.4.2",
14
+ "version": "1.4.5",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -49,25 +49,23 @@
49
49
  "modern": "./bin/modern.js"
50
50
  },
51
51
  "dependencies": {
52
+ "@modern-js/core": "^1.6.0",
52
53
  "@babel/runtime": "^7",
53
- "@modern-js/types": "^1.3.3",
54
+ "@modern-js/types": "^1.3.5",
54
55
  "@modern-js/i18n-cli-language-detector": "^1.2.1",
55
- "@modern-js/new-action": "^1.3.2",
56
- "@modern-js/plugin": "^1.2.1",
57
- "@modern-js/plugin-analyze": "^1.3.3",
58
- "@modern-js/plugin-fast-refresh": "^1.2.1",
56
+ "@modern-js/new-action": "^1.3.3",
57
+ "@modern-js/plugin": "^1.3.2",
58
+ "@modern-js/plugin-analyze": "^1.3.4",
59
+ "@modern-js/plugin-fast-refresh": "^1.2.2",
59
60
  "@modern-js/plugin-i18n": "^1.2.1",
60
- "@modern-js/server": "^1.4.3",
61
- "@modern-js/utils": "^1.3.2",
62
- "@modern-js/webpack": "^1.4.0",
61
+ "@modern-js/server": "^1.4.8",
62
+ "@modern-js/prod-server": "^1.0.5",
63
+ "@modern-js/utils": "^1.3.6",
64
+ "@modern-js/webpack": "^1.5.0",
63
65
  "inquirer": "^8.2.0",
64
66
  "webpack": "^5.54.0"
65
67
  },
66
- "peerDependencies": {
67
- "@modern-js/core": "^1.4.3"
68
- },
69
68
  "devDependencies": {
70
- "@modern-js/core": "^1.4.3",
71
69
  "@types/jest": "^26",
72
70
  "@types/node": "^14",
73
71
  "@types/react": "^17",
@@ -79,17 +77,13 @@
79
77
  "@types/inquirer": "^8.2.0"
80
78
  },
81
79
  "sideEffects": false,
82
- "modernConfig": {
83
- "output": {
84
- "packageMode": "node-js"
85
- }
86
- },
87
80
  "publishConfig": {
88
81
  "registry": "https://registry.npmjs.org/",
89
82
  "access": "public"
90
83
  },
91
84
  "scripts": {
92
85
  "new": "modern new",
86
+ "dev": "modern build --watch",
93
87
  "build": "modern build",
94
88
  "test": "jest --passWithNoTests"
95
89
  },
@@ -0,0 +1,8 @@
1
+ module.exports = {
2
+ root: true,
3
+ extends: ['@modern-js'],
4
+ parserOptions: {
5
+ tsconfigRootDir: __dirname,
6
+ project: ['./tsconfig.json'],
7
+ },
8
+ };
@@ -1,23 +1,8 @@
1
+ import { manager } from '@modern-js/core';
1
2
  import { build } from '../../src/commands/build';
2
3
 
3
- const mockBeforeBuild = jest.fn();
4
- const mockAfterBuild = jest.fn();
5
4
  const mockGenerateRoutes = jest.fn();
6
5
 
7
- jest.mock('@modern-js/core', () => ({
8
- __esModule: true,
9
- mountHook() {
10
- return {
11
- beforeBuild: mockBeforeBuild,
12
- afterBuild: mockAfterBuild,
13
- };
14
- },
15
- useAppContext: jest.fn(() => ({
16
- existSrc: false,
17
- })),
18
- useResolvedConfigContext: jest.fn(),
19
- }));
20
-
21
6
  jest.mock('../../src/utils/routes', () => ({
22
7
  __esModule: true,
23
8
  generateRoutes: () => mockGenerateRoutes(),
@@ -29,9 +14,29 @@ describe('command build', () => {
29
14
  });
30
15
 
31
16
  test('existSrc is false', async () => {
32
- await build();
33
- expect(mockBeforeBuild).toBeCalled();
34
- expect(mockGenerateRoutes).toBeCalled();
35
- expect(mockAfterBuild).toBeCalled();
17
+ const mockBeforeBuild = jest.fn();
18
+ const mockAfterBuild = jest.fn();
19
+ const mockAPI = {
20
+ useAppContext: jest.fn((): any => ({
21
+ existSrc: false,
22
+ distDirectory: '',
23
+ })),
24
+ useResolvedConfigContext: jest.fn(),
25
+ useHookRunners: (): any => ({
26
+ afterBuild: mockAfterBuild,
27
+ beforeBuild: mockBeforeBuild,
28
+ }),
29
+ };
30
+
31
+ const cloned = manager.clone(mockAPI);
32
+ cloned.usePlugin({
33
+ async setup(api) {
34
+ await build(api);
35
+ expect(mockBeforeBuild).toBeCalled();
36
+ expect(mockGenerateRoutes).toBeCalled();
37
+ expect(mockAfterBuild).toBeCalled();
38
+ },
39
+ });
40
+ await cloned.init();
36
41
  });
37
42
  });