arui-scripts 18.7.0 → 19.0.1

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.
Files changed (49) hide show
  1. package/.turbo/turbo-test.log +6 -10
  2. package/CHANGELOG.md +33 -0
  3. package/build/commands/build/build-wrapper.d.ts +3 -3
  4. package/build/commands/build/build-wrapper.js +2 -2
  5. package/build/commands/bundle-analyze/index.js +5 -3
  6. package/build/commands/util/client-assets-sizes.d.ts +1 -1
  7. package/build/commands/util/run-client-dev-server.d.ts +1 -1
  8. package/build/commands/util/run-client-dev-server.js +6 -6
  9. package/build/commands/util/run-server-watch-compiler.d.ts +2 -2
  10. package/build/commands/util/run-server-watch-compiler.js +2 -2
  11. package/build/configs/app-configs/calculate-dependent-config.js +1 -1
  12. package/build/configs/app-configs/get-defaults.js +4 -7
  13. package/build/configs/app-configs/types.d.ts +4 -17
  14. package/build/configs/app-configs/warn-about-deprecations.js +14 -5
  15. package/build/configs/babel-client.js +1 -1
  16. package/build/configs/babel-server.js +1 -1
  17. package/build/configs/client-env-config/client-config-plugin.d.ts +1 -1
  18. package/build/configs/config-extras/minimizers/imagemin/imagemin.d.ts +27 -1
  19. package/build/configs/config-extras/minimizers/imagemin/imagemin.js +55 -41
  20. package/build/configs/dev-server.js +39 -30
  21. package/build/configs/modules.d.ts +3 -3
  22. package/build/configs/modules.js +25 -2
  23. package/build/configs/stats-options.d.ts +2 -2
  24. package/build/configs/util/apply-overrides.d.ts +11 -11
  25. package/build/configs/util/find-loader.d.ts +2 -2
  26. package/build/configs/util/find-plugin.d.ts +9 -6
  27. package/build/configs/webpack.client.d.ts +2 -2
  28. package/build/configs/webpack.client.dev.d.ts +1 -1
  29. package/build/configs/webpack.client.js +24 -56
  30. package/build/configs/webpack.client.prod.d.ts +1 -1
  31. package/build/configs/webpack.server.d.ts +1 -1
  32. package/build/configs/webpack.server.dev.d.ts +1 -1
  33. package/build/configs/webpack.server.js +13 -43
  34. package/build/configs/webpack.server.prod.d.ts +1 -1
  35. package/build/plugins/arui-runtime/arui-runtime-module.d.ts +2 -2
  36. package/build/plugins/arui-runtime/arui-runtime-module.js +5 -8
  37. package/build/plugins/arui-runtime/index.d.ts +2 -2
  38. package/build/plugins/arui-runtime/index.js +2 -5
  39. package/build/plugins/postcss-global-variables/utils/utils.js +20 -6
  40. package/build/plugins/reload-server-plugin.d.ts +10 -0
  41. package/build/plugins/reload-server-plugin.js +44 -0
  42. package/build/plugins/watch-missing-node-modules-plugin.d.ts +5 -5
  43. package/build/plugins/watch-missing-node-modules-plugin.js +3 -1
  44. package/build/tsconfig-local.tsbuildinfo +1 -1
  45. package/docs/commands.md +1 -1
  46. package/docs/settings.md +10 -33
  47. package/package.json +10 -6
  48. package/build/plugins/reload-server-webpack-plugin.d.ts +0 -9
  49. package/build/plugins/reload-server-webpack-plugin.js +0 -44
@@ -5,23 +5,19 @@ ts-jest[versions] (WARN) Version 29.7.0 of jest installed has not been tested wi
5
5
  ts-jest[versions] (WARN) Version 5.6.3 of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=4.3.0 <5.0.0-0). Please do not report issues in ts-jest if you are using unsupported versions.
6
6
  ts-jest[versions] (WARN) Version 5.6.3 of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=4.3.0 <5.0.0-0). Please do not report issues in ts-jest if you are using unsupported versions.
7
7
  ts-jest[versions] (WARN) Version 5.6.3 of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=4.3.0 <5.0.0-0). Please do not report issues in ts-jest if you are using unsupported versions.
8
- PASS src/configs/app-configs/__tests__/update-with-presets.tests.ts (24.292 s)
8
+ PASS src/configs/app-configs/__tests__/update-with-presets.tests.ts (26.869 s)
9
+ PASS src/plugins/postcss-global-variables/utils/__tests__/add-global-variable.tests.ts (26.871 s)
9
10
  PASS src/configs/util/__tests__/get-polyfills.tests.ts
10
- PASS src/plugins/postcss-global-variables/utils/__tests__/add-global-variable.tests.ts (24.414 s)
11
- PASS src/configs/util/__tests__/apply-overrides.tests.ts
12
11
  PASS src/configs/app-configs/__tests__/update-with-env.tests.ts
