@modern-js/app-tools 1.1.3 → 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 +24 -0
- package/dist/js/modern/commands/build.js +13 -2
- package/dist/js/modern/index.js +2 -2
- 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/index.js +2 -2
- 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/index.d.ts +3 -0
- 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 +8 -8
- package/src/commands/build.ts +11 -1
- package/src/index.ts +3 -2
- package/src/locale/en.ts +1 -1
- package/src/locale/zh.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @modern-js/app-tools
|
|
2
2
|
|
|
3
|
+
## 1.1.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
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
|
+
|
|
3
27
|
## 1.1.3
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
|
@@ -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);
|
package/dist/js/modern/index.js
CHANGED
|
@@ -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);
|
|
@@ -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
|
|
package/dist/js/node/index.js
CHANGED
|
@@ -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);
|
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<{
|
|
@@ -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.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,18 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/runtime": "^7",
|
|
35
|
-
"@modern-js/core": "^1.1.
|
|
35
|
+
"@modern-js/core": "^1.1.3",
|
|
36
36
|
"@modern-js/types": "^1.1.2",
|
|
37
37
|
"@modern-js/i18n-cli-language-detector": "^1.1.1",
|
|
38
|
-
"@modern-js/new-action": "^1.1.
|
|
38
|
+
"@modern-js/new-action": "^1.1.5",
|
|
39
39
|
"@modern-js/plugin": "^1.1.2",
|
|
40
40
|
"@modern-js/plugin-analyze": "^1.1.1",
|
|
41
41
|
"@modern-js/plugin-fast-refresh": "^1.1.1",
|
|
42
42
|
"@modern-js/plugin-i18n": "^1.1.1",
|
|
43
43
|
"@modern-js/plugin-polyfill": "^1.1.1",
|
|
44
|
-
"@modern-js/server": "^1.1.
|
|
45
|
-
"@modern-js/utils": "^1.1.
|
|
46
|
-
"@modern-js/webpack": "^1.1.
|
|
44
|
+
"@modern-js/server": "^1.1.3",
|
|
45
|
+
"@modern-js/utils": "^1.1.3",
|
|
46
|
+
"@modern-js/webpack": "^1.1.3",
|
|
47
47
|
"esbuild": "^0.13.13",
|
|
48
48
|
"webpack": "^5.54.0"
|
|
49
49
|
},
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"@types/react": "^17",
|
|
54
54
|
"@types/react-dom": "^17",
|
|
55
55
|
"typescript": "^4",
|
|
56
|
-
"@modern-js/plugin-testing": "^1.1.
|
|
57
|
-
"@modern-js/module-tools": "^1.1.
|
|
56
|
+
"@modern-js/plugin-testing": "^1.1.1",
|
|
57
|
+
"@modern-js/module-tools": "^1.1.1"
|
|
58
58
|
},
|
|
59
59
|
"sideEffects": false,
|
|
60
60
|
"modernConfig": {
|
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/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);
|
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