@modern-js/app-tools 1.6.5 → 1.6.6

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,5 +1,35 @@
1
1
  # @modern-js/app-tools
2
2
 
3
+ ## 1.6.6
4
+
5
+ ### Patch Changes
6
+
7
+ - a1198d509: feat: bump babel 7.18.0
8
+ - d12686040: feat(app-tools): support dev --analyze
9
+ - 8ee2b1b29: fix: remove some unnecessary logs during dev
10
+ - 8f7c0f898: feat(app-tools): support specify config file in build and deploy command
11
+ - Updated dependencies [8d508c6ed]
12
+ - Updated dependencies [0eff2473c]
13
+ - Updated dependencies [a1198d509]
14
+ - Updated dependencies [29728812e]
15
+ - Updated dependencies [f25d6a62e]
16
+ - Updated dependencies [a18926bbd]
17
+ - Updated dependencies [c7e38b4e6]
18
+ - Updated dependencies [147e090f7]
19
+ - Updated dependencies [18892c65c]
20
+ - Updated dependencies [a1198d509]
21
+ - Updated dependencies [8f7c0f898]
22
+ - @modern-js/core@1.11.2
23
+ - @modern-js/webpack@1.10.0
24
+ - @modern-js/server@1.4.18
25
+ - @modern-js/i18n-cli-language-detector@1.2.4
26
+ - @modern-js/plugin-analyze@1.4.6
27
+ - @modern-js/plugin-i18n@1.2.7
28
+ - @modern-js/new-action@1.3.10
29
+ - @modern-js/prod-server@1.1.8
30
+ - @modern-js/node-bundle-require@1.3.5
31
+ - @modern-js/plugin@1.3.6
32
+
3
33
  ## 1.6.5
4
34
 
5
35
  ### Patch Changes
@@ -5,6 +5,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
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
 
7
7
  import { fs, logger, chalk, isSSR, clearConsole } from '@modern-js/utils';
8
+ import { manager, ResolvedConfigContext } from '@modern-js/core';
8
9
  import { createCompiler } from "../utils/createCompiler";
9
10
  import { createServer } from "../utils/createServer";
10
11
  import { generateRoutes } from "../utils/routes";
@@ -12,9 +13,15 @@ import { printInstructions } from "../utils/printInstructions";
12
13
  import { getSpecifiedEntries } from "../utils/getSpecifiedEntries";
13
14
  import { buildServerConfig } from "../utils/config";
