arui-scripts 23.9.3 → 25.0.0
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/.turbo/turbo-test.log +13 -11
- package/CHANGELOG.md +38 -0
- package/README.md +4 -1
- package/build/commands/build/build-wrapper.js +2 -2
- package/build/commands/build/client.js +26 -8
- package/build/commands/build/server.js +1 -1
- package/build/commands/bundle-analyze/index.js +10 -10
- package/build/commands/start/server.js +1 -1
- package/build/commands/start-prod/client.js +1 -1
- package/build/commands/start-prod/server.js +1 -1
- package/build/commands/util/build-size-budgets.d.ts +6 -0
- package/build/commands/util/build-size-budgets.js +158 -0
- package/build/commands/util/client-assets-sizes.d.ts +1 -1
- package/build/commands/util/client-assets-sizes.js +2 -2
- package/build/commands/util/{format-webpack-messages.d.ts → format-rspack-messages.d.ts} +1 -1
- package/build/commands/util/{format-webpack-messages.js → format-rspack-messages.js} +2 -2
- package/build/configs/app-configs/get-defaults.js +1 -0
- package/build/configs/app-configs/types.d.ts +14 -4
- package/build/configs/app-configs/types.js +3 -0
- package/build/configs/app-configs/validate-build-size-budgets.d.ts +1 -0
- package/build/configs/app-configs/validate-build-size-budgets.js +31 -0
- package/build/configs/app-configs/validate-config.js +2 -0
- package/build/configs/app-configs/warn-about-deprecations.js +0 -5
- package/build/configs/client-env-config/client-config-plugin.js +2 -3
- package/build/configs/config-extras/minimizers/imagemin/imagemin.d.ts +1 -10
- package/build/configs/config-extras/minimizers/imagemin/imagemin.js +2 -14
- package/build/configs/modules.d.ts +2 -4
- package/build/configs/modules.js +23 -25
- package/build/configs/postcss.d.ts +2 -2
- package/build/configs/rspack.client.d.ts +3 -3
- package/build/configs/rspack.client.dev.js +2 -2
- package/build/configs/rspack.client.js +15 -15
- package/build/configs/rspack.client.prod.d.ts +1 -1
- package/build/configs/rspack.client.prod.js +3 -3
- package/build/configs/rspack.server.dev.d.ts +1 -1
- package/build/configs/rspack.server.dev.js +2 -2
- package/build/configs/rspack.server.prod.d.ts +1 -1
- package/build/configs/rspack.server.prod.js +2 -2
- package/build/configs/util/apply-overrides.d.ts +4 -34
- package/build/configs/util/apply-overrides.js +2 -38
- package/build/configs/util/find-plugin.d.ts +1 -1
- package/build/configs/util/find-plugin.js +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.js +1 -2
- package/docs/cli.md +2 -0
- package/docs/commands.md +5 -0
- package/docs/overrides.md +25 -25
- package/docs/settings.md +37 -2
- package/package.json +7 -5
- package/tsconfig-local.tsbuildinfo +1 -1
- package/build/configs/util/get-webpack-cache-dependencies.d.ts +0 -1
- package/build/configs/util/get-webpack-cache-dependencies.js +0 -15
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
ts-jest[versions] (WARN) Version 6.0.2 of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=4.3.0 <6.0.0-0). Please do not report issues in ts-jest if you are using unsupported versions.
|
|
2
2
|
ts-jest[versions] (WARN) Version 6.0.2 of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=4.3.0 <6.0.0-0). Please do not report issues in ts-jest if you are using unsupported versions.
|
|
3
3
|
ts-jest[versions] (WARN) Version 6.0.2 of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=4.3.0 <6.0.0-0). Please do not report issues in ts-jest if you are using unsupported versions.
|
|
4
|
-
PASS src/
|
|
4
|
+
PASS src/plugins/__tests__/attribute-module-css.tests.ts (34.601 s)
|
|
5
|
+
PASS src/commands/util/__tests__/build-size-budgets.tests.ts (36.218 s)
|
|
6
|
+
PASS src/commands/util/__tests__/run-compilers.tests.ts
|
|
5
7
|
PASS src/plugins/postcss-global-variables/utils/__tests__/add-global-variable.tests.ts
|
|
6
8
|
PASS src/bin/__tests__/create-cli.tests.ts
|
|
7
9
|
PASS src/configs/app-configs/__tests__/update-with-presets.tests.ts
|
|
8
10
|
PASS src/configs/util/__tests__/create-watch-ignore-regex.tests.ts
|
|
9
11
|
PASS src/configs/util/__tests__/apply-overrides.tests.ts
|
|
10
12
|
PASS src/commands/util/__tests__/artifacts-deprecations.tests.ts
|
|
11
|
-
PASS src/plugins/__tests__/attribute-module-css.tests.ts (38.033 s)
|
|
12
13
|
PASS src/configs/app-configs/__tests__/update-with-env.tests.ts
|
|
13
|
-
PASS src/configs/util/__tests__/find-plugin.tests.ts (
|
|
14
|
-
PASS src/configs/__tests__/rspack-client-assets.tests.ts (18.834 s)
|
|
14
|
+
PASS src/configs/util/__tests__/find-plugin.tests.ts (39.598 s)
|
|
15
15
|
PASS src/configs/app-configs/__tests__/update-with-package.tests.ts
|
|
16
|
+
PASS src/configs/__tests__/rspack-client-assets.tests.ts (5.388 s)
|
|
17
|
+
PASS src/configs/util/__tests__/compress-with-dcb.test.ts
|
|
16
18
|
PASS src/configs/util/__tests__/get-polyfills.tests.ts
|
|
17
|
-
PASS src/configs/__tests__/webpack-client-modules.tests.ts
|
|
18
19
|
PASS src/plugins/postcss-global-variables/utils/__tests__/parse-variables.tests.ts
|
|
19
|
-
PASS src/configs/util/__tests__/compress-with-dcb.test.ts
|
|
20
|
-
PASS src/configs/app-configs/__tests__/validate-settings-keys.tests.ts
|
|
21
|
-
PASS src/plugins/postcss-global-variables/utils/__tests__/get-media-query-name.tests.ts
|
|
22
20
|
PASS src/commands/util/__tests__/client-assets-sizes.tests.ts
|
|
21
|
+
PASS src/plugins/postcss-global-variables/utils/__tests__/get-media-query-name.tests.ts
|
|
22
|
+
PASS src/configs/__tests__/rspack-client-modules.tests.ts
|
|
23
|
+
PASS src/configs/app-configs/__tests__/validate-build-size-budgets.tests.ts
|
|
24
|
+
PASS src/configs/app-configs/__tests__/validate-settings-keys.tests.ts
|
|
23
25
|
|
|
24
|
-
Test Suites:
|
|
25
|
-
Tests:
|
|
26
|
+
Test Suites: 21 passed, 21 total
|
|
27
|
+
Tests: 97 passed, 97 total
|
|
26
28
|
Snapshots: 0 total
|
|
27
|
-
Time:
|
|
29
|
+
Time: 41.859 s
|
|
28
30
|
Ran all test suites.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# arui-scripts
|
|
2
2
|
|
|
3
|
+
## 25.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#615](https://github.com/core-ds/arui-scripts/pull/615) [`3bd3e860`](https://github.com/core-ds/arui-scripts/commit/3bd3e86002c6d5966f0a6aada5f3554819bd3e7d) Thanks [@dmitrbrvsk](https://github.com/dmitrbrvsk)! - Удалены deprecated webpack имена из кодовой базы.
|
|
8
|
+
В оверрайдах, настройках остались только имена rspack.
|
|
9
|
+
|
|
10
|
+
**Что сделать пользователю**
|
|
11
|
+
|
|
12
|
+
Замените имена один в один:
|
|
13
|
+
|
|
14
|
+
- ключи оверрайдов `webpack*` на такие же `rspack*` (`webpackClient` -> `rspackClient` и т.д.);
|
|
15
|
+
- `disableDevWebpackTypecheck` -> `disableDevRspackTypecheck`;
|
|
16
|
+
- `patchMainWebpackConfigForModules` -> `patchMainRspackConfigForModules`;
|
|
17
|
+
- `createSingleClientWebpackConfig` -> `createSingleClientRspackConfig`;
|
|
18
|
+
- в `findPlugin` ключ `ForkTsCheckerWebpackPlugin` -> `TsCheckerRspackPlugin`.
|
|
19
|
+
|
|
20
|
+
### Minor Changes
|
|
21
|
+
|
|
22
|
+
- [#614](https://github.com/core-ds/arui-scripts/pull/614) [`13254a03`](https://github.com/core-ds/arui-scripts/commit/13254a030228e2486714ef3abac69fd6a0c83f43) Thanks [@dmitrbrvsk](https://github.com/dmitrbrvsk)! - Добавлена настройка buildSizeBudgets для контроля размера начального JS и CSS при production сборке.
|
|
23
|
+
Лимиты задаются в байтах для файлов без сжатия и gzip и проверяются отдельно для каждой точки входа.
|
|
24
|
+
При превышении сборка завершается с ошибкой, по умолчанию проверка выключена.
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- [#623](https://github.com/core-ds/arui-scripts/pull/623) [`5fa1063e`](https://github.com/core-ds/arui-scripts/commit/5fa1063ea39fa6b3bf9e3c0c6b2ed4e00bbb869d) Thanks [@dmitrbrvsk](https://github.com/dmitrbrvsk)! - Исправлены варнинги svgo `You are trying to configure removeViewBox which is not part of preset-default` в production сборке при включенной минификации svg
|
|
29
|
+
|
|
30
|
+
## 24.0.0
|
|
31
|
+
|
|
32
|
+
### Major Changes
|
|
33
|
+
|
|
34
|
+
- [#609](https://github.com/core-ds/arui-scripts/pull/609) [`fdc0e343`](https://github.com/core-ds/arui-scripts/commit/fdc0e3433d79884165072aa0f68c94345b574f71) Thanks [@dmitrbrvsk](https://github.com/dmitrbrvsk)! - Vitest обновлен с v4 до v5
|
|
35
|
+
|
|
36
|
+
## Почему мажорный релиз
|
|
37
|
+
|
|
38
|
+
Vitest 5 требует Node.js `^22.12.0 || ^24.0.0 || >=26.0.0`.
|
|
39
|
+
Полный список изменений: [Migrating to Vitest 5](https://vitest.dev/guide/migration/#vitest-5)
|
|
40
|
+
|
|
3
41
|
## 23.9.3
|
|
4
42
|
|
|
5
43
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ CLI `arui-scripts` поддерживает глобальные флаги `--h
|
|
|
27
27
|
|
|
28
28
|
Зависимость | Версия
|
|
29
29
|
-- | --
|
|
30
|
-
`nodejs` | `
|
|
30
|
+
`nodejs` | `22.12.0+, 24.0.0+, 26.0.0+`
|
|
31
31
|
`react` | `16.13.0+`
|
|
32
32
|
`react-dom` | `16.13.0+`
|
|
33
33
|
|
|
@@ -80,3 +80,6 @@ npm install arui-scripts --save-dev
|
|
|
80
80
|
- [Использование модулей](docs/modules.md)
|
|
81
81
|
- [Client-only режим](./docs/client-only.md)
|
|
82
82
|
- [Словарь для сжатия](./docs/compression-dictionary.md)
|
|
83
|
+
|
|
84
|
+
Размер начального JS и CSS можно контролировать настройкой [buildSizeBudgets](docs/settings.md#buildsizebudgets).
|
|
85
|
+
При превышении лимита сборка завершается с ошибкой.
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const core_1 = require("@rspack/core");
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const
|
|
8
|
+
const format_rspack_messages_1 = require("../util/format-rspack-messages");
|
|
9
9
|
function build(config, previousFileSizes) {
|
|
10
10
|
const compiler = (0, core_1.rspack)(config);
|
|
11
11
|
return new Promise((resolve, reject) => {
|
|
@@ -13,7 +13,7 @@ function build(config, previousFileSizes) {
|
|
|
13
13
|
if (err) {
|
|
14
14
|
return reject(err);
|
|
15
15
|
}
|
|
16
|
-
const messages = (0,
|
|
16
|
+
const messages = (0, format_rspack_messages_1.formatRspackMessages)(stats === null || stats === void 0 ? void 0 : stats.toJson({}));
|
|
17
17
|
if (messages.errors.length) {
|
|
18
18
|
// Only keep the first error. Others are often indicative
|
|
19
19
|
// of the same problem, but confuse the reader with noise.
|
|
@@ -13,17 +13,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const chalk_1 = __importDefault(require("chalk"));
|
|
16
|
+
const app_configs_1 = require("../../configs/app-configs");
|
|
16
17
|
const rspack_client_prod_1 = require("../../configs/rspack.client.prod");
|
|
18
|
+
const build_size_budgets_1 = require("../util/build-size-budgets");
|
|
17
19
|
const client_assets_sizes_1 = require("../util/client-assets-sizes");
|
|
18
20
|
const load_browserslist_1 = require("../util/load-browserslist");
|
|
19
21
|
const print_build_error_1 = require("../util/print-build-error");
|
|
20
22
|
const build_wrapper_1 = __importDefault(require("./build-wrapper"));
|
|
21
23
|
(0, load_browserslist_1.loadBrowserslist)();
|
|
22
24
|
console.log(chalk_1.default.magenta('Building client...'));
|
|
25
|
+
function printOutputSizes(webpackConfig, stats) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
const name = webpackConfig.name || 'main';
|
|
28
|
+
console.log(chalk_1.default.bold(`Sizes for "${name}"`));
|
|
29
|
+
try {
|
|
30
|
+
(0, client_assets_sizes_1.printAssetsSizes)(stats);
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
console.warn(chalk_1.default.yellow(`Could not report asset sizes for "${name}": ${error instanceof Error ? error.message : String(error)}`));
|
|
34
|
+
}
|
|
35
|
+
yield (0, build_size_budgets_1.checkBuildSizeBudgets)(stats, app_configs_1.configs.buildSizeBudgets, name);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
23
38
|
function main() {
|
|
24
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
40
|
try {
|
|
26
|
-
const { stats, warnings } = yield (0, build_wrapper_1.default)(rspack_client_prod_1.
|
|
41
|
+
const { stats, warnings } = yield (0, build_wrapper_1.default)(rspack_client_prod_1.rspackClientConfig);
|
|
27
42
|
if (warnings.length) {
|
|
28
43
|
console.log(chalk_1.default.yellow('Client compiled with warnings.\n'));
|
|
29
44
|
console.log(warnings.join('\n\n'));
|
|
@@ -33,18 +48,21 @@ function main() {
|
|
|
33
48
|
else {
|
|
34
49
|
console.log(chalk_1.default.green('Client compiled successfully.\n'));
|
|
35
50
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
51
|
+
if (Array.isArray(rspack_client_prod_1.rspackClientConfig)) {
|
|
52
|
+
for (const [index, conf] of rspack_client_prod_1.rspackClientConfig.entries()) {
|
|
53
|
+
// measure builds sequentially to bound gzip memory use
|
|
54
|
+
// eslint-disable-next-line no-await-in-loop
|
|
55
|
+
yield printOutputSizes(conf, stats.stats[index]);
|
|
56
|
+
}
|
|
42
57
|
}
|
|
43
58
|
else {
|
|
44
|
-
printOutputSizes(rspack_client_prod_1.
|
|
59
|
+
yield printOutputSizes(rspack_client_prod_1.rspackClientConfig, stats);
|
|
45
60
|
}
|
|
46
61
|
}
|
|
47
62
|
catch (err) {
|
|
63
|
+
if (err instanceof build_size_budgets_1.BuildSizeBudgetError) {
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
48
66
|
console.log(chalk_1.default.red('Failed to compile client.\n'));
|
|
49
67
|
(0, print_build_error_1.printBuildError)(err);
|
|
50
68
|
process.exit(1);
|
|
@@ -10,7 +10,7 @@ const print_build_error_1 = require("../util/print-build-error");
|
|
|
10
10
|
const build_wrapper_1 = __importDefault(require("./build-wrapper"));
|
|
11
11
|
process.env.BROWSERSLIST = supporting_node_1.supportingNode.join(',');
|
|
12
12
|
console.log(chalk_1.default.magenta('Building server...'));
|
|
13
|
-
(0, build_wrapper_1.default)(rspack_server_prod_1.
|
|
13
|
+
(0, build_wrapper_1.default)(rspack_server_prod_1.rspackServerConfig)
|
|
14
14
|
.then(({ warnings }) => {
|
|
15
15
|
if (warnings.length) {
|
|
16
16
|
console.log(chalk_1.default.yellow('Server compiled with warnings.\n'));
|
|
@@ -30,15 +30,15 @@ const bundleAnalyzerStatsOptions = {
|
|
|
30
30
|
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
31
|
(0, load_browserslist_1.loadBrowserslist)();
|
|
32
32
|
console.log('Starting bundle analysis...');
|
|
33
|
-
const
|
|
34
|
-
? rspack_client_prod_1.
|
|
35
|
-
: [rspack_client_prod_1.
|
|
33
|
+
const clientRspackConfigs = Array.isArray(rspack_client_prod_1.rspackClientConfig)
|
|
34
|
+
? rspack_client_prod_1.rspackClientConfig
|
|
35
|
+
: [rspack_client_prod_1.rspackClientConfig];
|
|
36
36
|
/* eslint-disable no-param-reassign */
|
|
37
|
-
const promises =
|
|
37
|
+
const promises = clientRspackConfigs.map((rspackConfig, i) => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
38
|
const tmpDir = yield (0, make_tmp_dir_1.makeTmpDir)(i.toString());
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
...(
|
|
39
|
+
const rspackStatsOptions = Object.assign(Object.assign({}, (typeof rspackConfig.stats === 'object' ? rspackConfig.stats : {})), bundleAnalyzerStatsOptions);
|
|
40
|
+
rspackConfig.plugins = [
|
|
41
|
+
...(rspackConfig.plugins || []),
|
|
42
42
|
new webpack_bundle_analyzer_1.BundleAnalyzerPlugin({
|
|
43
43
|
generateStatsFile: true,
|
|
44
44
|
statsFilename: app_configs_1.configs.statsOutputPath,
|
|
@@ -50,11 +50,11 @@ const bundleAnalyzerStatsOptions = {
|
|
|
50
50
|
}), // webpack-bundle-analyzer has incorrect types
|
|
51
51
|
new rspack_plugin_1.RsdoctorRspackPlugin({}),
|
|
52
52
|
];
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
rspackConfig.stats = rspackStatsOptions;
|
|
54
|
+
rspackConfig.output = Object.assign(Object.assign({}, rspackConfig.output), { path: tmpDir });
|
|
55
55
|
}));
|
|
56
56
|
yield Promise.all(promises);
|
|
57
|
-
(0, core_1.rspack)(
|
|
57
|
+
(0, core_1.rspack)(clientRspackConfigs).run((err, stats) => {
|
|
58
58
|
var _a, _b;
|
|
59
59
|
if (err) {
|
|
60
60
|
console.error('Bundle analysis failed with error: ', err);
|
|
@@ -4,4 +4,4 @@ const rspack_server_dev_1 = require("../../configs/rspack.server.dev");
|
|
|
4
4
|
const supporting_node_1 = require("../../configs/supporting-node");
|
|
5
5
|
const run_server_watch_compiler_1 = require("../util/run-server-watch-compiler");
|
|
6
6
|
process.env.BROWSERSLIST = supporting_node_1.supportingNode.join(',');
|
|
7
|
-
(0, run_server_watch_compiler_1.runServerWatchCompiler)(rspack_server_dev_1.
|
|
7
|
+
(0, run_server_watch_compiler_1.runServerWatchCompiler)(rspack_server_dev_1.rspackServerConfig);
|
|
@@ -4,4 +4,4 @@ const rspack_client_prod_1 = require("../../configs/rspack.client.prod");
|
|
|
4
4
|
const load_browserslist_1 = require("../util/load-browserslist");
|
|
5
5
|
const run_client_dev_server_1 = require("../util/run-client-dev-server");
|
|
6
6
|
(0, load_browserslist_1.loadBrowserslist)();
|
|
7
|
-
(0, run_client_dev_server_1.runClientDevServer)(rspack_client_prod_1.
|
|
7
|
+
(0, run_client_dev_server_1.runClientDevServer)(rspack_client_prod_1.rspackClientConfig);
|
|
@@ -4,4 +4,4 @@ const rspack_server_prod_1 = require("../../configs/rspack.server.prod");
|
|
|
4
4
|
const supporting_node_1 = require("../../configs/supporting-node");
|
|
5
5
|
const run_server_watch_compiler_1 = require("../util/run-server-watch-compiler");
|
|
6
6
|
process.env.BROWSERSLIST = supporting_node_1.supportingNode.join(',');
|
|
7
|
-
(0, run_server_watch_compiler_1.runServerWatchCompiler)(rspack_server_prod_1.
|
|
7
|
+
(0, run_server_watch_compiler_1.runServerWatchCompiler)(rspack_server_prod_1.rspackServerConfig);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Stats } from '@rspack/core';
|
|
2
|
+
import { type BuildSizeBudgets } from '../../configs/app-configs/types';
|
|
3
|
+
export declare class BuildSizeBudgetError extends Error {
|
|
4
|
+
constructor(messages: string[]);
|
|
5
|
+
}
|
|
6
|
+
export declare function checkBuildSizeBudgets(stats: Stats, budgets: BuildSizeBudgets | null, buildName?: string): Promise<void>;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.BuildSizeBudgetError = void 0;
|
|
16
|
+
exports.checkBuildSizeBudgets = checkBuildSizeBudgets;
|
|
17
|
+
const promises_1 = require("fs/promises");
|
|
18
|
+
const path_1 = __importDefault(require("path"));
|
|
19
|
+
const util_1 = require("util");
|
|
20
|
+
const zlib_1 = require("zlib");
|
|
21
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
22
|
+
const filesize_1 = __importDefault(require("filesize"));
|
|
23
|
+
const types_1 = require("../../configs/app-configs/types");
|
|
24
|
+
class BuildSizeBudgetError extends Error {
|
|
25
|
+
constructor(messages) {
|
|
26
|
+
super(messages.join('\n'));
|
|
27
|
+
this.name = 'BuildSizeBudgetError';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.BuildSizeBudgetError = BuildSizeBudgetError;
|
|
31
|
+
const gzipAsync = (0, util_1.promisify)(zlib_1.gzip);
|
|
32
|
+
// CompressionPlugin по умолчанию жмёт gzip с Z_BEST_COMPRESSION (9).
|
|
33
|
+
// Фоллбек в памяти берёт тот же уровень, чтобы файл без готового .gz
|
|
34
|
+
// получил тот же размер, что и файл, для которого плагин уже записал .gz.
|
|
35
|
+
const GZIP_LEVEL = zlib_1.constants.Z_BEST_COMPRESSION;
|
|
36
|
+
const ASSET_PATTERN = {
|
|
37
|
+
js: /\.(?:js|mjs|cjs)$/i,
|
|
38
|
+
css: /\.css$/i,
|
|
39
|
+
};
|
|
40
|
+
function warn(message) {
|
|
41
|
+
console.warn(chalk_1.default.yellow(message));
|
|
42
|
+
}
|
|
43
|
+
function reportOverBudget(messages) {
|
|
44
|
+
if (!messages.length) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
console.warn(chalk_1.default.bgRed.white.bold('\n BUILD SIZE BUDGET EXCEEDED '));
|
|
48
|
+
for (const message of messages) {
|
|
49
|
+
console.warn(chalk_1.default.red.bold(message));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function isConfigured(limits) {
|
|
53
|
+
return Object.keys(limits !== null && limits !== void 0 ? limits : {}).length > 0;
|
|
54
|
+
}
|
|
55
|
+
// получаем файлы точки входа вместе с файлами начальных родительских чанков
|
|
56
|
+
function getInitialFiles(group, visited = new Set()) {
|
|
57
|
+
if (visited.has(group)) {
|
|
58
|
+
return new Set();
|
|
59
|
+
}
|
|
60
|
+
visited.add(group);
|
|
61
|
+
const files = new Set(group.getFiles());
|
|
62
|
+
for (const parent of group.getParents()) {
|
|
63
|
+
if (parent.isInitial()) {
|
|
64
|
+
getInitialFiles(parent, visited).forEach((file) => files.add(file));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return files;
|
|
68
|
+
}
|
|
69
|
+
function calcAssetSizes(compilation, outputPath, file, withGzip) {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
var _a;
|
|
72
|
+
if (!outputPath) {
|
|
73
|
+
throw new Error('output.path is missing');
|
|
74
|
+
}
|
|
75
|
+
const content = yield (0, promises_1.readFile)(path_1.default.resolve(outputPath, file));
|
|
76
|
+
const emitted = withGzip ? compilation.getAsset(`${file}.gz`) : undefined;
|
|
77
|
+
return {
|
|
78
|
+
raw: content.length,
|
|
79
|
+
gzip: (_a = emitted === null || emitted === void 0 ? void 0 : emitted.source.size()) !== null && _a !== void 0 ? _a : (withGzip ? (yield gzipAsync(content, { level: GZIP_LEVEL })).length : 0),
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
function calcInitialAssetSizes(cache, files, type, withGzip) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
const sizes = { raw: 0, gzip: 0 };
|
|
86
|
+
const matchingFiles = [...files].filter((file) => ASSET_PATTERN[type].test(file));
|
|
87
|
+
for (const file of matchingFiles) {
|
|
88
|
+
let pending = cache.measurements.get(file);
|
|
89
|
+
if (!pending) {
|
|
90
|
+
pending = calcAssetSizes(cache.compilation, cache.outputPath, file, withGzip);
|
|
91
|
+
cache.measurements.set(file, pending);
|
|
92
|
+
}
|
|
93
|
+
// держим в памяти не больше одного буфера или сжатия одновременно.
|
|
94
|
+
// eslint-disable-next-line no-await-in-loop
|
|
95
|
+
const size = yield pending;
|
|
96
|
+
sizes.raw += size.raw;
|
|
97
|
+
sizes.gzip += size.gzip;
|
|
98
|
+
}
|
|
99
|
+
return sizes;
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
function formatSize(bytes) {
|
|
103
|
+
return (0, filesize_1.default)(bytes, { exponent: bytes >= 1024 ** 2 ? 2 : -1 });
|
|
104
|
+
}
|
|
105
|
+
function overBudgetMessages(compilerName, entryName, type, limits, sizes) {
|
|
106
|
+
const messages = [];
|
|
107
|
+
for (const metric of types_1.BUILD_SIZE_METRICS) {
|
|
108
|
+
const limit = limits[metric];
|
|
109
|
+
const actual = sizes[metric];
|
|
110
|
+
if (limit !== undefined && actual > limit) {
|
|
111
|
+
messages.push(`[buildSizeBudgets] ${compilerName}/${entryName}: initial ${type.toUpperCase()} (${metric}) is ${formatSize(actual)}; limit ${formatSize(limit)}; exceeded by ${formatSize(actual - limit)}.`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return messages;
|
|
115
|
+
}
|
|
116
|
+
function failedToMeasureMessage(compilerName, entryName, type, error) {
|
|
117
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
118
|
+
return `[buildSizeBudgets] Could not measure ${compilerName}/${entryName} ${type.toUpperCase()}: ${message}`;
|
|
119
|
+
}
|
|
120
|
+
function checkBuildSizeBudgets(stats, budgets, buildName) {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
if (!budgets) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const configuredTypes = types_1.BUILD_SIZE_ASSET_TYPES.filter((type) => isConfigured(budgets[type]));
|
|
126
|
+
if (!configuredTypes.length) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const { compilation } = stats;
|
|
130
|
+
const compilerName = buildName || compilation.name || 'main';
|
|
131
|
+
const cache = {
|
|
132
|
+
compilation,
|
|
133
|
+
outputPath: compilation.outputOptions.path,
|
|
134
|
+
measurements: new Map(),
|
|
135
|
+
};
|
|
136
|
+
const overBudget = [];
|
|
137
|
+
for (const [entryName, entrypoint] of compilation.entrypoints) {
|
|
138
|
+
for (const type of configuredTypes) {
|
|
139
|
+
const limits = budgets[type];
|
|
140
|
+
try {
|
|
141
|
+
// точки входа измеряем по очереди, чтобы не держать несколько gzip сразу.
|
|
142
|
+
// eslint-disable-next-line no-await-in-loop
|
|
143
|
+
const sizes = yield calcInitialAssetSizes(cache, getInitialFiles(entrypoint), type, limits.gzip !== undefined);
|
|
144
|
+
overBudget.push(...overBudgetMessages(compilerName, entryName, type, limits, sizes));
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
const message = failedToMeasureMessage(compilerName, entryName, type, error);
|
|
148
|
+
warn(message);
|
|
149
|
+
throw new BuildSizeBudgetError([message]);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
reportOverBudget(overBudget);
|
|
154
|
+
if (overBudget.length) {
|
|
155
|
+
throw new BuildSizeBudgetError(overBudget);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type Stats } from '@rspack/core';
|
|
2
|
-
export declare function printAssetsSizes(
|
|
2
|
+
export declare function printAssetsSizes(rspackStats: Stats): void;
|
|
@@ -15,8 +15,8 @@ function removeFileNameHash(fileName) {
|
|
|
15
15
|
const extension = parts.find((p) => ['js', 'css'].includes(p));
|
|
16
16
|
return `${id}${isChunk ? '.chunk' : ''}.${extension}`;
|
|
17
17
|
}
|
|
18
|
-
function printAssetsSizes(
|
|
19
|
-
const assetsStats =
|
|
18
|
+
function printAssetsSizes(rspackStats) {
|
|
19
|
+
const assetsStats = rspackStats.toJson({ all: false, assets: true }).assets || [];
|
|
20
20
|
const assetsMap = {};
|
|
21
21
|
const statExtensions = ['js', 'css', 'br', 'gz', 'dcb'];
|
|
22
22
|
assetsStats.forEach((asset) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type StatsCompilation } from '@rspack/core';
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function formatRspackMessages(json: StatsCompilation | undefined): {
|
|
3
3
|
errors: string[];
|
|
4
4
|
warnings: string[];
|
|
5
5
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.formatRspackMessages = formatRspackMessages;
|
|
4
4
|
/**
|
|
5
5
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
6
6
|
*
|
|
@@ -82,7 +82,7 @@ function formatMessage(message) {
|
|
|
82
82
|
newMessage = lines.join('\n');
|
|
83
83
|
return newMessage.trim();
|
|
84
84
|
}
|
|
85
|
-
function
|
|
85
|
+
function formatRspackMessages(json) {
|
|
86
86
|
var _a, _b;
|
|
87
87
|
const formattedErrors = ((_a = json === null || json === void 0 ? void 0 : json.errors) === null || _a === void 0 ? void 0 : _a.map(formatMessage)) || [];
|
|
88
88
|
const formattedWarnings = ((_b = json === null || json === void 0 ? void 0 : json.warnings) === null || _b === void 0 ? void 0 : _b.map(formatMessage)) || [];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type DevTool, type Shared } from '@rspack/core';
|
|
2
2
|
import { type Configuration as DevServerConfiguration } from '@rspack/dev-server';
|
|
3
3
|
import { type PluginOptions as ReactCompilerOptions } from 'babel-plugin-react-compiler';
|
|
4
|
-
import type
|
|
4
|
+
import type NodeExternals from 'webpack-node-externals';
|
|
5
5
|
import { type NginxBaseConfOptions } from '@alfalab/arui-scripts-artifacts';
|
|
6
6
|
/**
|
|
7
7
|
* Конфигурация arui-scripts, которая может быть переопределена приложением
|
|
@@ -48,13 +48,12 @@ export type AppConfigs = {
|
|
|
48
48
|
dictionaryPath: string[];
|
|
49
49
|
enablePreviousVersionHeaders?: boolean;
|
|
50
50
|
};
|
|
51
|
+
buildSizeBudgets: BuildSizeBudgets | null;
|
|
51
52
|
keepPropTypes: boolean;
|
|
52
53
|
codeLoader: 'babel' | 'tsc' | 'swc';
|
|
53
54
|
experimentalReactCompiler: 'disabled' | ReactCompilerOptions;
|
|
54
55
|
installServerSourceMaps: boolean;
|
|
55
56
|
disableDevRspackTypecheck: boolean;
|
|
56
|
-
/** @deprecated используйте `disableDevRspackTypecheck` */
|
|
57
|
-
disableDevWebpackTypecheck?: boolean;
|
|
58
57
|
jestCodeTransformer: 'babel' | 'tsc' | 'swc';
|
|
59
58
|
jestTransformNodeModules: string[];
|
|
60
59
|
collectCoverage: boolean;
|
|
@@ -98,7 +97,7 @@ export type AppConfigs = {
|
|
|
98
97
|
options?: ModuleConfigBase;
|
|
99
98
|
shareScope?: string;
|
|
100
99
|
} | null;
|
|
101
|
-
nodeExternals?: Omit<
|
|
100
|
+
nodeExternals?: Omit<NodeExternals.Options, 'allowlist'>;
|
|
102
101
|
};
|
|
103
102
|
export type ModuleConfigBase = {
|
|
104
103
|
cssPrefix?: false | string;
|
|
@@ -148,4 +147,15 @@ export type AppContext = {
|
|
|
148
147
|
};
|
|
149
148
|
export type AppContextWithConfigs = AppContext & AppConfigs;
|
|
150
149
|
export type PackageSettings = Partial<AppConfigs>;
|
|
150
|
+
export declare const BUILD_SIZE_ASSET_TYPES: readonly ["js", "css"];
|
|
151
|
+
export declare const BUILD_SIZE_METRICS: readonly ["raw", "gzip"];
|
|
152
|
+
export type BuildSizeAssetType = (typeof BUILD_SIZE_ASSET_TYPES)[number];
|
|
153
|
+
export type BuildSizeMetric = (typeof BUILD_SIZE_METRICS)[number];
|
|
154
|
+
export type BuildSizeLimit = {
|
|
155
|
+
[metric in BuildSizeMetric]?: number;
|
|
156
|
+
};
|
|
157
|
+
/** Absolute initial asset limits per client entrypoint, in bytes. */
|
|
158
|
+
export type BuildSizeBudgets = {
|
|
159
|
+
[type in BuildSizeAssetType]?: BuildSizeLimit;
|
|
160
|
+
};
|
|
151
161
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function validateBuildSizeBudgets(value: unknown): void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateBuildSizeBudgets = validateBuildSizeBudgets;
|
|
4
|
+
const types_1 = require("./types");
|
|
5
|
+
function isObject(value) {
|
|
6
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
7
|
+
}
|
|
8
|
+
function isAssetType(value) {
|
|
9
|
+
return types_1.BUILD_SIZE_ASSET_TYPES.includes(value);
|
|
10
|
+
}
|
|
11
|
+
function isMetric(value) {
|
|
12
|
+
return types_1.BUILD_SIZE_METRICS.includes(value);
|
|
13
|
+
}
|
|
14
|
+
function validateBuildSizeBudgets(value) {
|
|
15
|
+
if (value === null || value === undefined) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (!isObject(value)) {
|
|
19
|
+
throw new Error('`buildSizeBudgets` должен быть объектом или `null`');
|
|
20
|
+
}
|
|
21
|
+
Object.entries(value).forEach(([type, limits]) => {
|
|
22
|
+
if (!isAssetType(type) || !isObject(limits)) {
|
|
23
|
+
throw new Error('`buildSizeBudgets` принимает только объекты `js` и `css`');
|
|
24
|
+
}
|
|
25
|
+
Object.entries(limits).forEach(([metric, limit]) => {
|
|
26
|
+
if (!isMetric(metric) || !Number.isSafeInteger(limit) || Number(limit) < 0) {
|
|
27
|
+
throw new Error(`buildSizeBudgets.${type}.${metric} должен быть целым неотрицательным числом байт (raw или gzip)`);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.validateConfig = validateConfig;
|
|
4
|
+
const validate_build_size_budgets_1 = require("./validate-build-size-budgets");
|
|
4
5
|
function validateConfig(config) {
|
|
6
|
+
(0, validate_build_size_budgets_1.validateBuildSizeBudgets)(config.buildSizeBudgets);
|
|
5
7
|
if (config.experimentalReactCompiler !== 'disabled' && config.codeLoader !== 'swc') {
|
|
6
8
|
throw new Error('Использование `experimentalReactCompiler` на данный момент поддерживается только с `codeLoader: "swc"`. \nЛибо выключите `experimentalReactCompiler`, либо измените настройку для `codeLoader`.');
|
|
7
9
|
}
|
|
@@ -7,11 +7,6 @@ function warnAboutDeprecations(config) {
|
|
|
7
7
|
// eslint-disable-next-line no-param-reassign
|
|
8
8
|
config.proxy = convertObjectProxyConfigurationToArray(config.proxy);
|
|
9
9
|
}
|
|
10
|
-
if (config.disableDevWebpackTypecheck !== undefined) {
|
|
11
|
-
console.warn('Настройка `disableDevWebpackTypecheck` устарела, используйте `disableDevRspackTypecheck`. ', 'Поддержка `disableDevWebpackTypecheck` будет скоро удалена.');
|
|
12
|
-
// eslint-disable-next-line no-param-reassign
|
|
13
|
-
config.disableDevRspackTypecheck = config.disableDevWebpackTypecheck;
|
|
14
|
-
}
|
|
15
10
|
}
|
|
16
11
|
function convertObjectProxyConfigurationToArray(proxyConfiguration) {
|
|
17
12
|
const arrayProxy = [];
|
|
@@ -10,15 +10,14 @@ class ClientConfigPlugin {
|
|
|
10
10
|
// eslint-disable-next-line class-methods-use-this
|
|
11
11
|
apply(compiler) {
|
|
12
12
|
const pluginName = ClientConfigPlugin.name;
|
|
13
|
-
const { webpack } = compiler;
|
|
14
13
|
compiler.hooks.thisCompilation.tap(pluginName, (compilation) => {
|
|
15
14
|
// Tapping to the assets processing pipeline on a specific stage.
|
|
16
15
|
compilation.hooks.processAssets.tap({
|
|
17
16
|
name: pluginName,
|
|
18
|
-
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE,
|
|
17
|
+
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE,
|
|
19
18
|
}, () => {
|
|
20
19
|
const content = (0, get_env_config_1.getEnvConfigContent)();
|
|
21
|
-
compilation.emitAsset(`../${constants_1.ENV_CONFIG_FILENAME}`, new webpack.sources.RawSource(content));
|
|
20
|
+
compilation.emitAsset(`../${constants_1.ENV_CONFIG_FILENAME}`, new compiler.webpack.sources.RawSource(content));
|
|
22
21
|
});
|
|
23
22
|
});
|
|
24
23
|
}
|
|
@@ -13,7 +13,7 @@ export declare function getImageMinLoader(): false | {
|
|
|
13
13
|
minimizer: {
|
|
14
14
|
implementation: typeof ImageMinimizerPlugin.imageminMinify;
|
|
15
15
|
options: {
|
|
16
|
-
plugins: (false | (string | {
|
|
16
|
+
plugins: (string | false | (string | {
|
|
17
17
|
quality: number;
|
|
18
18
|
progressive: boolean;
|
|
19
19
|
})[] | (string | {
|
|
@@ -22,15 +22,6 @@ export declare function getImageMinLoader(): false | {
|
|
|
22
22
|
colorTypeReduction: boolean | undefined;
|
|
23
23
|
paletteReduction: boolean | undefined;
|
|
24
24
|
interlaced: boolean | undefined;
|
|
25
|
-
})[] | (string | {
|
|
26
|
-
plugins: {
|
|
27
|
-
name: string;
|
|
28
|
-
params: {
|
|
29
|
-
overrides: {
|
|
30
|
-
removeViewBox: boolean;
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
}[];
|
|
34
25
|
})[] | (string | {
|
|
35
26
|
optimizationLevel: number | undefined;
|
|
36
27
|
interlaced: boolean;
|