@modern-js/app-tools 1.1.0 → 1.1.4

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 CHANGED
@@ -1,85 +1,82 @@
1
1
  # @modern-js/app-tools
2
2
 
3
- ## 1.1.0
4
-
5
- ### Minor Changes
6
-
7
- - 96119db2: Relese v1.1.0
8
-
9
- 1. 全面支持 Windows 平台
10
-
11
- ISSUE:
12
-
13
- - [182](https://github.com/modern-js-dev/modern.js/issues/182)
14
- - [236](https://github.com/modern-js-dev/modern.js/issues/236)
15
-
16
- PR
17
-
18
- - [219](https://github.com/modern-js-dev/modern.js/pull/219)
19
- - [247](https://github.com/modern-js-dev/modern.js/pull/247)
20
- - [249](https://github.com/modern-js-dev/modern.js/pull/249)
21
- - [253](https://github.com/modern-js-dev/modern.js/pull/253)
22
- - [268](https://github.com/modern-js-dev/modern.js/pull/268)
23
- - [270](https://github.com/modern-js-dev/modern.js/pull/270)
24
- - [273](https://github.com/modern-js-dev/modern.js/pull/273)
25
- - [276](https://github.com/modern-js-dev/modern.js/pull/276)
26
-
27
- 2. 修复 Unbundled 模式启用问题
28
-
29
- ISSUE
30
-
31
- - [186](https://github.com/modern-js-dev/modern.js/issues/186)
32
- - [224](https://github.com/modern-js-dev/modern.js/issues/224)
33
- - [225](https://github.com/modern-js-dev/modern.js/issues/225)
34
- - [238](https://github.com/modern-js-dev/modern.js/issues/238)
35
-
36
- PR
37
-
38
- - [226](https://github.com/modern-js-dev/modern.js/pull/226)
39
- - [264](https://github.com/modern-js-dev/modern.js/pull/264)
40
- - [codesmith-12](https://github.com/modern-js-dev/codesmith/pull/12)
41
-
42
- 3. 修复模块工程方案 .npmignore 文件初始化未生成
3
+ ## 1.1.4
43
4
 
44
- ISSUE
45
-
46
- - [198](https://github.com/modern-js-dev/modern.js/issues/198)
47
-
48
- PR
49
-
50
- - [209](https://github.com/modern-js-dev/modern.js/pull/209)
51
-
52
- 4. 修复 Storybook 使用时浏览器打开页面报错
53
-
54
- ISSUE
55
-
56
- - [228](https://github.com/modern-js-dev/modern.js/issues/228)
57
-
58
- PR
59
-
60
- - [254](https://github.com/modern-js-dev/modern.js/pull/254)
5
+ ### Patch Changes
61
6
 
62
- 5. 修复 BFF 一体化开发不支持 unbundle 模式
7
+ - ed1f6b12: feat: support build --analyze
8
+ - Updated dependencies [085a6a58]
9
+ - Updated dependencies [085a6a58]
10
+ - Updated dependencies [9a5e6d14]
11
+ - Updated dependencies [085a6a58]
12
+ - Updated dependencies [d280ea33]
13
+ - Updated dependencies [a37192b1]
14
+ - Updated dependencies [d4fcc73a]
15
+ - Updated dependencies [085a6a58]
16
+ - Updated dependencies [ed1f6b12]
17
+ - Updated dependencies [144145c7]
18
+ - Updated dependencies [a5ebbb00]
19
+ - Updated dependencies [b058c6fa]
20
+ - Updated dependencies [085a6a58]
21
+ - @modern-js/core@1.1.3
22
+ - @modern-js/server@1.1.3
23
+ - @modern-js/utils@1.1.3
24
+ - @modern-js/webpack@1.1.3
25
+ - @modern-js/new-action@1.1.5
26
+
27
+ ## 1.1.3
63
28
 
64
- ISSUE
29
+ ### Patch Changes
65
30
 
66
- - [235](https://github.com/modern-js-dev/modern.js/issues/235)
67
- - [257](https://github.com/modern-js-dev/modern.js/issues/257)
31
+ - 0fa83663: support more .env files
32
+ - Updated dependencies [6f7fe574]
33
+ - Updated dependencies [e4755134]
34
+ - Updated dependencies [0fa83663]
35
+ - Updated dependencies [19b4f79e]
36
+ - Updated dependencies [f594fbc8]
37
+ - Updated dependencies [d1fde77a]
38
+ - @modern-js/core@1.1.2
39
+ - @modern-js/webpack@1.1.2
40
+ - @modern-js/i18n-cli-language-detector@1.1.1
41
+ - @modern-js/plugin-analyze@1.1.1
42
+ - @modern-js/plugin-fast-refresh@1.1.1
43
+ - @modern-js/plugin-i18n@1.1.1
44
+ - @modern-js/new-action@1.1.2
45
+ - @modern-js/plugin-polyfill@1.1.1
46
+ - @modern-js/server@1.1.2
47
+ - @modern-js/plugin@1.1.2
48
+ - @modern-js/types@1.1.2
49
+ - @modern-js/utils@1.1.2
50
+
51
+ ## 1.1.2
68
52
 
69
- PR
53
+ ### Patch Changes
70
54
 
71
- - [269](https://github.com/modern-js-dev/modern.js/pull/269)
72
- - [271](https://github.com/modern-js-dev/modern.js/pull/271)
55
+ - c0fc0700: feat: support deploy plugin
56
+ - Updated dependencies [3b6856b8]
57
+ - Updated dependencies [687c92c7]
58
+ - Updated dependencies [c0fc0700]
59
+ - Updated dependencies [6ffd1a50]
60
+ - Updated dependencies [c7f4cafb]
61
+ - @modern-js/new-action@1.1.1
62
+ - @modern-js/core@1.1.1
63
+ - @modern-js/webpack@1.1.1
64
+ - @modern-js/server@1.1.1
65
+ - @modern-js/types@1.1.1
66
+ - @modern-js/utils@1.1.1
67
+ - @modern-js/plugin@1.1.1
68
+
69
+ ## 1.1.1
73
70
 
74
- 6. 修复 Node17 dev 命令报错问题
71
+ ### Patch Changes
75
72
 
76
- ISSUE
73
+ - 6cfc16e: add esbuild deps
77
74
 
78
- - [180](https://github.com/modern-js-dev/modern.js/issues/180)
75
+ ## 1.1.0
79
76
 
80
- PR
77
+ ### Minor Changes
81
78
 
82
- - [214](https://github.com/modern-js-dev/modern.js/pull/214)
79
+ - 96119db2: Relese v1.1.0
83
80
 
84
81
  ### Patch Changes
85
82
 
@@ -1,11 +1,17 @@
1
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (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 = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { 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);
@@ -105,8 +116,5 @@ export const build = async () => {
105
116
  }
106
117
  }
107
118
 
108
- await mountHook().afterBuild(); // force exit after build.
109
- // eslint-disable-next-line no-process-exit
110
-
111
- process.exit(0);
119
+ await mountHook().afterBuild();
112
120
  };
@@ -0,0 +1,5 @@
1
+ import { mountHook } from '@modern-js/core';
2
+ export const deploy = async () => {
3
+ await mountHook().beforeDeploy();
4
+ await mountHook().afterDeploy();
5
+ };
@@ -26,15 +26,30 @@ 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)).action(async () => {
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();
33
+ await build(options); // force exit after build.
34
+ // eslint-disable-next-line no-process-exit
35
+
36
+ process.exit(0);
34
37
  });
35
38
  program.command('start').usage('[options]').description(i18n.t(localeKeys.command.start.describe)).action(async () => {
36
39
  await start();
37
40
  });
41
+ program.command('deploy').usage('[options]').description(i18n.t(localeKeys.command.deploy.describe)).action(async () => {
42
+ const {
43
+ build
44
+ } = await import("./commands/build");
45
+ await build();
46
+ const {
47
+ deploy
48
+ } = await import("./commands/deploy");
49
+ await deploy(); // eslint-disable-next-line no-process-exit
50
+
51
+ process.exit(0);
52
+ });
38
53
  program.command('new').usage('[options]').description(i18n.t(localeKeys.command.new.describe)).option('-d, --debug', i18n.t(localeKeys.command.new.debug), false).option('-c, --config <config>', i18n.t(localeKeys.command.new.config)).option('--dist-tag <tag>', i18n.t(localeKeys.command.new.distTag)).option('--registry', i18n.t(localeKeys.command.new.registry)).action(async options => {
39
54
  const {
40
55
  MWANewAction
@@ -7,6 +7,8 @@ export const afterCreateCompiler = createAsyncWorkflow();
7
7
  export const beforePrintInstructions = createAsyncWaterfall();
8
8
  export const beforeBuild = createAsyncWorkflow();
9
9
  export const afterBuild = createAsyncWorkflow();
10
+ export const beforeDeploy = createAsyncWorkflow();
11
+ export const afterDeploy = createAsyncWorkflow();
10
12
  export const lifecycle = () => {
11
13
  registerHook({
12
14
  beforeDev,
@@ -15,6 +17,8 @@ export const lifecycle = () => {
15
17
  afterCreateCompiler,
16
18
  beforePrintInstructions,
17
19
  beforeBuild,
18
- afterBuild
20
+ afterBuild,
21
+ beforeDeploy,
22
+ afterDeploy
19
23
  });
20
24
  };
@@ -5,11 +5,15 @@ export const EN_LOCALE = {
5
5
  config: 'specify config file'
6
6
  },
7
7
  build: {
8
- describe: 'build application'
8
+ describe: 'build application',
9
+ analyze: 'analyze bundle'
9
10
  },
10
11
  start: {
11
12
  describe: 'start server'
12
13
  },
14
+ deploy: {
15
+ describe: 'deploy application'
16
+ },
13
17
  new: {
14
18
  describe: 'generator runner for MWA project',
15
19
  debug: 'using debug mode to log something',
@@ -5,11 +5,15 @@ export const ZH_LOCALE = {
5
5
  config: '制定配置文件路径'
6
6
  },
7
7
  build: {
8
- describe: '构建应用命令'
8
+ describe: '构建应用命令',
9
+ analyze: '分析构建产物'
9
10
  },
10
11
  start: {
11
12
  describe: '应用启动命令'
12
13
  },
14
+ deploy: {
15
+ describe: '部署应用命令'
16
+ },
13
17
  new: {
14
18
  describe: 'MWA 项目中中执行生成器',
15
19
  debug: '开启 Debug 模式,打印调试日志信息',
@@ -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); if (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 = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { 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
 
@@ -122,10 +134,7 @@ const build = async () => {
122
134
  }
123
135
  }
124
136
 
125
- await (0, _core.mountHook)().afterBuild(); // force exit after build.
126
- // eslint-disable-next-line no-process-exit
127
-
128
- process.exit(0);
137
+ await (0, _core.mountHook)().afterBuild();
129
138
  };
130
139
 
131
140
  exports.build = build;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.deploy = void 0;
7
+
8
+ var _core = require("@modern-js/core");
9
+
10
+ const deploy = async () => {
11
+ await (0, _core.mountHook)().beforeDeploy();
12
+ await (0, _core.mountHook)().afterDeploy();
13
+ };
14
+
15
+ exports.deploy = deploy;
@@ -51,15 +51,30 @@ 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)).action(async () => {
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();
58
+ await build(options); // force exit after build.
59
+ // eslint-disable-next-line no-process-exit
60
+
61
+ process.exit(0);
59
62
  });
60
63
  program.command('start').usage('[options]').description(_locale.i18n.t(_locale.localeKeys.command.start.describe)).action(async () => {
61
64
  await (0, _start.start)();
62
65
  });
66
+ program.command('deploy').usage('[options]').description(_locale.i18n.t(_locale.localeKeys.command.deploy.describe)).action(async () => {
67
+ const {
68
+ build
69
+ } = await Promise.resolve().then(() => _interopRequireWildcard(require("./commands/build")));
70
+ await build();
71
+ const {
72
+ deploy
73
+ } = await Promise.resolve().then(() => _interopRequireWildcard(require("./commands/deploy")));
74
+ await deploy(); // eslint-disable-next-line no-process-exit
75
+
76
+ process.exit(0);
77
+ });
63
78
  program.command('new').usage('[options]').description(_locale.i18n.t(_locale.localeKeys.command.new.describe)).option('-d, --debug', _locale.i18n.t(_locale.localeKeys.command.new.debug), false).option('-c, --config <config>', _locale.i18n.t(_locale.localeKeys.command.new.config)).option('--dist-tag <tag>', _locale.i18n.t(_locale.localeKeys.command.new.distTag)).option('--registry', _locale.i18n.t(_locale.localeKeys.command.new.registry)).action(async options => {
64
79
  const {
65
80
  MWANewAction
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.lifecycle = exports.beforePrintInstructions = exports.beforeDev = exports.beforeCreateCompiler = exports.beforeBuild = exports.afterDev = exports.afterCreateCompiler = exports.afterBuild = void 0;
6
+ exports.lifecycle = exports.beforePrintInstructions = exports.beforeDev = exports.beforeDeploy = exports.beforeCreateCompiler = exports.beforeBuild = exports.afterDev = exports.afterDeploy = exports.afterCreateCompiler = exports.afterBuild = void 0;
7
7
 
8
8
  var _plugin = require("@modern-js/plugin");
9
9
 
@@ -23,6 +23,10 @@ const beforeBuild = (0, _plugin.createAsyncWorkflow)();
23
23
  exports.beforeBuild = beforeBuild;
24
24
  const afterBuild = (0, _plugin.createAsyncWorkflow)();
25
25
  exports.afterBuild = afterBuild;
26
+ const beforeDeploy = (0, _plugin.createAsyncWorkflow)();
27
+ exports.beforeDeploy = beforeDeploy;
28
+ const afterDeploy = (0, _plugin.createAsyncWorkflow)();
29
+ exports.afterDeploy = afterDeploy;
26
30
 
27
31
  const lifecycle = () => {
28
32
  (0, _core.registerHook)({
@@ -32,7 +36,9 @@ const lifecycle = () => {
32
36
  afterCreateCompiler,
33
37
  beforePrintInstructions,
34
38
  beforeBuild,
35
- afterBuild
39
+ afterBuild,
40
+ beforeDeploy,
41
+ afterDeploy
36
42
  });
37
43
  };
38
44
 
@@ -11,11 +11,15 @@ const EN_LOCALE = {
11
11
  config: 'specify config file'
12
12
  },
13
13
  build: {
14
- describe: 'build application'
14
+ describe: 'build application',
15
+ analyze: 'analyze bundle'
15
16
  },
16
17
  start: {
17
18
  describe: 'start server'
18
19
  },
20
+ deploy: {
21
+ describe: 'deploy application'
22
+ },
19
23
  new: {
20
24
  describe: 'generator runner for MWA project',
21
25
  debug: 'using debug mode to log something',
@@ -11,11 +11,15 @@ const ZH_LOCALE = {
11
11
  config: '制定配置文件路径'
12
12
  },
13
13
  build: {
14
- describe: '构建应用命令'
14
+ describe: '构建应用命令',
15
+ analyze: '分析构建产物'
15
16
  },
16
17
  start: {
17
18
  describe: '应用启动命令'
18
19
  },
20
+ deploy: {
21
+ describe: '部署应用命令'
22
+ },
19
23
  new: {
20
24
  describe: 'MWA 项目中中执行生成器',
21
25
  debug: '开启 Debug 模式,打印调试日志信息',
@@ -1 +1,5 @@
1
- export declare const build: () => Promise<never>;
1
+ interface CliOptions {
2
+ analyze?: boolean;
3
+ }
4
+ export declare const build: (options?: CliOptions | undefined) => Promise<void>;
5
+ export {};
@@ -0,0 +1 @@
1
+ export declare const deploy: () => Promise<void>;
@@ -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,4 +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<void, unknown>;
18
+ export declare const afterDeploy: import("@modern-js/plugin").AsyncWorkflow<void, unknown>;
17
19
  export declare const lifecycle: () => void;
@@ -6,10 +6,14 @@ export declare const EN_LOCALE: {
6
6
  };
7
7
  build: {
8
8
  describe: string;
9
+ analyze: string;
9
10
  };
10
11
  start: {
11
12
  describe: string;
12
13
  };
14
+ deploy: {
15
+ describe: string;
16
+ };
13
17
  new: {
14
18
  describe: string;
15
19
  debug: string;
@@ -8,10 +8,14 @@ declare const localeKeys: {
8
8
  };
9
9
  build: {
10
10
  describe: string;
11
+ analyze: string;
11
12
  };
12
13
  start: {
13
14
  describe: string;
14
15
  };
16
+ deploy: {
17
+ describe: string;
18
+ };
15
19
  new: {
16
20
  describe: string;
17
21
  debug: string;
@@ -28,10 +32,14 @@ declare const localeKeys: {
28
32
  };
29
33
  build: {
30
34
  describe: string;
35
+ analyze: string;
31
36
  };
32
37
  start: {
33
38
  describe: string;
34
39
  };
40
+ deploy: {
41
+ describe: string;
42
+ };
35
43
  new: {
36
44
  describe: string;
37
45
  debug: string;
@@ -6,10 +6,14 @@ export declare const ZH_LOCALE: {
6
6
  };
7
7
  build: {
8
8
  describe: string;
9
+ analyze: string;
9
10
  };
10
11
  start: {
11
12
  describe: string;
12
13
  };
14
+ deploy: {
15
+ describe: string;
16
+ };
13
17
  new: {
14
18
  describe: string;
15
19
  debug: string;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.1.0",
14
+ "version": "1.1.4",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./lib/types.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -32,18 +32,19 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@babel/runtime": "^7",
35
- "@modern-js/core": "^1.1.0",
36
- "@modern-js/types": "^1.1.0",
37
- "@modern-js/i18n-cli-language-detector": "^1.1.0",
38
- "@modern-js/new-action": "^1.1.0",
39
- "@modern-js/plugin": "^1.1.0",
40
- "@modern-js/plugin-analyze": "^1.1.0",
41
- "@modern-js/plugin-fast-refresh": "^1.1.0",
42
- "@modern-js/plugin-i18n": "^1.1.0",
43
- "@modern-js/plugin-polyfill": "^1.1.0",
44
- "@modern-js/server": "^1.1.0",
45
- "@modern-js/utils": "^1.1.0",
46
- "@modern-js/webpack": "^1.1.0",
35
+ "@modern-js/core": "^1.1.3",
36
+ "@modern-js/types": "^1.1.2",
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.3",
45
+ "@modern-js/utils": "^1.1.3",
46
+ "@modern-js/webpack": "^1.1.3",
47
+ "esbuild": "^0.13.13",
47
48
  "webpack": "^5.54.0"
48
49
  },
49
50
  "devDependencies": {
@@ -52,8 +53,8 @@
52
53
  "@types/react": "^17",
53
54
  "@types/react-dom": "^17",
54
55
  "typescript": "^4",
55
- "@modern-js/plugin-testing": "^1.0.2",
56
- "@modern-js/module-tools": "^1.0.2"
56
+ "@modern-js/plugin-testing": "^1.1.1",
57
+ "@modern-js/module-tools": "^1.1.1"
57
58
  },
58
59
  "sideEffects": false,
59
60
  "modernConfig": {
@@ -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
- export const build = async () => {
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);
@@ -116,8 +126,4 @@ export const build = async () => {
116
126
  }
117
127
  }
118
128
  await (mountHook() as any).afterBuild();
119
-
120
- // force exit after build.
121
- // eslint-disable-next-line no-process-exit
122
- process.exit(0);
123
129
  };
@@ -0,0 +1,6 @@
1
+ import { mountHook } from '@modern-js/core';
2
+
3
+ export const deploy = async () => {
4
+ await (mountHook() as any).beforeDeploy();
5
+ await (mountHook() as any).afterDeploy();
6
+ };
package/src/index.ts CHANGED
@@ -36,9 +36,13 @@ export default createPlugin(
36
36
  .command('build')
37
37
  .usage('[options]')
38
38
  .description(i18n.t(localeKeys.command.build.describe))
39
- .action(async () => {
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);
43
+ // force exit after build.
44
+ // eslint-disable-next-line no-process-exit
45
+ process.exit(0);
42
46
  });
43
47
 
44
48
  program
@@ -49,6 +53,19 @@ export default createPlugin(
49
53
  await start();
50
54
  });
51
55
 
56
+ program
57
+ .command('deploy')
58
+ .usage('[options]')
59
+ .description(i18n.t(localeKeys.command.deploy.describe))
60
+ .action(async () => {
61
+ const { build } = await import('./commands/build');
62
+ await build();
63
+ const { deploy } = await import('./commands/deploy');
64
+ await deploy();
65
+ // eslint-disable-next-line no-process-exit
66
+ process.exit(0);
67
+ });
68
+
52
69
  program
53
70
  .command('new')
54
71
  .usage('[options]')
package/src/lifecycle.ts CHANGED
@@ -24,6 +24,10 @@ export const beforeBuild = createAsyncWorkflow<{
24
24
 
25
25
  export const afterBuild = createAsyncWorkflow();
26
26
 
27
+ export const beforeDeploy = createAsyncWorkflow();
28
+
29
+ export const afterDeploy = createAsyncWorkflow();
30
+
27
31
  export const lifecycle = () => {
28
32
  registerHook({
29
33
  beforeDev,
@@ -33,5 +37,7 @@ export const lifecycle = () => {
33
37
  beforePrintInstructions,
34
38
  beforeBuild,
35
39
  afterBuild,
40
+ beforeDeploy,
41
+ afterDeploy,
36
42
  });
37
43
  };
package/src/locale/en.ts CHANGED
@@ -4,8 +4,9 @@ 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
+ deploy: { describe: 'deploy application' },
9
10
  new: {
10
11
  describe: 'generator runner for MWA project',
11
12
  debug: 'using debug mode to log something',
package/src/locale/zh.ts CHANGED
@@ -4,8 +4,9 @@ export const ZH_LOCALE = {
4
4
  describe: '本地开发命令',
5
5
  config: '制定配置文件路径',
6
6
  },
7
- build: { describe: '构建应用命令' },
7
+ build: { describe: '构建应用命令', analyze: '分析构建产物' },
8
8
  start: { describe: '应用启动命令' },
9
+ deploy: { describe: '部署应用命令' },
9
10
  new: {
10
11
  describe: 'MWA 项目中中执行生成器',
11
12
  debug: '开启 Debug 模式,打印调试日志信息',