14
15
  export const dev = async (api, options) => {
16
+ let userConfig = api.useResolvedConfigContext();
15
17
  const appContext = api.useAppContext();
16
- const userConfig = api.useResolvedConfigContext();
17
18
  const hookRunners = api.useHookRunners();
19
+ manager.run(() => {
20
+ userConfig = _objectSpread(_objectSpread({}, userConfig), {}, {
21
+ cliOptions: options
22
+ });
23
+ ResolvedConfigContext.set(userConfig);
24
+ });
18
25
  const {
19
26
  appDirectory,
20
27
  distDirectory,
@@ -29,10 +29,10 @@ export default (() => ({
29
29
  commands({
30
30
  program
31
31
  }) {
32
- program.command('dev').usage('[options]').description(i18n.t(localeKeys.command.dev.describe)).option('-c --config <config>', i18n.t(localeKeys.command.dev.config)).option('-e --entry [entry...]', i18n.t(localeKeys.command.dev.entry)).option('--api-only', i18n.t(localeKeys.command.dev.apiOnly)).action(async options => {
32
+ program.command('dev').usage('[options]').description(i18n.t(localeKeys.command.dev.describe)).option('-c --config <config>', i18n.t(localeKeys.command.shared.config)).option('-e --entry [entry...]', i18n.t(localeKeys.command.dev.entry)).option('--analyze', i18n.t(localeKeys.command.shared.analyze)).option('--api-only', i18n.t(localeKeys.command.dev.apiOnly)).action(async options => {
33
33
  await dev(api, options);
34
34
  });
35
- program.command('build').usage('[options]').description(i18n.t(localeKeys.command.build.describe)).option('--analyze', i18n.t(localeKeys.command.build.analyze)).action(async options => {
35
+ program.command('build').usage('[options]').description(i18n.t(localeKeys.command.build.describe)).option('-c --config <config>', i18n.t(localeKeys.command.shared.config)).option('--analyze', i18n.t(localeKeys.command.shared.analyze)).action(async options => {
36
36
  const {
37
37
  build
38
38
  } = await import("./commands/build");
@@ -44,7 +44,7 @@ export default (() => ({
44
44
  program.command('start').usage('[options]').description(i18n.t(localeKeys.command.start.describe)).option('--api-only', i18n.t(localeKeys.command.dev.apiOnly)).action(async () => {
45
45
  await start(api);
46
46
  });
47
- program.command('deploy').usage('[options]').description(i18n.t(localeKeys.command.deploy.describe)).action(async options => {
47
+ program.command('deploy').usage('[options]').option('-c --config <config>', i18n.t(localeKeys.command.shared.config)).description(i18n.t(localeKeys.command.deploy.describe)).action(async options => {
48
48
  const {
49
49
  build
50
50
  } = await import("./commands/build");
@@ -1,14 +1,16 @@
1
1
  export const EN_LOCALE = {
2
2
  command: {
3
+ shared: {
4
+ analyze: 'analyze bundle size',
5
+ config: 'specify config file'
6
+ },
3
7
  dev: {
4
8
  describe: 'start dev server',
5
- config: 'specify config file',
6
9
  entry: 'compiler by entry',
7
10
  apiOnly: 'start api server only'
8
11
  },
9
12
  build: {
10
- describe: 'build application',
11
- analyze: 'analyze bundle'
13
+ describe: 'build application'
12
14
  },
13
15
  start: {
14
16
  describe: 'start server'
@@ -1,14 +1,16 @@
1
1
  export const ZH_LOCALE = {
2
2
  command: {
3
+ shared: {
4
+ analyze: '分析构建产物体积,查看各个模块打包后的大小',
5
+ config: '指定配置文件路径,可以为相对路径或绝对路径'
6
+ },
3
7
  dev: {
4
8
  describe: '本地开发命令',
5
- config: '制定配置文件路径',
6
- entry: '按入口编译',
9
+ entry: '指定入口,编译特定的页面',
7
10
  apiOnly: '仅启动 API 接口服务'
8
11
  },
9
12
  build: {
10
- describe: '构建应用命令',
11
- analyze: '分析构建产物体积,查看各个模块打包后的大小'
13
+ describe: '构建应用命令'
12
14
  },
13
15
  start: {
14
16
  describe: '应用启动命令'
@@ -1,13 +1,6 @@
1
1
  import { webpack } from '@modern-js/webpack';
2
2
  import { chalk, logger, formatWebpackMessages, clearConsole } from '@modern-js/utils';
3
3
  import { printInstructions } from "./printInstructions";
4
-
5
- const prettyTime = stats => {
6
- var _stats$children;
7
-
8
- return Math.max(...(((_stats$children = stats.children) === null || _stats$children === void 0 ? void 0 : _stats$children.map(child => child.time || 0)) || []));
9
- };
10
-
11
4
  export const createCompiler = async ({
12
5
  api,
13
6
  webpackConfigs,
@@ -30,7 +23,6 @@ export const createCompiler = async ({
30
23
  logger.log('Compiling...');
31
24
  });
32
25
  compiler.hooks.done.tap('done', async stats => {
33
- clearConsole();
34
26
  const statsData = stats.toJson({
35
27
  all: false,
36
28
  warnings: true,
@@ -53,8 +45,6 @@ export const createCompiler = async ({
53
45
  logger.log(chalk.yellow(`Compiled with warnings.\n`));
54
46
  logger.log(warnings.join('\n\n'));
55
47
  logger.log();
56
- } else {
57
- logger.log(chalk.green(`Compiled successfully in ${prettyTime(statsData)} ms.\n`));
58
48
  }
59
49
 
60
50
  await printInstructions(hookRunners, appContext, userConfig);
@@ -1,14 +1,6 @@
1
- import { prettyInstructions, logger, isDev, chalk } from '@modern-js/utils';
1
+ import { prettyInstructions, logger } from '@modern-js/utils';
2
2
  export const printInstructions = async (hookRunners, appContext, config) => {
3
- let message = prettyInstructions(appContext, config);
4
- const {
5
- apiOnly
6
- } = appContext;
7
-
8
- if (isDev() && !apiOnly) {
9
- message += `\n${chalk.cyanBright([`Note that the development build is not optimized.`, `To create a production build, execute build command.`].join('\n'))}`;
10
- } // call beforePrintInstructions hook.
11
-
3
+ const message = prettyInstructions(appContext, config); // call beforePrintInstructions hook.
12
4
 
13
5
  const {
14
6
  instructions
@@ -7,6 +7,8 @@ exports.dev = void 0;
7
7
 
8
8
  var _utils = require("@modern-js/utils");
9
9
 
10
+ var _core = require("@modern-js/core");
11
+
10
12
  var _createCompiler = require("../utils/createCompiler");
11
13
 
12
14
  var _createServer = require("../utils/createServer");
@@ -30,9 +32,18 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
30
32
  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
33
 
32
34
  const dev = async (api, options) => {
35
+ let userConfig = api.useResolvedConfigContext();
33
36
  const appContext = api.useAppContext();
34
- const userConfig = api.useResolvedConfigContext();
35
37
  const hookRunners = api.useHookRunners();
38
+
39
+ _core.manager.run(() => {
40
+ userConfig = _objectSpread(_objectSpread({}, userConfig), {}, {
41
+ cliOptions: options
42
+ });
43
+
44
+ _core.ResolvedConfigContext.set(userConfig);
45
+ });
46
+
36
47
  const {
37
48
  appDirectory,
38
49
  distDirectory,
@@ -59,10 +59,10 @@ var _default = () => ({
59
59
  commands({
60
60
  program
61
61
  }) {
62
- 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)).option('-e --entry [entry...]', _locale.i18n.t(_locale.localeKeys.command.dev.entry)).option('--api-only', _locale.i18n.t(_locale.localeKeys.command.dev.apiOnly)).action(async options => {
62
+ program.command('dev').usage('[options]').description(_locale.i18n.t(_locale.localeKeys.command.dev.describe)).option('-c --config <config>', _locale.i18n.t(_locale.localeKeys.command.shared.config)).option('-e --entry [entry...]', _locale.i18n.t(_locale.localeKeys.command.dev.entry)).option('--analyze', _locale.i18n.t(_locale.localeKeys.command.shared.analyze)).option('--api-only', _locale.i18n.t(_locale.localeKeys.command.dev.apiOnly)).action(async options => {
63
63
  await (0, _dev.dev)(api, options);
64
64
  });
65
- 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 => {
65
+ program.command('build').usage('[options]').description(_locale.i18n.t(_locale.localeKeys.command.build.describe)).option('-c --config <config>', _locale.i18n.t(_locale.localeKeys.command.shared.config)).option('--analyze', _locale.i18n.t(_locale.localeKeys.command.shared.analyze)).action(async options => {
66
66
  const {
67
67
  build
68
68
  } = await Promise.resolve().then(() => _interopRequireWildcard(require("./commands/build")));
@@ -74,7 +74,7 @@ var _default = () => ({
74
74
  program.command('start').usage('[options]').description(_locale.i18n.t(_locale.localeKeys.command.start.describe)).option('--api-only', _locale.i18n.t(_locale.localeKeys.command.dev.apiOnly)).action(async () => {
75
75
  await (0, _start.start)(api);
76
76
  });
77
- program.command('deploy').usage('[options]').description(_locale.i18n.t(_locale.localeKeys.command.deploy.describe)).action(async options => {
77
+ program.command('deploy').usage('[options]').option('-c --config <config>', _locale.i18n.t(_locale.localeKeys.command.shared.config)).description(_locale.i18n.t(_locale.localeKeys.command.deploy.describe)).action(async options => {
78
78
  const {
79
79
  build
80
80
  } = await Promise.resolve().then(() => _interopRequireWildcard(require("./commands/build")));
@@ -6,15 +6,17 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.EN_LOCALE = void 0;
7
7
  const EN_LOCALE = {
8
8
  command: {
9
+ shared: {
10
+ analyze: 'analyze bundle size',
11
+ config: 'specify config file'
12
+ },
9
13
  dev: {
10
14
  describe: 'start dev server',
11
- config: 'specify config file',
12
15
  entry: 'compiler by entry',
13
16
  apiOnly: 'start api server only'
14
17
  },
15
18
  build: {
16
- describe: 'build application',
17
- analyze: 'analyze bundle'
19
+ describe: 'build application'
18
20
  },
19
21
  start: {
20
22
  describe: 'start server'
@@ -6,15 +6,17 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.ZH_LOCALE = void 0;
7
7
  const ZH_LOCALE = {
8
8
  command: {
9
+ shared: {
10
+ analyze: '分析构建产物体积,查看各个模块打包后的大小',
11
+ config: '指定配置文件路径,可以为相对路径或绝对路径'
12
+ },
9
13
  dev: {
10
14
  describe: '本地开发命令',
11
- config: '制定配置文件路径',
12
- entry: '按入口编译',
15
+ entry: '指定入口,编译特定的页面',
13
16
  apiOnly: '仅启动 API 接口服务'
14
17
  },
15
18
  build: {
16
- describe: '构建应用命令',
17
- analyze: '分析构建产物体积,查看各个模块打包后的大小'
19
+ describe: '构建应用命令'
18
20
  },
19
21
  start: {
20
22
  describe: '应用启动命令'
@@ -11,12 +11,6 @@ var _utils = require("@modern-js/utils");
11
11
 
12
12
  var _printInstructions = require("./printInstructions");
13
13
 
14
- const prettyTime = stats => {
15
- var _stats$children;
16
-
17
- return Math.max(...(((_stats$children = stats.children) === null || _stats$children === void 0 ? void 0 : _stats$children.map(child => child.time || 0)) || []));
18
- };
19
-
20
14
  const createCompiler = async ({
21
15
  api,
22
16
  webpackConfigs,
@@ -40,7 +34,6 @@ const createCompiler = async ({
40
34
  _utils.logger.log('Compiling...');
41
35
  });
42
36
  compiler.hooks.done.tap('done', async stats => {
43
- (0, _utils.clearConsole)();
44
37
  const statsData = stats.toJson({
45
38
  all: false,
46
39
  warnings: true,
@@ -67,8 +60,6 @@ const createCompiler = async ({
67
60
  _utils.logger.log(warnings.join('\n\n'));
68
61
 
69
62
  _utils.logger.log();
70
- } else {
71
- _utils.logger.log(_utils.chalk.green(`Compiled successfully in ${prettyTime(statsData)} ms.\n`));
72
63
  }
73
64
 
74
65
  await (0, _printInstructions.printInstructions)(hookRunners, appContext, userConfig);
@@ -8,15 +8,7 @@ exports.printInstructions = void 0;
8
8
  var _utils = require("@modern-js/utils");
9
9
 
10
10
  const printInstructions = async (hookRunners, appContext, config) => {
11
- let message = (0, _utils.prettyInstructions)(appContext, config);
12
- const {
13
- apiOnly
14
- } = appContext;
15
-
16
- if ((0, _utils.isDev)() && !apiOnly) {
17
- message += `\n${_utils.chalk.cyanBright([`Note that the development build is not optimized.`, `To create a production build, execute build command.`].join('\n'))}`;
18
- } // call beforePrintInstructions hook.
19
-
11
+ const message = (0, _utils.prettyInstructions)(appContext, config); // call beforePrintInstructions hook.
20
12
 
21
13
  const {
22
14
  instructions
@@ -1,3 +1,3 @@
1
- import type { PluginAPI } from '@modern-js/core';
1
+ import { PluginAPI } from '@modern-js/core';
2
2
  import { DevOptions } from '../utils/types';
3
3
  export declare const dev: (api: PluginAPI, options: DevOptions) => Promise<void>;
@@ -1,14 +1,16 @@
1
1
  export declare const EN_LOCALE: {
2
2
  command: {
3
+ shared: {
4
+ analyze: string;
5
+ config: string;
6
+ };
3
7
  dev: {
4
8
  describe: string;
5
- config: string;
6
9
  entry: string;
7
10
  apiOnly: string;
8
11
  };
9
12
  build: {
10
13
  describe: string;
11
- analyze: string;
12
14
  };
13
15
  start: {
14
16
  describe: string;
@@ -2,15 +2,17 @@ import { I18n } from '@modern-js/plugin-i18n';
2
2
  declare const i18n: I18n;
3
3
  declare const localeKeys: {
4
4
  command: {
5
+ shared: {
6
+ analyze: string;
7
+ config: string;
8
+ };
5
9
  dev: {
6
10
  describe: string;
7
- config: string;
8
11
  entry: string;
9
12
  apiOnly: string;
10
13
  };
11
14
  build: {
12
15
  describe: string;
13
- analyze: string;
14
16
  };
15
17
  start: {
16
18
  describe: string;
@@ -28,15 +30,17 @@ declare const localeKeys: {
28
30
  };
29
31
  } | {
30
32
  command: {
33
+ shared: {
34
+ analyze: string;
35
+ config: string;
36
+ };
31
37
  dev: {
32
38
  describe: string;
33
- config: string;
34
39
  entry: string;
35
40
  apiOnly: string;
36
41
  };
37
42
  build: {
38
43
  describe: string;
39
- analyze: string;
40
44
  };
41
45
  start: {
42
46
  describe: string;
@@ -1,14 +1,16 @@
1
1
  export declare const ZH_LOCALE: {
2
2
  command: {
3
+ shared: {
4
+ analyze: string;
5
+ config: string;
6
+ };
3
7
  dev: {
4
8
  describe: string;
5
- config: string;
6
9
  entry: string;
7
10
  apiOnly: string;
8
11
  };
9
12
  build: {
10
13
  describe: string;
11
- analyze: string;
12
14
  };
13
15
  start: {
14
16
  describe: string;
@@ -1,10 +1,16 @@
1
1
  export declare type DevOptions = {
2
2
  entry?: string[] | boolean;
3
+ config?: string;
3
4
  apiOnly?: boolean;
5
+ analyze?: boolean;
4
6
  };
5
7
  export declare type BuildOptions = {
8
+ config?: string;
6
9
  analyze?: boolean;
7
10
  };
11
+ export declare type DeployOptions = {
12
+ config?: string;
13
+ };
8
14
  export declare type StartOptions = {
9
15
  apiOnly?: boolean;
10
16
  };
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.6.5",
14
+ "version": "1.6.6",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -56,19 +56,19 @@
56
56
  "modern": "./bin/modern.js"
57
57
  },
58
58
  "dependencies": {
59
- "@babel/runtime": "^7",
60
- "@modern-js/core": "^1.11.1",
61
- "@modern-js/i18n-cli-language-detector": "^1.2.3",
62
- "@modern-js/new-action": "^1.3.9",
63
- "@modern-js/node-bundle-require": "^1.3.3",
64
- "@modern-js/plugin": "^1.3.4",
65
- "@modern-js/plugin-analyze": "^1.4.5",
66
- "@modern-js/plugin-i18n": "^1.2.6",
67
- "@modern-js/prod-server": "^1.1.6",
68
- "@modern-js/server": "^1.4.16",
59
+ "@babel/runtime": "^7.18.0",
60
+ "@modern-js/core": "^1.11.2",
61
+ "@modern-js/i18n-cli-language-detector": "^1.2.4",
62
+ "@modern-js/new-action": "^1.3.10",
63
+ "@modern-js/node-bundle-require": "^1.3.5",
64
+ "@modern-js/plugin": "^1.3.6",
65
+ "@modern-js/plugin-analyze": "^1.4.6",
66
+ "@modern-js/plugin-i18n": "^1.2.7",
67
+ "@modern-js/prod-server": "^1.1.8",
68
+ "@modern-js/server": "^1.4.18",
69
69
  "@modern-js/types": "^1.5.4",
70
70
  "@modern-js/utils": "^1.7.6",
71
- "@modern-js/webpack": "^1.9.0"
71
+ "@modern-js/webpack": "^1.10.0"
72
72
  },
73
73
  "devDependencies": {
74
74
  "@modern-js/server-core": "1.3.5",