12
+ PASS src/configs/util/__tests__/apply-overrides.tests.ts
13
13
  PASS src/configs/app-configs/__tests__/update-with-package.tests.ts
14
14
  PASS src/plugins/postcss-global-variables/utils/__tests__/parse-variables.tests.ts
15
15
  PASS src/configs/app-configs/__tests__/validate-settings-keys.tests.ts
16
16
  PASS src/plugins/postcss-global-variables/utils/__tests__/get-media-query-name.tests.ts
17
- Failed to load /home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/tsconfig.json: Missing baseUrl in compilerOptions
18
- Failed to load /home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/tsconfig.json: Missing baseUrl in compilerOptions
19
- Failed to load /home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/tsconfig.json: Missing baseUrl in compilerOptions
20
- Failed to load /home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/tsconfig.json: Missing baseUrl in compilerOptions
21
- PASS src/configs/util/__tests__/find-plugin.tests.ts (26.927 s)
17
+ PASS src/configs/util/__tests__/find-plugin.tests.ts (29.164 s)
22
18
 
23
19
  Test Suites: 10 passed, 10 total
24
- Tests: 27 passed, 27 total
20
+ Tests: 26 passed, 26 total
25
21
  Snapshots: 0 total
26
- Time: 27.554 s
22
+ Time: 30.106 s
27
23
  Ran all test suites.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # [15.3.0](https://github.com/core-ds/arui-scripts/compare/v15.2.0...v15.3.0) (2023-06-30)
2
2
 
