@modern-js/app-tools 1.4.2 → 1.4.3
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/commands/build.js +11 -5
- package/dist/js/modern/commands/start.js +1 -1
- package/dist/js/node/commands/build.js +10 -6
- package/dist/js/node/commands/start.js +2 -2
- package/dist/types/utils/createServer.d.ts +2 -2
- package/lib/types.d.ts +92 -0
- package/package.json +8 -10
- package/tests/commands/build.test.ts +17 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# @modern-js/app-tools
|
|
2
2
|
|
|
3
|
+
## 1.4.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4b5d4bf4: feat: add img resource's inline and url type declaration
|
|
8
|
+
- bdcf0865: fix: empty distDirectory for api service
|
|
9
|
+
- 02fb4146: support product server
|
|
10
|
+
- edc3bd3d: fix: @modern-js/core package not found
|
|
11
|
+
- Updated dependencies [969f172f]
|
|
12
|
+
- Updated dependencies [0ad75faa]
|
|
13
|
+
- Updated dependencies [4c792f68]
|
|
14
|
+
- Updated dependencies [83059b93]
|
|
15
|
+
- Updated dependencies [4b5d4bf4]
|
|
16
|
+
- Updated dependencies [0ad75faa]
|
|
17
|
+
- Updated dependencies [62f5b8c8]
|
|
18
|
+
- Updated dependencies [55e18278]
|
|
19
|
+
- Updated dependencies [4499a674]
|
|
20
|
+
- Updated dependencies [0ad75faa]
|
|
21
|
+
- Updated dependencies [02fb4146]
|
|
22
|
+
- Updated dependencies [403f5169]
|
|
23
|
+
- Updated dependencies [e37ea5b2]
|
|
24
|
+
- Updated dependencies [a7f42f48]
|
|
25
|
+
- Updated dependencies [83059b93]
|
|
26
|
+
- @modern-js/core@1.4.4
|
|
27
|
+
- @modern-js/webpack@1.4.1
|
|
28
|
+
- @modern-js/utils@1.3.3
|
|
29
|
+
- @modern-js/new-action@1.3.3
|
|
30
|
+
- @modern-js/server@1.4.4
|
|
31
|
+
- @modern-js/types@1.3.4
|
|
32
|
+
- @modern-js/prod-server@1.0.1
|
|
33
|
+
|
|
3
34
|
## 1.4.2
|
|
4
35
|
|
|
5
36
|
### Patch Changes
|
|
@@ -7,7 +7,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
7
7
|
import { webpack } from 'webpack';
|
|
8
8
|
import { WebpackConfigTarget, getWebpackConfig } from '@modern-js/webpack';
|
|
9
9
|
import { useAppContext, useResolvedConfigContext, mountHook, ResolvedConfigContext, manager } from '@modern-js/core';
|
|
10
|
-
import {
|
|
10
|
+
import { formatWebpackMessages, measureFileSizesBeforeBuild, printFileSizesAfterBuild, printBuildError, logger, isUseSSRBundle, emptyDir } from '@modern-js/utils';
|
|
11
11
|
import { generateRoutes } from "../utils/routes"; // These sizes are pretty large. We'll warn for bundles exceeding them.
|
|
12
12
|
|
|
13
13
|
const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
|
|
@@ -23,6 +23,10 @@ export const build = async options => {
|
|
|
23
23
|
/* eslint-enable react-hooks/rules-of-hooks */
|
|
24
24
|
|
|
25
25
|
if (!existSrc) {
|
|
26
|
+
const {
|
|
27
|
+
distDirectory
|
|
28
|
+
} = appContext;
|
|
29
|
+
await emptyDir(distDirectory);
|
|
26
30
|
await mountHook().beforeBuild({
|
|
27
31
|
webpackConfigs: []
|
|
28
32
|
});
|
|
@@ -53,7 +57,7 @@ export const build = async options => {
|
|
|
53
57
|
|
|
54
58
|
if (messages.errors.length === 0) {
|
|
55
59
|
logger.info(`File sizes after ${label} build:\n`);
|
|
56
|
-
printFileSizesAfterBuild(stats, previousFileSizes,
|
|
60
|
+
printFileSizesAfterBuild(stats, previousFileSizes, distDirectory, WARN_AFTER_BUNDLE_GZIP_SIZE, WARN_AFTER_CHUNK_GZIP_SIZE);
|
|
57
61
|
logger.log();
|
|
58
62
|
}
|
|
59
63
|
} // When using run or watch, call close and wait for it to finish before calling run or watch again.
|
|
@@ -87,9 +91,11 @@ export const build = async options => {
|
|
|
87
91
|
cliOptions: options
|
|
88
92
|
}));
|
|
89
93
|
});
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
94
|
+
const {
|
|
95
|
+
distDirectory
|
|
96
|
+
} = appContext;
|
|
97
|
+
const previousFileSizes = await measureFileSizesBeforeBuild(distDirectory);
|
|
98
|
+
await emptyDir(distDirectory);
|
|
93
99
|
const buildConfigs = [];
|
|
94
100
|
buildConfigs.push({
|
|
95
101
|
type: 'legacy',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { logger, chalk } from '@modern-js/utils';
|
|
2
2
|
import { useAppContext, useResolvedConfigContext } from '@modern-js/core';
|
|
3
|
-
import server from '@modern-js/server';
|
|
3
|
+
import server from '@modern-js/prod-server';
|
|
4
4
|
import { printInstructions } from "../utils/printInstructions";
|
|
5
5
|
export const start = async () => {
|
|
6
6
|
/* eslint-disable react-hooks/rules-of-hooks */
|
|
@@ -36,6 +36,10 @@ const build = async options => {
|
|
|
36
36
|
/* eslint-enable react-hooks/rules-of-hooks */
|
|
37
37
|
|
|
38
38
|
if (!existSrc) {
|
|
39
|
+
const {
|
|
40
|
+
distDirectory
|
|
41
|
+
} = appContext;
|
|
42
|
+
await (0, _utils.emptyDir)(distDirectory);
|
|
39
43
|
await (0, _core.mountHook)().beforeBuild({
|
|
40
44
|
webpackConfigs: []
|
|
41
45
|
});
|
|
@@ -68,7 +72,7 @@ const build = async options => {
|
|
|
68
72
|
if (messages.errors.length === 0) {
|
|
69
73
|
_utils.logger.info(`File sizes after ${label} build:\n`);
|
|
70
74
|
|
|
71
|
-
(0, _utils.printFileSizesAfterBuild)(stats, previousFileSizes,
|
|
75
|
+
(0, _utils.printFileSizesAfterBuild)(stats, previousFileSizes, distDirectory, WARN_AFTER_BUNDLE_GZIP_SIZE, WARN_AFTER_CHUNK_GZIP_SIZE);
|
|
72
76
|
|
|
73
77
|
_utils.logger.log();
|
|
74
78
|
}
|
|
@@ -104,11 +108,11 @@ const build = async options => {
|
|
|
104
108
|
}));
|
|
105
109
|
});
|
|
106
110
|
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
_utils.
|
|
111
|
-
|
|
111
|
+
const {
|
|
112
|
+
distDirectory
|
|
113
|
+
} = appContext;
|
|
114
|
+
const previousFileSizes = await (0, _utils.measureFileSizesBeforeBuild)(distDirectory);
|
|
115
|
+
await (0, _utils.emptyDir)(distDirectory);
|
|
112
116
|
const buildConfigs = [];
|
|
113
117
|
buildConfigs.push({
|
|
114
118
|
type: 'legacy',
|
|
@@ -9,7 +9,7 @@ var _utils = require("@modern-js/utils");
|
|
|
9
9
|
|
|
10
10
|
var _core = require("@modern-js/core");
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _prodServer = _interopRequireDefault(require("@modern-js/prod-server"));
|
|
13
13
|
|
|
14
14
|
var _printInstructions = require("../utils/printInstructions");
|
|
15
15
|
|
|
@@ -28,7 +28,7 @@ const start = async () => {
|
|
|
28
28
|
|
|
29
29
|
_utils.logger.log(_utils.chalk.cyan(`Starting the modern server...`));
|
|
30
30
|
|
|
31
|
-
const app = await (0,
|
|
31
|
+
const app = await (0, _prodServer.default)({
|
|
32
32
|
pwd: appDirectory,
|
|
33
33
|
config: userConfig,
|
|
34
34
|
plugins: appContext.plugins.filter(p => p.server).map(p => p.server)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Server,
|
|
1
|
+
import { Server, ModernDevServerOptions } from '@modern-js/server';
|
|
2
2
|
export declare const getServer: () => Server | null;
|
|
3
3
|
export declare const closeServer: () => Promise<void>;
|
|
4
|
-
export declare const createServer: (options:
|
|
4
|
+
export declare const createServer: (options: ModernDevServerOptions) => Promise<Server>;
|
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/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.4.
|
|
14
|
+
"version": "1.4.3",
|
|
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.4.4",
|
|
52
53
|
"@babel/runtime": "^7",
|
|
53
|
-
"@modern-js/types": "^1.3.
|
|
54
|
+
"@modern-js/types": "^1.3.4",
|
|
54
55
|
"@modern-js/i18n-cli-language-detector": "^1.2.1",
|
|
55
|
-
"@modern-js/new-action": "^1.3.
|
|
56
|
+
"@modern-js/new-action": "^1.3.3",
|
|
56
57
|
"@modern-js/plugin": "^1.2.1",
|
|
57
58
|
"@modern-js/plugin-analyze": "^1.3.3",
|
|
58
59
|
"@modern-js/plugin-fast-refresh": "^1.2.1",
|
|
59
60
|
"@modern-js/plugin-i18n": "^1.2.1",
|
|
60
|
-
"@modern-js/server": "^1.4.
|
|
61
|
-
"@modern-js/
|
|
62
|
-
"@modern-js/
|
|
61
|
+
"@modern-js/server": "^1.4.4",
|
|
62
|
+
"@modern-js/prod-server": "^1.0.1",
|
|
63
|
+
"@modern-js/utils": "^1.3.3",
|
|
64
|
+
"@modern-js/webpack": "^1.4.1",
|
|
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",
|
|
@@ -4,19 +4,23 @@ const mockBeforeBuild = jest.fn();
|
|
|
4
4
|
const mockAfterBuild = jest.fn();
|
|
5
5
|
const mockGenerateRoutes = jest.fn();
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
// eslint-disable-next-line arrow-body-style
|
|
8
|
+
jest.mock('@modern-js/core', () => {
|
|
9
|
+
return {
|
|
10
|
+
__esModule: true,
|
|
11
|
+
mountHook() {
|
|
12
|
+
return {
|
|
13
|
+
beforeBuild: mockBeforeBuild,
|
|
14
|
+
afterBuild: mockAfterBuild,
|
|
15
|
+
};
|
|
16
|
+
},
|
|
17
|
+
useAppContext: jest.fn(() => ({
|
|
18
|
+
existSrc: false,
|
|
19
|
+
distDirectory: '',
|
|
20
|
+
})),
|
|
21
|
+
useResolvedConfigContext: jest.fn(),
|
|
22
|
+
};
|
|
23
|
+
});
|
|
20
24
|
|
|
21
25
|
jest.mock('../../src/utils/routes', () => ({
|
|
22
26
|
__esModule: true,
|