@modern-js/app-tools 1.1.2 → 1.1.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.
- package/CHANGELOG.md +65 -0
- package/dist/js/modern/commands/build.js +13 -2
- package/dist/js/modern/commands/deploy.js +3 -3
- package/dist/js/modern/commands/dev.js +2 -2
- package/dist/js/modern/index.js +6 -6
- package/dist/js/modern/locale/en.js +2 -1
- package/dist/js/modern/locale/zh.js +2 -1
- package/dist/js/node/commands/build.js +13 -1
- package/dist/js/node/commands/deploy.js +3 -3
- package/dist/js/node/commands/dev.js +2 -2
- package/dist/js/node/index.js +6 -6
- package/dist/js/node/locale/en.js +2 -1
- package/dist/js/node/locale/zh.js +2 -1
- package/dist/types/commands/build.d.ts +5 -1
- package/dist/types/commands/deploy.d.ts +1 -1
- package/dist/types/index.d.ts +3 -0
- package/dist/types/lifecycle.d.ts +2 -2
- package/dist/types/locale/en.d.ts +1 -0
- package/dist/types/locale/index.d.ts +2 -0
- package/dist/types/locale/zh.d.ts +1 -0
- package/package.json +17 -17
- package/src/commands/build.ts +11 -1
- package/src/commands/deploy.ts +3 -3
- package/src/index.ts +5 -4
- package/src/lifecycle.ts +2 -2
- package/src/locale/en.ts +1 -1
- package/src/locale/zh.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,70 @@
|
|
|
1
1
|
# @modern-js/app-tools
|
|
2
2
|
|
|
3
|
+
## 1.1.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d927bc83: remove esbuild and use @modenr-js/esbuild-compiler
|
|
8
|
+
- Updated dependencies [d927bc83]
|
|
9
|
+
- Updated dependencies [d73ff455]
|
|
10
|
+
- Updated dependencies [9c1ab865]
|
|
11
|
+
- Updated dependencies [d73ff455]
|
|
12
|
+
- Updated dependencies [d73ff455]
|
|
13
|
+
- Updated dependencies [d73ff455]
|
|
14
|
+
- Updated dependencies [d73ff455]
|
|
15
|
+
- @modern-js/utils@1.1.4
|
|
16
|
+
- @modern-js/core@1.1.4
|
|
17
|
+
- @modern-js/server@1.1.4
|
|
18
|
+
- @modern-js/types@1.1.3
|
|
19
|
+
|
|
20
|
+
## 1.1.4
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- ed1f6b12: feat: support build --analyze
|
|
25
|
+
- Updated dependencies [085a6a58]
|
|
26
|
+
- Updated dependencies [085a6a58]
|
|
27
|
+
- Updated dependencies [9a5e6d14]
|
|
28
|
+
- Updated dependencies [085a6a58]
|
|
29
|
+
- Updated dependencies [d280ea33]
|
|
30
|
+
- Updated dependencies [a37192b1]
|
|
31
|
+
- Updated dependencies [d4fcc73a]
|
|
32
|
+
- Updated dependencies [085a6a58]
|
|
33
|
+
- Updated dependencies [ed1f6b12]
|
|
34
|
+
- Updated dependencies [144145c7]
|
|
35
|
+
- Updated dependencies [a5ebbb00]
|
|
36
|
+
- Updated dependencies [b058c6fa]
|
|
37
|
+
- Updated dependencies [085a6a58]
|
|
38
|
+
- @modern-js/core@1.1.3
|
|
39
|
+
- @modern-js/server@1.1.3
|
|
40
|
+
- @modern-js/utils@1.1.3
|
|
41
|
+
- @modern-js/webpack@1.1.3
|
|
42
|
+
- @modern-js/new-action@1.1.5
|
|
43
|
+
|
|
44
|
+
## 1.1.3
|
|
45
|
+
|
|
46
|
+
### Patch Changes
|
|
47
|
+
|
|
48
|
+
- 0fa83663: support more .env files
|
|
49
|
+
- Updated dependencies [6f7fe574]
|
|
50
|
+
- Updated dependencies [e4755134]
|
|
51
|
+
- Updated dependencies [0fa83663]
|
|
52
|
+
- Updated dependencies [19b4f79e]
|
|
53
|
+
- Updated dependencies [f594fbc8]
|
|
54
|
+
- Updated dependencies [d1fde77a]
|
|
55
|
+
- @modern-js/core@1.1.2
|
|
56
|
+
- @modern-js/webpack@1.1.2
|
|
57
|
+
- @modern-js/i18n-cli-language-detector@1.1.1
|
|
58
|
+
- @modern-js/plugin-analyze@1.1.1
|
|
59
|
+
- @modern-js/plugin-fast-refresh@1.1.1
|
|
60
|
+
- @modern-js/plugin-i18n@1.1.1
|
|
61
|
+
- @modern-js/new-action@1.1.2
|
|
62
|
+
- @modern-js/plugin-polyfill@1.1.1
|
|
63
|
+
- @modern-js/server@1.1.2
|
|
64
|
+
- @modern-js/plugin@1.1.2
|
|
65
|
+
- @modern-js/types@1.1.2
|
|
66
|
+
- @modern-js/utils@1.1.2
|
|
67
|
+
|
|
3
68
|
## 1.1.2
|
|
4
69
|
|
|
5
70
|
### Patch Changes
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
+
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
|
|
5
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
|
|
1
7
|
import { webpack } from 'webpack';
|
|
2
8
|
import { WebpackConfigTarget, getWebpackConfig } from '@modern-js/webpack';
|
|
3
|
-
import { useAppContext, useResolvedConfigContext, mountHook } from '@modern-js/core';
|
|
9
|
+
import { useAppContext, useResolvedConfigContext, mountHook, ResolvedConfigContext, manager } from '@modern-js/core';
|
|
4
10
|
import { fs, formatWebpackMessages, measureFileSizesBeforeBuild, printFileSizesAfterBuild, printBuildError, logger, isUseSSRBundle } from '@modern-js/utils'; // These sizes are pretty large. We'll warn for bundles exceeding them.
|
|
5
11
|
|
|
6
12
|
const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
|
|
7
13
|
const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
|
|
8
|
-
export const build = async
|
|
14
|
+
export const build = async options => {
|
|
9
15
|
const webpackBuild = async (webpackConfig, type) => {
|
|
10
16
|
const compiler = webpack(webpackConfig);
|
|
11
17
|
return new Promise((resolve, reject) => {
|
|
@@ -63,6 +69,11 @@ export const build = async () => {
|
|
|
63
69
|
const appContext = useAppContext();
|
|
64
70
|
/* eslint-enable react-hooks/rules-of-hooks */
|
|
65
71
|
|
|
72
|
+
manager.run(() => {
|
|
73
|
+
ResolvedConfigContext.set(_objectSpread(_objectSpread({}, resolvedConfig), {}, {
|
|
74
|
+
cliOptions: options
|
|
75
|
+
}));
|
|
76
|
+
});
|
|
66
77
|
const outputPath = appContext.distDirectory;
|
|
67
78
|
const previousFileSizes = await measureFileSizesBeforeBuild(outputPath);
|
|
68
79
|
fs.emptyDirSync(outputPath);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mountHook } from '@modern-js/core';
|
|
2
|
-
export const deploy = async
|
|
3
|
-
await mountHook().beforeDeploy();
|
|
4
|
-
await mountHook().afterDeploy();
|
|
2
|
+
export const deploy = async options => {
|
|
3
|
+
await mountHook().beforeDeploy(options);
|
|
4
|
+
await mountHook().afterDeploy(options);
|
|
5
5
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
2
|
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
4
|
|
|
5
5
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
6
|
|
package/dist/js/modern/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
2
|
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
4
|
|
|
5
5
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
6
|
|
|
@@ -26,11 +26,11 @@ export default createPlugin(() => {
|
|
|
26
26
|
program.command('dev').usage('[options]').description(i18n.t(localeKeys.command.dev.describe)).option('-c --config <config>', i18n.t(localeKeys.command.dev.config)).action(async () => {
|
|
27
27
|
await dev();
|
|
28
28
|
});
|
|
29
|
-
program.command('build').usage('[options]').description(i18n.t(localeKeys.command.build.describe)).
|
|
29
|
+
program.command('build').usage('[options]').description(i18n.t(localeKeys.command.build.describe)).option('--analyze', i18n.t(localeKeys.command.build.analyze)).action(async options => {
|
|
30
30
|
const {
|
|
31
31
|
build
|
|
32
32
|
} = await import("./commands/build");
|
|
33
|
-
await build(); // force exit after build.
|
|
33
|
+
await build(options); // force exit after build.
|
|
34
34
|
// eslint-disable-next-line no-process-exit
|
|
35
35
|
|
|
36
36
|
process.exit(0);
|
|
@@ -38,7 +38,7 @@ export default createPlugin(() => {
|
|
|
38
38
|
program.command('start').usage('[options]').description(i18n.t(localeKeys.command.start.describe)).action(async () => {
|
|
39
39
|
await start();
|
|
40
40
|
});
|
|
41
|
-
program.command('deploy').usage('[options]').description(i18n.t(localeKeys.command.deploy.describe)).action(async
|
|
41
|
+
program.command('deploy').usage('[options]').description(i18n.t(localeKeys.command.deploy.describe)).action(async options => {
|
|
42
42
|
const {
|
|
43
43
|
build
|
|
44
44
|
} = await import("./commands/build");
|
|
@@ -46,7 +46,7 @@ export default createPlugin(() => {
|
|
|
46
46
|
const {
|
|
47
47
|
deploy
|
|
48
48
|
} = await import("./commands/deploy");
|
|
49
|
-
await deploy(); // eslint-disable-next-line no-process-exit
|
|
49
|
+
await deploy(options); // eslint-disable-next-line no-process-exit
|
|
50
50
|
|
|
51
51
|
process.exit(0);
|
|
52
52
|
});
|
|
@@ -13,11 +13,17 @@ var _core = require("@modern-js/core");
|
|
|
13
13
|
|
|
14
14
|
var _utils = require("@modern-js/utils");
|
|
15
15
|
|
|
16
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
+
|
|
18
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
|
+
|
|
20
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
21
|
+
|
|
16
22
|
// These sizes are pretty large. We'll warn for bundles exceeding them.
|
|
17
23
|
const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
|
|
18
24
|
const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
|
|
19
25
|
|
|
20
|
-
const build = async
|
|
26
|
+
const build = async options => {
|
|
21
27
|
const webpackBuild = async (webpackConfig, type) => {
|
|
22
28
|
const compiler = (0, _webpack.webpack)(webpackConfig);
|
|
23
29
|
return new Promise((resolve, reject) => {
|
|
@@ -78,6 +84,12 @@ const build = async () => {
|
|
|
78
84
|
const appContext = (0, _core.useAppContext)();
|
|
79
85
|
/* eslint-enable react-hooks/rules-of-hooks */
|
|
80
86
|
|
|
87
|
+
_core.manager.run(() => {
|
|
88
|
+
_core.ResolvedConfigContext.set(_objectSpread(_objectSpread({}, resolvedConfig), {}, {
|
|
89
|
+
cliOptions: options
|
|
90
|
+
}));
|
|
91
|
+
});
|
|
92
|
+
|
|
81
93
|
const outputPath = appContext.distDirectory;
|
|
82
94
|
const previousFileSizes = await (0, _utils.measureFileSizesBeforeBuild)(outputPath);
|
|
83
95
|
|
|
@@ -7,9 +7,9 @@ exports.deploy = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _core = require("@modern-js/core");
|
|
9
9
|
|
|
10
|
-
const deploy = async
|
|
11
|
-
await (0, _core.mountHook)().beforeDeploy();
|
|
12
|
-
await (0, _core.mountHook)().afterDeploy();
|
|
10
|
+
const deploy = async options => {
|
|
11
|
+
await (0, _core.mountHook)().beforeDeploy(options);
|
|
12
|
+
await (0, _core.mountHook)().afterDeploy(options);
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
exports.deploy = deploy;
|
|
@@ -15,9 +15,9 @@ var _createCompiler = require("../utils/createCompiler");
|
|
|
15
15
|
|
|
16
16
|
var _createServer = require("../utils/createServer");
|
|
17
17
|
|
|
18
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
18
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
19
19
|
|
|
20
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
20
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
21
|
|
|
22
22
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
23
23
|
|
package/dist/js/node/index.js
CHANGED
|
@@ -23,9 +23,9 @@ var _start = require("./commands/start");
|
|
|
23
23
|
|
|
24
24
|
var _dev = require("./commands/dev");
|
|
25
25
|
|
|
26
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
26
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
27
27
|
|
|
28
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
28
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
29
29
|
|
|
30
30
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
31
31
|
|
|
@@ -51,11 +51,11 @@ var _default = (0, _core.createPlugin)(() => {
|
|
|
51
51
|
program.command('dev').usage('[options]').description(_locale.i18n.t(_locale.localeKeys.command.dev.describe)).option('-c --config <config>', _locale.i18n.t(_locale.localeKeys.command.dev.config)).action(async () => {
|
|
52
52
|
await (0, _dev.dev)();
|
|
53
53
|
});
|
|
54
|
-
program.command('build').usage('[options]').description(_locale.i18n.t(_locale.localeKeys.command.build.describe)).
|
|
54
|
+
program.command('build').usage('[options]').description(_locale.i18n.t(_locale.localeKeys.command.build.describe)).option('--analyze', _locale.i18n.t(_locale.localeKeys.command.build.analyze)).action(async options => {
|
|
55
55
|
const {
|
|
56
56
|
build
|
|
57
57
|
} = await Promise.resolve().then(() => _interopRequireWildcard(require("./commands/build")));
|
|
58
|
-
await build(); // force exit after build.
|
|
58
|
+
await build(options); // force exit after build.
|
|
59
59
|
// eslint-disable-next-line no-process-exit
|
|
60
60
|
|
|
61
61
|
process.exit(0);
|
|
@@ -63,7 +63,7 @@ var _default = (0, _core.createPlugin)(() => {
|
|
|
63
63
|
program.command('start').usage('[options]').description(_locale.i18n.t(_locale.localeKeys.command.start.describe)).action(async () => {
|
|
64
64
|
await (0, _start.start)();
|
|
65
65
|
});
|
|
66
|
-
program.command('deploy').usage('[options]').description(_locale.i18n.t(_locale.localeKeys.command.deploy.describe)).action(async
|
|
66
|
+
program.command('deploy').usage('[options]').description(_locale.i18n.t(_locale.localeKeys.command.deploy.describe)).action(async options => {
|
|
67
67
|
const {
|
|
68
68
|
build
|
|
69
69
|
} = await Promise.resolve().then(() => _interopRequireWildcard(require("./commands/build")));
|
|
@@ -71,7 +71,7 @@ var _default = (0, _core.createPlugin)(() => {
|
|
|
71
71
|
const {
|
|
72
72
|
deploy
|
|
73
73
|
} = await Promise.resolve().then(() => _interopRequireWildcard(require("./commands/deploy")));
|
|
74
|
-
await deploy(); // eslint-disable-next-line no-process-exit
|
|
74
|
+
await deploy(options); // eslint-disable-next-line no-process-exit
|
|
75
75
|
|
|
76
76
|
process.exit(0);
|
|
77
77
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const deploy: () => Promise<void>;
|
|
1
|
+
export declare const deploy: (options: any) => Promise<void>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ export { defineConfig };
|
|
|
3
3
|
|
|
4
4
|
declare const _default: import("@modern-js/core").AsyncPlugin<Partial<import("@modern-js/core").Progresses2Threads<{
|
|
5
5
|
config: import("@modern-js/core").ParallelWorkflow<void, unknown>;
|
|
6
|
+
resolvedConfig: import("@modern-js/core").AsyncWaterfall<{
|
|
7
|
+
resolved: import("@modern-js/core").NormalizedConfig;
|
|
8
|
+
}>;
|
|
6
9
|
validateSchema: import("@modern-js/core").ParallelWorkflow<void, unknown>;
|
|
7
10
|
prepare: import("@modern-js/core").AsyncWorkflow<void, void>;
|
|
8
11
|
commands: import("@modern-js/core").AsyncWorkflow<{
|
|
@@ -14,6 +14,6 @@ export declare const beforeBuild: import("@modern-js/plugin").AsyncWorkflow<{
|
|
|
14
14
|
webpackConfigs: Configuration[];
|
|
15
15
|
}, unknown>;
|
|
16
16
|
export declare const afterBuild: import("@modern-js/plugin").AsyncWorkflow<void, unknown>;
|
|
17
|
-
export declare const beforeDeploy: import("@modern-js/plugin").AsyncWorkflow<
|
|
18
|
-
export declare const afterDeploy: import("@modern-js/plugin").AsyncWorkflow<
|
|
17
|
+
export declare const beforeDeploy: import("@modern-js/plugin").AsyncWorkflow<Record<string, any>, unknown>;
|
|
18
|
+
export declare const afterDeploy: import("@modern-js/plugin").AsyncWorkflow<Record<string, any>, unknown>;
|
|
19
19
|
export declare const lifecycle: () => void;
|
|
@@ -8,6 +8,7 @@ declare const localeKeys: {
|
|
|
8
8
|
};
|
|
9
9
|
build: {
|
|
10
10
|
describe: string;
|
|
11
|
+
analyze: string;
|
|
11
12
|
};
|
|
12
13
|
start: {
|
|
13
14
|
describe: string;
|
|
@@ -31,6 +32,7 @@ declare const localeKeys: {
|
|
|
31
32
|
};
|
|
32
33
|
build: {
|
|
33
34
|
describe: string;
|
|
35
|
+
analyze: string;
|
|
34
36
|
};
|
|
35
37
|
start: {
|
|
36
38
|
describe: string;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.1.
|
|
14
|
+
"version": "1.1.5",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./lib/types.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -32,19 +32,18 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/runtime": "^7",
|
|
35
|
-
"@modern-js/core": "^1.1.
|
|
36
|
-
"@modern-js/types": "^1.1.
|
|
37
|
-
"@modern-js/i18n-cli-language-detector": "^1.1.
|
|
38
|
-
"@modern-js/new-action": "^1.1.
|
|
39
|
-
"@modern-js/plugin": "^1.1.
|
|
40
|
-
"@modern-js/plugin-analyze": "^1.1.
|
|
41
|
-
"@modern-js/plugin-fast-refresh": "^1.1.
|
|
42
|
-
"@modern-js/plugin-i18n": "^1.1.
|
|
43
|
-
"@modern-js/plugin-polyfill": "^1.1.
|
|
44
|
-
"@modern-js/server": "^1.1.
|
|
45
|
-
"@modern-js/utils": "^1.1.
|
|
46
|
-
"@modern-js/webpack": "^1.1.
|
|
47
|
-
"esbuild": "^0.13.13",
|
|
35
|
+
"@modern-js/core": "^1.1.4",
|
|
36
|
+
"@modern-js/types": "^1.1.3",
|
|
37
|
+
"@modern-js/i18n-cli-language-detector": "^1.1.1",
|
|
38
|
+
"@modern-js/new-action": "^1.1.5",
|
|
39
|
+
"@modern-js/plugin": "^1.1.2",
|
|
40
|
+
"@modern-js/plugin-analyze": "^1.1.1",
|
|
41
|
+
"@modern-js/plugin-fast-refresh": "^1.1.1",
|
|
42
|
+
"@modern-js/plugin-i18n": "^1.1.1",
|
|
43
|
+
"@modern-js/plugin-polyfill": "^1.1.1",
|
|
44
|
+
"@modern-js/server": "^1.1.4",
|
|
45
|
+
"@modern-js/utils": "^1.1.4",
|
|
46
|
+
"@modern-js/webpack": "^1.1.3",
|
|
48
47
|
"webpack": "^5.54.0"
|
|
49
48
|
},
|
|
50
49
|
"devDependencies": {
|
|
@@ -53,8 +52,8 @@
|
|
|
53
52
|
"@types/react": "^17",
|
|
54
53
|
"@types/react-dom": "^17",
|
|
55
54
|
"typescript": "^4",
|
|
56
|
-
"@modern-js/plugin-testing": "^1.1.
|
|
57
|
-
"@modern-js/module-tools": "^1.1.
|
|
55
|
+
"@modern-js/plugin-testing": "^1.1.1",
|
|
56
|
+
"@modern-js/module-tools": "^1.1.1"
|
|
58
57
|
},
|
|
59
58
|
"sideEffects": false,
|
|
60
59
|
"modernConfig": {
|
|
@@ -70,5 +69,6 @@
|
|
|
70
69
|
"new": "modern new",
|
|
71
70
|
"build": "modern build",
|
|
72
71
|
"test": "modern test --passWithNoTests"
|
|
73
|
-
}
|
|
72
|
+
},
|
|
73
|
+
"readme": "\n<p align=\"center\">\n <a href=\"https://modernjs.dev\" target=\"blank\"><img src=\"https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png\" width=\"300\" alt=\"Modern.js Logo\" /></a>\n</p>\n<p align=\"center\">\n现代 Web 工程体系\n <br/>\n <a href=\"https://modernjs.dev\" target=\"blank\">\n modernjs.dev\n </a>\n</p>\n<p align=\"center\">\n The meta-framework suite designed from scratch for frontend-focused modern web development\n</p>\n\n# Introduction\n\n> The doc site ([modernjs.dev](https://modernjs.dev)) and articles are only available in Chinese for now, we are planning to add English versions soon.\n\n- [Modern.js: Hello, World!](https://zhuanlan.zhihu.com/p/426707646)\n\n## Getting Started\n\n- [Quick Start](https://modernjs.dev/docs/start)\n- [Guides](https://modernjs.dev/docs/guides)\n- [API References](https://modernjs.dev/docs/apis)\n\n## Contributing\n\n- [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md)\n"
|
|
74
74
|
}
|
package/src/commands/build.ts
CHANGED
|
@@ -4,6 +4,8 @@ import {
|
|
|
4
4
|
useAppContext,
|
|
5
5
|
useResolvedConfigContext,
|
|
6
6
|
mountHook,
|
|
7
|
+
ResolvedConfigContext,
|
|
8
|
+
manager,
|
|
7
9
|
} from '@modern-js/core';
|
|
8
10
|
import {
|
|
9
11
|
fs,
|
|
@@ -19,7 +21,11 @@ import {
|
|
|
19
21
|
const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
|
|
20
22
|
const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
|
|
21
23
|
|
|
22
|
-
|
|
24
|
+
interface CliOptions {
|
|
25
|
+
analyze?: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const build = async (options?: CliOptions) => {
|
|
23
29
|
const webpackBuild = async (webpackConfig: Configuration, type?: string) => {
|
|
24
30
|
const compiler = webpack(webpackConfig);
|
|
25
31
|
|
|
@@ -78,6 +84,10 @@ export const build = async () => {
|
|
|
78
84
|
const appContext = useAppContext();
|
|
79
85
|
/* eslint-enable react-hooks/rules-of-hooks */
|
|
80
86
|
|
|
87
|
+
manager.run(() => {
|
|
88
|
+
ResolvedConfigContext.set({ ...resolvedConfig, cliOptions: options });
|
|
89
|
+
});
|
|
90
|
+
|
|
81
91
|
const outputPath = appContext.distDirectory;
|
|
82
92
|
const previousFileSizes = await measureFileSizesBeforeBuild(outputPath);
|
|
83
93
|
fs.emptyDirSync(outputPath);
|
package/src/commands/deploy.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mountHook } from '@modern-js/core';
|
|
2
2
|
|
|
3
|
-
export const deploy = async () => {
|
|
4
|
-
await (mountHook() as any).beforeDeploy();
|
|
5
|
-
await (mountHook() as any).afterDeploy();
|
|
3
|
+
export const deploy = async (options: any) => {
|
|
4
|
+
await (mountHook() as any).beforeDeploy(options);
|
|
5
|
+
await (mountHook() as any).afterDeploy(options);
|
|
6
6
|
};
|
package/src/index.ts
CHANGED
|
@@ -36,9 +36,10 @@ export default createPlugin(
|
|
|
36
36
|
.command('build')
|
|
37
37
|
.usage('[options]')
|
|
38
38
|
.description(i18n.t(localeKeys.command.build.describe))
|
|
39
|
-
.
|
|
39
|
+
.option('--analyze', i18n.t(localeKeys.command.build.analyze))
|
|
40
|
+
.action(async (options: any) => {
|
|
40
41
|
const { build } = await import('./commands/build');
|
|
41
|
-
await build();
|
|
42
|
+
await build(options);
|
|
42
43
|
// force exit after build.
|
|
43
44
|
// eslint-disable-next-line no-process-exit
|
|
44
45
|
process.exit(0);
|
|
@@ -56,11 +57,11 @@ export default createPlugin(
|
|
|
56
57
|
.command('deploy')
|
|
57
58
|
.usage('[options]')
|
|
58
59
|
.description(i18n.t(localeKeys.command.deploy.describe))
|
|
59
|
-
.action(async () => {
|
|
60
|
+
.action(async (options: any) => {
|
|
60
61
|
const { build } = await import('./commands/build');
|
|
61
62
|
await build();
|
|
62
63
|
const { deploy } = await import('./commands/deploy');
|
|
63
|
-
await deploy();
|
|
64
|
+
await deploy(options);
|
|
64
65
|
// eslint-disable-next-line no-process-exit
|
|
65
66
|
process.exit(0);
|
|
66
67
|
});
|
package/src/lifecycle.ts
CHANGED
|
@@ -24,9 +24,9 @@ export const beforeBuild = createAsyncWorkflow<{
|
|
|
24
24
|
|
|
25
25
|
export const afterBuild = createAsyncWorkflow();
|
|
26
26
|
|
|
27
|
-
export const beforeDeploy = createAsyncWorkflow();
|
|
27
|
+
export const beforeDeploy = createAsyncWorkflow<Record<string, any>>();
|
|
28
28
|
|
|
29
|
-
export const afterDeploy = createAsyncWorkflow();
|
|
29
|
+
export const afterDeploy = createAsyncWorkflow<Record<string, any>>();
|
|
30
30
|
|
|
31
31
|
export const lifecycle = () => {
|
|
32
32
|
registerHook({
|
package/src/locale/en.ts
CHANGED
|
@@ -4,7 +4,7 @@ export const EN_LOCALE = {
|
|
|
4
4
|
describe: 'start dev server',
|
|
5
5
|
config: 'specify config file',
|
|
6
6
|
},
|
|
7
|
-
build: { describe: 'build application' },
|
|
7
|
+
build: { describe: 'build application', analyze: 'analyze bundle' },
|
|
8
8
|
start: { describe: 'start server' },
|
|
9
9
|
deploy: { describe: 'deploy application' },
|
|
10
10
|
new: {
|
package/src/locale/zh.ts
CHANGED