3
+ ## 19.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#303](https://github.com/core-ds/arui-scripts/pull/303) [`342c717`](https://github.com/core-ds/arui-scripts/commit/342c7171017056214e0ecc3cd7c866f7cce64e88) Thanks [@Echzio](https://github.com/Echzio)! - исправление парсинга postcss, в котором неправильно парсились @media
8
+
9
+ - [#301](https://github.com/core-ds/arui-scripts/pull/301) [`77bbf31`](https://github.com/core-ds/arui-scripts/commit/77bbf3108257192d056ebf779bc737800b60375c) Thanks [@heymdall-legal](https://github.com/heymdall-legal)! - Исправлена проблема при обработке маленьких svg (меньше, чем [config.dataUrlMaxSize](https://github.com/core-ds/arui-scripts/blob/master/packages/arui-scripts/docs/settings.md#dataurlmaxsize)): теперь они корректно преобразуются в data-url
10
+
11
+ ## 19.0.0
12
+
13
+ ### Major Changes
14
+
15
+ - [#279](https://github.com/core-ds/arui-scripts/pull/279) [`827742a`](https://github.com/core-ds/arui-scripts/commit/827742ade65d80f3b20d000349d443560fc57b35) Thanks [@heymdall-legal](https://github.com/heymdall-legal)! - - Теперь как основной сборочный инструмент используется rspack.
16
+
17
+ Для большинства проектов миграция должна пройти максимально незаметно, rspack сохраняет обратную совместимость с webpack
18
+ в большинстве случаев. Подробнее о несовместимых изменениях можно почитать в документации [rspack](https://rspack.dev/guide/migration/webpack).
19
+ Наибольший прирост в производительности можно получить при использовании `swc` как [codeLoader](https://github.com/core-ds/arui-scripts/blob/master/packages/arui-scripts/docs/settings.md#codeLoader).
20
+
21
+ - Изменен дефолт для настройки `codeLoader`. Теперь по умолчанию используется `swc`. Для возврата к предыдущему поведению используйте `babel`.
22
+ - Изменен дефолт для настройки `jestCodeTransformer`. Теперь по умолчанию используется `swc`.
23
+ - Удалена опция `jestUseTsJest`. Используйте настройку `jestCodeTransformer` со значением `tsc` как замену.
24
+ - Удалена опция `useTscLoader`. Используйте настройку `codeLoader` со значением `tsc` как замену.
25
+ - Изменен формат настройки [`proxy`](https://github.com/core-ds/arui-scripts/blob/master/packages/arui-scripts/docs/settings.md#proxy) - теперь она
26
+ принимает массив объектов, а не объект. arui-scripts попробует преобразовать конфигурацию старого формата в новый, но рекомендуется обновить конфигурацию самостоятельно.
27
+ - Удалена опция `webpack4Compatibility`.
28
+ - Если вы использовали `babel-plugin-istanbul` для сбора code coverage - с настройками по умолчанию это больше не будет работать из-за замены babel на swc.
29
+ Рекомендуется использовать настройку [collectCoverage](https://github.com/core-ds/arui-scripts/blob/master/packages/arui-scripts/docs/settings.md#collectcoverage).
30
+ - Команда [bundle-analyze](https://github.com/core-ds/arui-scripts/blob/master/packages/arui-scripts/docs/commands.md#bundle-analyze) теперь так же запускает [rsdoctor](https://rsdoctor.dev/).
31
+ - Изменен дефолт для `devSourceMaps`, теперь по умолчанию используется `inline-cheap-source-map`.
32
+
33
+ При активном использовании оверрайдов скорее всего вы столкнетесь с различиями в конфигурациях. Информацию о том, как
34
+ мигрировать с webpack на rspack, и о различиях в их конфигурациях можно найти в [документации rspack](https://rspack.dev/guide/migration/webpack).
35
+
3
36
  ## 18.7.0
4
37
 
5
38
  ### Minor Changes
@@ -1,8 +1,8 @@
1
- import webpack from 'webpack';
1
+ import { Stats, MultiStats, Configuration } from '@rspack/core';
2
2
  type BuildResult = {
3
- stats: webpack.Stats | webpack.MultiStats;
3
+ stats: Stats | MultiStats;
4
4
  warnings: string[];
5
5
  previousFileSizes: unknown;
6
6
  };
7
- declare function build(config: webpack.Configuration | webpack.Configuration[], previousFileSizes?: unknown): Promise<BuildResult>;
7
+ declare function build(config: Configuration | Configuration[], previousFileSizes?: unknown): Promise<BuildResult>;
8
8
  export default build;
@@ -6,10 +6,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
6
6
  };
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
8
  const chalk_1 = __importDefault(require("chalk"));
9
- const webpack_1 = __importDefault(require("webpack"));
9
+ const core_1 = require("@rspack/core");
10
10
  const format_webpack_messages_1 = __importDefault(require("../util/format-webpack-messages"));
11
11
  function build(config, previousFileSizes) {
12
- let compiler = (0, webpack_1.default)(config);
12
+ let compiler = (0, core_1.rspack)(config);
13
13
  return new Promise((resolve, reject) => {
14
14
  compiler.run((err, stats) => {
15
15
  if (err) {
@@ -14,7 +14,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  // TODO: remove eslint-disable
16
16
  /* eslint-disable no-param-reassign */
17
- const webpack_1 = __importDefault(require("webpack"));
17
+ const rspack_plugin_1 = require("@rsdoctor/rspack-plugin");
18
+ const core_1 = require("@rspack/core");
18
19
  const webpack_bundle_analyzer_1 = require("webpack-bundle-analyzer");
19
20
  const app_configs_1 = require("../../configs/app-configs");
20
21
  const webpack_client_prod_1 = __importDefault(require("../../configs/webpack.client.prod"));
@@ -29,10 +30,11 @@ const make_tmp_dir_1 = __importDefault(require("../util/make-tmp-dir"));
29
30
  generateStatsFile: true,
30
31
  statsFilename: app_configs_1.configs.statsOutputPath,
31
32
  analyzerPort: 'auto',
32
- }),
33
+ }), // webpack-bundle-analyzer has incorrect types
34
+ new rspack_plugin_1.RsdoctorRspackPlugin({}),
33
35
  ];
34
36
  webpackConfig.output = Object.assign(Object.assign({}, webpackConfig.output), { path: tmpDir });
35
37
  }));
36
38
  yield Promise.all(promises);
37
- (0, webpack_1.default)(clientWebpackConfigs).run(() => { });
39
+ (0, core_1.rspack)(clientWebpackConfigs).run(() => { });
38
40
  }))();
@@ -1,4 +1,4 @@
1
- import { Stats } from 'webpack';
1
+ import { Stats } from '@rspack/core';
2
2
  type AssetSize = {
3
3
  name: string;
4
4
  fullName: string;
@@ -1,2 +1,2 @@
1
- import { Configuration } from 'webpack';
1
+ import { Configuration } from '@rspack/core';
2
2
  export declare function runClientDevServer(configuration: Configuration | Configuration[]): Promise<void>;
@@ -14,17 +14,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.runClientDevServer = runClientDevServer;
16
16
  const WebpackDevServerUtils_1 = require("react-dev-utils/WebpackDevServerUtils");
17
- const webpack_1 = __importDefault(require("webpack"));
18
- const webpack_dev_server_1 = __importDefault(require("webpack-dev-server"));
19
- const dev_server_1 = __importDefault(require("../../configs/dev-server"));
17
+ const core_1 = require("@rspack/core");
18
+ const dev_server_1 = require("@rspack/dev-server");
19
+ const dev_server_2 = __importDefault(require("../../configs/dev-server"));
20
20
  const print_compiler_output_1 = __importDefault(require("../start/print-compiler-output"));
21
21
  function runClientDevServer(configuration) {
22
22
  return __awaiter(this, void 0, void 0, function* () {
23
- const clientCompiler = (0, webpack_1.default)(configuration); // типы вебпака не умеют выбирать между конфигурациями и массивом конфигураций
24
- const clientDevServer = new webpack_dev_server_1.default(dev_server_1.default, clientCompiler);
23
+ const clientCompiler = (0, core_1.rspack)(configuration);
24
+ const clientDevServer = new dev_server_1.RspackDevServer(dev_server_2.default, clientCompiler);
25
25
  clientCompiler.hooks.invalid.tap('client', () => console.log('Compiling client...'));
26
26
  clientCompiler.hooks.done.tap('client', (stats) => (0, print_compiler_output_1.default)('Client', stats));
27
- const DEFAULT_PORT = dev_server_1.default.port;
27
+ const DEFAULT_PORT = dev_server_2.default.port;
28
28
  const HOST = '0.0.0.0';
29
29
  try {
30
30
  const port = yield (0, WebpackDevServerUtils_1.choosePort)(HOST, +(DEFAULT_PORT || 0));
@@ -1,2 +1,2 @@
1
- import webpack from 'webpack';
2
- export declare function runServerWatchCompiler(config: webpack.Configuration): void;
1
+ import { Configuration } from '@rspack/core';
2
+ export declare function runServerWatchCompiler(config: Configuration): void;
@@ -4,11 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.runServerWatchCompiler = runServerWatchCompiler;
7
- const webpack_1 = __importDefault(require("webpack"));
7
+ const core_1 = require("@rspack/core");
8
8
  const app_configs_1 = __importDefault(require("../../configs/app-configs"));
9
9
  const print_compiler_output_1 = __importDefault(require("../start/print-compiler-output"));
10
10
  function runServerWatchCompiler(config) {
11
- const serverCompiler = (0, webpack_1.default)(config);
11
+ const serverCompiler = (0, core_1.rspack)(config);
12
12
  serverCompiler.hooks.compile.tap('server', () => console.log('Compiling server...'));
13
13
  serverCompiler.hooks.invalid.tap('server', () => console.log('Compiling server...'));
14
14
  serverCompiler.hooks.done.tap('server', (stats) => (0, print_compiler_output_1.default)('Server', stats));
@@ -14,7 +14,7 @@ const resolve_1 = require("../util/resolve");
14
14
  * Обновление ключей конфига, зависящих от других. Это нужно делать в самый последний момент
15
15
  */
16
16
  function calculateDependentConfig(config) {
17
- return Object.assign(Object.assign({}, config), { codeLoader: config.useTscLoader ? 'tsc' : config.codeLoader, jestCodeTransformer: config.jestUseTsJest ? 'tsc' : config.jestCodeTransformer, clientPolyfillsEntry: (0, get_polyfills_1.getPolyfills)(config) });
17
+ return Object.assign(Object.assign({}, config), { clientPolyfillsEntry: (0, get_polyfills_1.getPolyfills)(config) });
18
18
  }
19
19
  /**
20
20
  * Обновление контекста в зависимости от ключей конфига
@@ -23,11 +23,11 @@ function getDefaultAppConfig() {
23
23
  clientServerPort: 8080,
24
24
  serverPort: 3000,
25
25
  debug: false,
26
- devSourceMaps: 'eval',
26
+ devSourceMaps: 'inline-cheap-source-map', // так получаются нормальные сорсмапы, с eval - они не работают
27
27
  devServerCors: false,
28
28
  useServerHMR: false,
29
29
  presets: (configFile === null || configFile === void 0 ? void 0 : configFile.presets) || ((_a = appPackage === null || appPackage === void 0 ? void 0 : appPackage.aruiScripts) === null || _a === void 0 ? void 0 : _a.presets) || null,
30
- proxy: appPackage.proxy || null,
30
+ proxy: appPackage.proxy || [],
31
31
  clientOnly: false,
32
32
  // paths
33
33
  buildPath: '.build',
@@ -49,13 +49,10 @@ function getDefaultAppConfig() {
49
49
  archiveName: 'build.tar',
50
50
  // build tuning
51
51
  keepPropTypes: false,
52
- useTscLoader: false,
53
- codeLoader: 'babel',
54
- webpack4Compatibility: false,
52
+ codeLoader: 'swc',
55
53
  installServerSourceMaps: false,
56
54
  disableDevWebpackTypecheck: true,
57
- jestUseTsJest: false,
58
- jestCodeTransformer: 'babel',
55
+ jestCodeTransformer: 'swc',
59
56
  collectCoverage: process.env.NODE_ENV === 'cypress' || process.env.USE_ISTANBUL === 'enabled',
60
57
  // image processing
61
58
  dataUrlMaxSize: 1536,
@@ -1,4 +1,5 @@
1
- import { ProxyConfigArrayItem } from 'webpack-dev-server';
1
+ import { DevTool } from '@rspack/core';
2
+ import { RspackDevServer } from '@rspack/dev-server';
2
3
  /**
3
4
  * Конфигурация arui-scripts, которая может быть переопределена приложением
4
5
  */
@@ -6,13 +7,11 @@ export type AppConfigs = {
6
7
  clientServerPort: number;
7
8
  serverPort: number;
8
9
  debug: boolean;
9
- devSourceMaps: string;
10
+ devSourceMaps: DevTool;
10
11
  devServerCors: boolean;
11
12
  useServerHMR: boolean;
12
13
  presets: string | null;
13
- proxy: null | {
14
- [url: string]: ProxyConfigArrayItem;
15
- };
14
+ proxy: RspackDevServer['options']['proxy'];
16
15
  clientOnly: boolean;
17
16
  buildPath: string;
18
17
  assetsPath: string;
@@ -36,21 +35,9 @@ export type AppConfigs = {
36
35
  removeDevDependenciesDuringDockerBuild: boolean;
37
36
  archiveName: string;
38
37
  keepPropTypes: boolean;
39
- /**
40
- * @deprecated использование ts-loader крайне не рекомендуется - он медленнее и не имеет преимуществ перед babel
41
- */
42
- useTscLoader: boolean;
43
38
  codeLoader: 'babel' | 'tsc' | 'swc';
44
- /**
45
- * @deprecated эта настройка будет удалена в будущих версиях скриптов
46
- */
47
- webpack4Compatibility: boolean;
48
39
  installServerSourceMaps: boolean;
49
40
  disableDevWebpackTypecheck: boolean;
50
- /**
51
- * @deprecated используйте настройку jestCodeTransformer
52
- */
53
- jestUseTsJest: boolean;
54
41
  jestCodeTransformer: 'babel' | 'tsc' | 'swc';
55
42
  collectCoverage: boolean;
56
43
  dataUrlMaxSize?: number;
@@ -2,10 +2,19 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.warnAboutDeprecations = warnAboutDeprecations;
4
4
  function warnAboutDeprecations(config) {
5
- if (config.useTscLoader) {
6
- console.warn('Использование опции `useTscLoader` не рекомендуется и будет удалено в будущих версиях. ', 'Обратитесь к документации https://github.com/core-ds/arui-scripts/blob/master/packages/arui-scripts/docs/settings.md#usetscloader', 'для получения дополнительной информации.');
7
- }
8
- if (config.webpack4Compatibility) {
9
- console.warn('Опция `webpack4Compatibility` будет удалена в будущих версиях arui-scripts.', 'Обратитесь к issue в webpack https://github.com/webpack/webpack/issues/14580 для получения дополнительной информации');
5
+ if (!Array.isArray(config.proxy) && config.proxy) {
6
+ console.warn('Передача config.proxy как объекта больше не поддерживается. ', 'arui-scripts попробует привести конфигурацию к корректному виду, но это не всегда может работать корректно', 'Правильный формат конфигурации можно посмотреть в документации rspack: https://rspack.dev/guide/features/dev-server#proxy');
7
+ // eslint-disable-next-line no-param-reassign
8
+ config.proxy = convertObjectProxyConfigurationToArray(config.proxy);
10
9
  }
11
10
  }
11
+ function convertObjectProxyConfigurationToArray(proxyConfiguration) {
12
+ const arrayProxy = [];
13
+ Object.keys(proxyConfiguration).forEach((context) => {
14
+ const itemConfig = proxyConfiguration[context];
15
+ arrayProxy.push(Object.assign({ context }, (typeof itemConfig === 'string' ? {
16
+ target: itemConfig,
17
+ } : itemConfig)));
18
+ });
19
+ return arrayProxy;
20
+ }
@@ -22,7 +22,7 @@ const babelClientConfig = (0, apply_overrides_1.default)(['babel', 'babelClient'
22
22
  },
23
23
  ],
24
24
  app_configs_1.configs.tsconfig !== null &&
25
- !app_configs_1.configs.useTscLoader &&
25
+ app_configs_1.configs.codeLoader !== 'tsc' &&
26
26
  require.resolve('@babel/preset-typescript'),
27
27
  require.resolve('@babel/preset-react'),
28
28
  ].filter(Boolean),
@@ -12,7 +12,7 @@ const config = (0, apply_overrides_1.default)(['babel', 'babelServer'], {
12
12
  { modules: false, targets: { node: 'current' }, loose: true },
13
13
  ],
14
14
  app_configs_1.default.tsconfig !== null &&
15
- !app_configs_1.default.useTscLoader &&
15
+ app_configs_1.default.codeLoader !== 'tsc' &&
16
16
  require.resolve('@babel/preset-typescript'),
17
17
  require.resolve('@babel/preset-react'),
18
18
  ].filter(Boolean),
@@ -1,4 +1,4 @@
1
- import { Compiler } from 'webpack';
1
+ import { Compiler } from '@rspack/core';
2
2
  export declare class ClientConfigPlugin {
3
3
  protected cachedContent: string | null;
4
4
  apply(compiler: Compiler): void;
@@ -1,2 +1,28 @@
1
1
  import ImageMinimizerPlugin from 'image-minimizer-webpack-plugin';
2
- export declare const getImageMin: () => (false | ImageMinimizerPlugin<unknown, unknown> | undefined)[];
2
+ export declare function getImageMinLoader(): false | {
3
+ test: RegExp;
4
+ type: string;
5
+ use: {
6
+ loader: string;
7
+ options: {
8
+ minimizer: {
9
+ implementation: typeof ImageMinimizerPlugin.imageminMinify;
10
+ options: {
11
+ plugins: (false | (string | {
12
+ quality: number;
13
+ progressive: boolean;
14
+ })[] | (string | {
15
+ optimizationLevel: number | undefined;
16
+ bitDepthReduction: boolean | undefined;
17
+ colorTypeReduction: boolean | undefined;
18
+ paletteReduction: boolean | undefined;
19
+ interlaced: boolean | undefined;
20
+ })[] | (string | {
21
+ optimizationLevel: number | undefined;
22
+ interlaced: boolean;
23
+ })[] | undefined)[];
24
+ };
25
+ };
26
+ };
27
+ }[];
28
+ };
@@ -3,49 +3,63 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getImageMin = void 0;
6
+ exports.getImageMinLoader = getImageMinLoader;
7
7
  const image_minimizer_webpack_plugin_1 = __importDefault(require("image-minimizer-webpack-plugin"));
8
- const app_configs_1 = __importDefault(require("../../../app-configs"));
9
- const getImageMin = () => {
8
+ const app_configs_1 = require("../../../app-configs");
9
+ function getImageMinLoader() {
10
10
  var _a;
11
- const { svg, gif, jpg, png } = (_a = app_configs_1.default.imageMinimizer) !== null && _a !== void 0 ? _a : {};
11
+ const { svg, gif, jpg, png } = (_a = app_configs_1.configs.imageMinimizer) !== null && _a !== void 0 ? _a : {};
12
12
  const doesAnyMinificationEnabled = (svg === null || svg === void 0 ? void 0 : svg.enabled) || (gif === null || gif === void 0 ? void 0 : gif.enabled) || (jpg === null || jpg === void 0 ? void 0 : jpg.enabled) || (png === null || png === void 0 ? void 0 : png.enabled);
13
- return [
14
- doesAnyMinificationEnabled &&
15
- new image_minimizer_webpack_plugin_1.default({
16
- minimizer: {
17
- implementation: image_minimizer_webpack_plugin_1.default.imageminMinify,
18
- options: {
19
- plugins: [
20
- (jpg === null || jpg === void 0 ? void 0 : jpg.enabled) && [
21
- 'mozjpeg',
22
- {
23
- quality: jpg === null || jpg === void 0 ? void 0 : jpg.quality,
24
- progressive: true,
25
- },
26
- ],
27
- (png === null || png === void 0 ? void 0 : png.enabled) && [
28
- 'optipng',
29
- {
30
- optimizationLevel: png === null || png === void 0 ? void 0 : png.optimizationLevel,
31
- bitDepthReduction: png === null || png === void 0 ? void 0 : png.bitDepthReduction,
32
- colorTypeReduction: png === null || png === void 0 ? void 0 : png.colorTypeReduction,
33
- paletteReduction: png === null || png === void 0 ? void 0 : png.paletteReduction,
34
- interlaced: png === null || png === void 0 ? void 0 : png.interlaced,
35
- },
36
- ],
37
- (svg === null || svg === void 0 ? void 0 : svg.enabled) && ['svgo'],
38
- (gif === null || gif === void 0 ? void 0 : gif.enabled) && [
39
- 'gifsicle',
40
- {
41
- optimizationLevel: gif === null || gif === void 0 ? void 0 : gif.optimizationLevel,
42
- interlaced: true,
43
- },
44
- ],
45
- ].filter(Boolean),
13
+ if (!doesAnyMinificationEnabled) {
14
+ return false;
15
+ }
16
+ const loaderExtensions = [
17
+ (svg === null || svg === void 0 ? void 0 : svg.enabled) && 'svg',
18
+ (gif === null || gif === void 0 ? void 0 : gif.enabled) && 'gif',
19
+ (jpg === null || jpg === void 0 ? void 0 : jpg.enabled) && 'jpe?g',
20
+ (png === null || png === void 0 ? void 0 : png.enabled) && 'png',
21
+ ].filter(Boolean);
22
+ return {
23
+ test: new RegExp(`\\.(${loaderExtensions.join('|')})$`),
24
+ type: 'assets',
25
+ use: [
26
+ {
27
+ loader: image_minimizer_webpack_plugin_1.default.loader,
28
+ options: {
29
+ minimizer: {
30
+ implementation: image_minimizer_webpack_plugin_1.default.imageminMinify,
31
+ options: {
32
+ plugins: [
33
+ (jpg === null || jpg === void 0 ? void 0 : jpg.enabled) && [
34
+ 'mozjpeg',
35
+ {
36
+ quality: jpg === null || jpg === void 0 ? void 0 : jpg.quality,
37
+ progressive: true,
38
+ },
39
+ ],
40
+ (png === null || png === void 0 ? void 0 : png.enabled) && [
41
+ 'optipng',
42
+ {
43
+ optimizationLevel: png === null || png === void 0 ? void 0 : png.optimizationLevel,
44
+ bitDepthReduction: png === null || png === void 0 ? void 0 : png.bitDepthReduction,
45
+ colorTypeReduction: png === null || png === void 0 ? void 0 : png.colorTypeReduction,
46
+ paletteReduction: png === null || png === void 0 ? void 0 : png.paletteReduction,
47
+ interlaced: png === null || png === void 0 ? void 0 : png.interlaced,
48
+ },
49
+ ],
50
+ (svg === null || svg === void 0 ? void 0 : svg.enabled) && ['svgo'],
51
+ (gif === null || gif === void 0 ? void 0 : gif.enabled) && [
52
+ 'gifsicle',
53
+ {
54
+ optimizationLevel: gif === null || gif === void 0 ? void 0 : gif.optimizationLevel,
55
+ interlaced: true,
56
+ },
57
+ ],
58
+ ].filter(Boolean),
59
+ },
46
60
  },
47
61
  },
48
- }),
49
- ];
50
- };
51
- exports.getImageMin = getImageMin;
62
+ },
63
+ ],
64
+ };
65
+ }
@@ -7,35 +7,33 @@ const path_1 = __importDefault(require("path"));
7
7
  const apply_overrides_1 = __importDefault(require("./util/apply-overrides"));
8
8
  const app_configs_1 = require("./app-configs");
9
9
  const client_env_config_1 = require("./client-env-config");
10
- const serverProxyConfig = {
11
- '/**': Object.assign({ target: `http://127.0.0.1:${app_configs_1.configs.serverPort}`, bypass: (req) => {
12
- var _a;
13
- const assetsRoot = path_1.default.normalize(`/${app_configs_1.configs.publicPath}`).replace(/\\/g, '/');
14
- if ((_a = req === null || req === void 0 ? void 0 : req.url) === null || _a === void 0 ? void 0 : _a.startsWith(assetsRoot)) {
15
- return req.url;
16
- }
17
- return null;
18
- } }, (app_configs_1.configs.devSourceMaps.includes('eval') || app_configs_1.configs.devServerCors
19
- ? {
20
- onProxyRes: (proxyRes) => {
21
- // Для дев режима, когда мы используем в качестве соурсмапов что-то, основанное на eval - нужно
22
- // разрешить браузеру исполнять наш код, даже когда content-security-policy приложения не позволяет этого делать.
23
- if (app_configs_1.configs.devSourceMaps.includes('eval')) {
24
- const cspHeader = proxyRes.headers['content-security-policy'];
25
- if (typeof cspHeader === 'string' &&
26
- !cspHeader.includes('unsafe-eval')) {
27
- proxyRes.headers['content-security-policy'] = cspHeader.replace(/script-src/, "script-src 'unsafe-eval'");
28
- }
29
- }
30
- // если включен devServerCors, то нужно принудительно менять статус ответа на 200, чтобы
31
- // браузер не отклонял ответы с CORS
32
- if (app_configs_1.configs.devServerCors && proxyRes.method === 'OPTIONS') {
33
- proxyRes.statusCode = 200;
34
- }
35
- },
10
+ const serverProxyConfig = Object.assign({ context: ['/**'], target: `http://127.0.0.1:${app_configs_1.configs.serverPort}`, bypass: (req) => {
11
+ var _a;
12
+ const assetsRoot = path_1.default.normalize(`/${app_configs_1.configs.publicPath}`).replace(/\\/g, '/');
13
+ if ((_a = req === null || req === void 0 ? void 0 : req.url) === null || _a === void 0 ? void 0 : _a.startsWith(assetsRoot)) {
14
+ return req.url;
36
15
  }
37
- : {})),
38
- };
16
+ return null;
17
+ } }, (app_configs_1.configs.devSourceMaps && app_configs_1.configs.devSourceMaps.includes('eval') || app_configs_1.configs.devServerCors
18
+ ? {
19
+ onProxyRes: (proxyRes) => {
20
+ // Для дев режима, когда мы используем в качестве соурсмапов что-то, основанное на eval - нужно
21
+ // разрешить браузеру исполнять наш код, даже когда content-security-policy приложения не позволяет этого делать.
22
+ if (app_configs_1.configs.devSourceMaps && app_configs_1.configs.devSourceMaps.includes('eval')) {
23
+ const cspHeader = proxyRes.headers['content-security-policy'];
24
+ if (typeof cspHeader === 'string' &&
25
+ !cspHeader.includes('unsafe-eval')) {
26
+ proxyRes.headers['content-security-policy'] = cspHeader.replace(/script-src/, "script-src 'unsafe-eval'");
27
+ }
28
+ }
29
+ // если включен devServerCors, то нужно принудительно менять статус ответа на 200, чтобы
30
+ // браузер не отклонял ответы с CORS
31
+ if (app_configs_1.configs.devServerCors && proxyRes.method === 'OPTIONS') {
32
+ proxyRes.statusCode = 200;
33
+ }
34
+ },
35
+ }
36
+ : {}));
39
37
  const devServerConfig = (0, apply_overrides_1.default)('devServer', {
40
38
  port: app_configs_1.configs.clientServerPort,
41
39
  liveReload: false,
@@ -51,8 +49,8 @@ const devServerConfig = (0, apply_overrides_1.default)('devServer', {
51
49
  // создаваемый для client-only режима как раз такой. Так же работает и env-config.json
52
50
  writeToDisk: (filename) => filename.endsWith('.html') || filename.endsWith(client_env_config_1.ENV_CONFIG_FILENAME),
53
51
  },
54
- static: [app_configs_1.configs.serverOutputPath],
55
- proxy: Object.assign(app_configs_1.configs.proxy || {}, app_configs_1.configs.clientOnly ? {} : serverProxyConfig),
52
+ static: [app_configs_1.configs.serverOutputPath, app_configs_1.configs.clientOutputPath],
53
+ proxy: getProxyConfig(),
56
54
  headers: app_configs_1.configs.devServerCors
57
55
  ? {
58
56
  'Access-Control-Allow-Origin': '*',
@@ -61,4 +59,15 @@ const devServerConfig = (0, apply_overrides_1.default)('devServer', {
61
59
  }
62
60
  : {},
63
61
  });
62
+ function getProxyConfig() {
63
+ const proxyConfig = [];
64
+ const userProxyConfig = app_configs_1.configs.proxy;
65
+ if (!app_configs_1.configs.clientOnly) {
66
+ proxyConfig.push(serverProxyConfig);
67
+ }
68
+ if (Array.isArray(userProxyConfig)) {
69
+ proxyConfig.push(...userProxyConfig);
70
+ }
71
+ return proxyConfig;
72
+ }
64
73
  exports.default = devServerConfig;
@@ -1,8 +1,8 @@
1
- import webpack from 'webpack';
1
+ import * as rspack from '@rspack/core';
2
2
  import { CompatModuleConfig } from './app-configs/types';
3
3
  export declare function haveExposedDefaultModules(): Record<string, string> | undefined;
4
4
  export declare const MODULES_ENTRY_NAME = "remoteEntry.js";
5
- export declare function patchMainWebpackConfigForModules(webpackConf: webpack.Configuration): webpack.Configuration;
5
+ export declare function patchMainWebpackConfigForModules(webpackConf: rspack.Configuration): rspack.RspackOptions;
6
6
  export declare function getCssPrefixForModule(module: CompatModuleConfig): string | undefined;
7
7
  export declare function getExposeLoadersFormCompatModules(): {
8
8
  test: string;
@@ -13,4 +13,4 @@ export declare function getExposeLoadersFormCompatModules(): {
13
13
  };
14
14
  }[];
15
15
  }[];
16
- export declare function patchWebpackConfigForCompat(module: CompatModuleConfig, webpackConf: webpack.Configuration): webpack.Configuration;
16
+ export declare function patchWebpackConfigForCompat(module: CompatModuleConfig, webpackConf: rspack.Configuration): rspack.RspackOptions;
@@ -1,4 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
@@ -11,7 +34,7 @@ exports.getExposeLoadersFormCompatModules = getExposeLoadersFormCompatModules;
11
34
  exports.patchWebpackConfigForCompat = patchWebpackConfigForCompat;
12
35
  // TODO: remove eslint-disable
13
36
  /* eslint-disable no-param-reassign */
14
- const webpack_1 = __importDefault(require("webpack"));
37
+ const rspack = __importStar(require("@rspack/core"));
15
38
  const postcss_prefix_selector_1 = require("../plugins/postcss-prefix-selector");
16
39
  const find_loader_1 = require("./util/find-loader");
17
40
  const app_configs_1 = __importDefault(require("./app-configs"));
@@ -33,7 +56,7 @@ function patchMainWebpackConfigForModules(webpackConf) {
33
56
  webpackConf.output.publicPath = haveExposedDefaultModules()
34
57
  ? 'auto' // Для того чтобы модули могли подключаться из разных мест, нам необходимо использовать auto. Для корректной работы в IE надо подключaть https://github.com/amiller-gh/currentScript-polyfill
35
58
  : app_configs_1.default.publicPath;
36
- webpackConf.plugins.push(new webpack_1.default.container.ModuleFederationPlugin({
59
+ webpackConf.plugins.push(new rspack.container.ModuleFederationPlugin({
37
60
  name: app_configs_1.default.modules.name || app_configs_1.default.normalizedName,
38
61
  filename: app_configs_1.default.modules.exposes ? exports.MODULES_ENTRY_NAME : undefined,
39
62
  shared: app_configs_1.default.modules.shared,