@modern-js/app-tools 0.0.0-bundle-deps-202110124831 → 0.0.0-runtime-2021112193858

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,24 +1,114 @@
1
1
  # @modern-js/app-tools
2
2
 
3
- ## 0.0.0-bundle-deps-202110124831
3
+ ## 0.0.0-runtime-2021112193858
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - test
8
- - Updated dependencies [undefined]
9
- - @modern-js/core@0.0.0-bundle-deps-202110124831
10
- - @modern-js/plugin-analyze@0.0.0-bundle-deps-202110124831
11
- - @modern-js/plugin-fast-refresh@0.0.0-bundle-deps-202110124831
12
- - @modern-js/webpack@0.0.0-bundle-deps-202110124831
13
- - @modern-js/server@0.0.0-bundle-deps-202110124831
14
- - @modern-js/deps@0.0.0-bundle-deps-202110124831
15
- - @modern-js/types@0.0.0-bundle-deps-202110124831
16
- - @modern-js/utils@0.0.0-bundle-deps-202110124831
17
- - @modern-js/i18n-cli-language-detector@0.0.0-bundle-deps-202110124831
18
- - @modern-js/plugin-i18n@0.0.0-bundle-deps-202110124831
19
- - @modern-js/new-action@0.0.0-bundle-deps-202110124831
20
- - @modern-js/plugin-polyfill@0.0.0-bundle-deps-202110124831
21
- - @modern-js/plugin@0.0.0-bundle-deps-202110124831
7
+ - 8698465e: fix: dependence version
8
+ - Updated dependencies [8698465e]
9
+ - Updated dependencies [e04914ce]
10
+ - Updated dependencies [e04914ce]
11
+ - @modern-js/core@0.0.0-runtime-2021112193858
12
+ - @modern-js/i18n-cli-language-detector@0.0.0-runtime-2021112193858
13
+ - @modern-js/plugin-analyze@0.0.0-runtime-2021112193858
14
+ - @modern-js/plugin-fast-refresh@0.0.0-runtime-2021112193858
15
+ - @modern-js/plugin-i18n@0.0.0-runtime-2021112193858
16
+ - @modern-js/webpack@0.0.0-runtime-2021112193858
17
+ - @modern-js/new-action@0.0.0-runtime-2021112193858
18
+ - @modern-js/plugin-polyfill@0.0.0-runtime-2021112193858
19
+ - @modern-js/server@0.0.0-runtime-2021112193858
20
+ - @modern-js/plugin@0.0.0-runtime-2021112193858
21
+ - @modern-js/utils@0.0.0-runtime-2021112193858
22
+ - @modern-js/types@0.0.0-runtime-2021112193858
23
+
24
+ ## 1.1.5
25
+
26
+ ### Patch Changes
27
+
28
+ - d927bc83: remove esbuild and use @modenr-js/esbuild-compiler
29
+ - Updated dependencies [d927bc83]
30
+ - Updated dependencies [d73ff455]
31
+ - Updated dependencies [9c1ab865]
32
+ - Updated dependencies [d73ff455]
33
+ - Updated dependencies [d73ff455]
34
+ - Updated dependencies [d73ff455]
35
+ - Updated dependencies [d73ff455]
36
+ - @modern-js/utils@1.1.4
37
+ - @modern-js/core@1.1.4
38
+ - @modern-js/server@1.1.4
39
+ - @modern-js/types@1.1.3
40
+
41
+ ## 1.1.4
42
+
43
+ ### Patch Changes
44
+
45
+ - ed1f6b12: feat: support build --analyze
46
+ - Updated dependencies [085a6a58]
47
+ - Updated dependencies [085a6a58]
48
+ - Updated dependencies [9a5e6d14]
49
+ - Updated dependencies [085a6a58]
50
+ - Updated dependencies [d280ea33]
51
+ - Updated dependencies [a37192b1]
52
+ - Updated dependencies [d4fcc73a]
53
+ - Updated dependencies [085a6a58]
54
+ - Updated dependencies [ed1f6b12]
55
+ - Updated dependencies [144145c7]
56
+ - Updated dependencies [a5ebbb00]
57
+ - Updated dependencies [b058c6fa]
58
+ - Updated dependencies [085a6a58]
59
+ - @modern-js/core@1.1.3
60
+ - @modern-js/server@1.1.3
61
+ - @modern-js/utils@1.1.3
62
+ - @modern-js/webpack@1.1.3
63
+ - @modern-js/new-action@1.1.5
64
+
65
+ ## 1.1.3
66
+
67
+ ### Patch Changes
68
+
69
+ - 0fa83663: support more .env files
70
+ - Updated dependencies [6f7fe574]
71
+ - Updated dependencies [e4755134]
72
+ - Updated dependencies [0fa83663]
73
+ - Updated dependencies [19b4f79e]
74
+ - Updated dependencies [f594fbc8]
75
+ - Updated dependencies [d1fde77a]
76
+ - @modern-js/core@1.1.2
77
+ - @modern-js/webpack@1.1.2
78
+ - @modern-js/i18n-cli-language-detector@1.1.1
79
+ - @modern-js/plugin-analyze@1.1.1
80
+ - @modern-js/plugin-fast-refresh@1.1.1
81
+ - @modern-js/plugin-i18n@1.1.1
82
+ - @modern-js/new-action@1.1.2
83
+ - @modern-js/plugin-polyfill@1.1.1
84
+ - @modern-js/server@1.1.2
85
+ - @modern-js/plugin@1.1.2
86
+ - @modern-js/types@1.1.2
87
+ - @modern-js/utils@1.1.2
88
+
89
+ ## 1.1.2
90
+
91
+ ### Patch Changes
92
+
93
+ - c0fc0700: feat: support deploy plugin
94
+ - Updated dependencies [3b6856b8]
95
+ - Updated dependencies [687c92c7]
96
+ - Updated dependencies [c0fc0700]
97
+ - Updated dependencies [6ffd1a50]
98
+ - Updated dependencies [c7f4cafb]
99
+ - @modern-js/new-action@1.1.1
100
+ - @modern-js/core@1.1.1
101
+ - @modern-js/webpack@1.1.1
102
+ - @modern-js/server@1.1.1
103
+ - @modern-js/types@1.1.1
104
+ - @modern-js/utils@1.1.1
105
+ - @modern-js/plugin@1.1.1
106
+
107
+ ## 1.1.1
108
+
109
+ ### Patch Changes
110
+
111
+ - 6cfc16e: add esbuild deps
22
112
 
23
113
  ## 1.1.0
24
114
 
@@ -1,11 +1,17 @@
1
- import { webpack } from '@modern-js/deps/compiled/webpack';
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
+
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 options => {
3
+ await mountHook().beforeDeploy(options);
4
+ await mountHook().afterDeploy(options);
5
+ };
@@ -1,6 +1,6 @@
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; }
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] != 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; }
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
 
@@ -1,6 +1,6 @@
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; }
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] != 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; }
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,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 options => {
42
+ const {
43
+ build
44
+ } = await import("./commands/build");
45
+ await build();
46
+ const {
47
+ deploy
48
+ } = await import("./commands/deploy");
49
+ await deploy(options); // 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 模式,打印调试日志信息',
@@ -1,4 +1,4 @@
1
- import webpack from '@modern-js/deps/compiled/webpack';
1
+ import webpack from 'webpack';
2
2
  import { mountHook } from '@modern-js/core';
3
3
  import { chalk, logger, formatWebpackMessages, clearConsole } from '@modern-js/utils';
4
4
  import { printInstructions } from "./printInstructions";
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.build = void 0;
7
7
 
8
- var _webpack = require("@modern-js/deps/compiled/webpack");
8
+ var _webpack = require("webpack");
9
9
 
10
10
  var _webpack2 = require("@modern-js/webpack");
11
11
 
@@ -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
 
@@ -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 options => {
11
+ await (0, _core.mountHook)().beforeDeploy(options);
12
+ await (0, _core.mountHook)().afterDeploy(options);
13
+ };
14
+
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); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
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] != 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; }
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
 
@@ -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); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
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] != 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; }
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,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 options => {
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(options); // 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 模式,打印调试日志信息',
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.createCompiler = void 0;
7
7
 
8
- var _webpack = _interopRequireDefault(require("@modern-js/deps/compiled/webpack"));
8
+ var _webpack = _interopRequireDefault(require("webpack"));
9
9
 
10
10
  var _core = require("@modern-js/core");
11
11
 
@@ -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: (options: any) => 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<Record<string, any>, unknown>;
18
+ export declare const afterDeploy: import("@modern-js/plugin").AsyncWorkflow<Record<string, any>, 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;
@@ -1,4 +1,4 @@
1
- import webpack, { Configuration } from '@modern-js/deps/compiled/webpack';
1
+ import webpack, { Configuration } from 'webpack';
2
2
  import { IAppContext, NormalizedConfig } from '@modern-js/core';
3
3
  export declare const createCompiler: ({
4
4
  webpackConfigs,
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "0.0.0-bundle-deps-202110124831",
14
+ "version": "0.0.0-runtime-2021112193858",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./lib/types.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -32,28 +32,28 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@babel/runtime": "^7",
35
- "@modern-js/core": "^0.0.0-bundle-deps-202110124831",
36
- "@modern-js/types": "^0.0.0-bundle-deps-202110124831",
37
- "@modern-js/i18n-cli-language-detector": "^0.0.0-bundle-deps-202110124831",
38
- "@modern-js/new-action": "^0.0.0-bundle-deps-202110124831",
39
- "@modern-js/plugin": "^0.0.0-bundle-deps-202110124831",
40
- "@modern-js/plugin-analyze": "^0.0.0-bundle-deps-202110124831",
41
- "@modern-js/plugin-fast-refresh": "^0.0.0-bundle-deps-202110124831",
42
- "@modern-js/plugin-i18n": "^0.0.0-bundle-deps-202110124831",
43
- "@modern-js/plugin-polyfill": "^0.0.0-bundle-deps-202110124831",
44
- "@modern-js/server": "^0.0.0-bundle-deps-202110124831",
45
- "@modern-js/utils": "^0.0.0-bundle-deps-202110124831",
46
- "@modern-js/webpack": "^0.0.0-bundle-deps-202110124831",
47
- "@modern-js/deps": "^0.0.0-bundle-deps-202110124831"
35
+ "@modern-js/core": "^0.0.0-runtime-2021112193858",
36
+ "@modern-js/types": "^0.0.0-runtime-2021112193858",
37
+ "@modern-js/i18n-cli-language-detector": "^0.0.0-runtime-2021112193858",
38
+ "@modern-js/new-action": "^0.0.0-runtime-2021112193858",
39
+ "@modern-js/plugin": "^0.0.0-runtime-2021112193858",
40
+ "@modern-js/plugin-analyze": "^0.0.0-runtime-2021112193858",
41
+ "@modern-js/plugin-fast-refresh": "^0.0.0-runtime-2021112193858",
42
+ "@modern-js/plugin-i18n": "^0.0.0-runtime-2021112193858",
43
+ "@modern-js/plugin-polyfill": "^0.0.0-runtime-2021112193858",
44
+ "@modern-js/server": "^0.0.0-runtime-2021112193858",
45
+ "@modern-js/utils": "^0.0.0-runtime-2021112193858",
46
+ "@modern-js/webpack": "^0.0.0-runtime-2021112193858",
47
+ "webpack": "^5.54.0"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@types/jest": "^26",
51
51
  "@types/node": "^14",
52
52
  "@types/react": "^17",
53
53
  "@types/react-dom": "^17",
54
- "typescript": "^4",
55
- "@modern-js/plugin-testing": "^0.0.0-bundle-deps-202110124831",
56
- "@modern-js/module-tools": "^0.0.0-bundle-deps-202110124831"
54
+ "typescript": "^4.4.4",
55
+ "@modern-js/plugin-testing": "^0.0.0-runtime-2021112193858",
56
+ "@modern-js/module-tools": "^0.0.0-runtime-2021112193858"
57
57
  },
58
58
  "sideEffects": false,
59
59
  "modernConfig": {
@@ -1,9 +1,11 @@
1
- import { Configuration, webpack } from '@modern-js/deps/compiled/webpack';
1
+ import { Configuration, webpack } from 'webpack';
2
2
  import { WebpackConfigTarget, getWebpackConfig } from '@modern-js/webpack';
3
3
  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 (options: any) => {
4
+ await (mountHook() as any).beforeDeploy(options);
5
+ await (mountHook() as any).afterDeploy(options);
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 (options: any) => {
61
+ const { build } = await import('./commands/build');
62
+ await build();
63
+ const { deploy } = await import('./commands/deploy');
64
+ await deploy(options);
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<Record<string, any>>();
28
+
29
+ export const afterDeploy = createAsyncWorkflow<Record<string, any>>();
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 模式,打印调试日志信息',
@@ -1,4 +1,4 @@
1
- import webpack, { Configuration, StatsCompilation } from '@modern-js/deps/compiled/webpack';
1
+ import webpack, { Configuration, StatsCompilation } from 'webpack';
2
2
  import { IAppContext, NormalizedConfig, mountHook } from '@modern-js/core';
3
3
  import {
4
4
  chalk,