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
@@ -1,3 +1,3 @@
1
- import type { WebpackOptionsNormalized } from 'webpack';
2
- declare const statsOptions: WebpackOptionsNormalized['stats'];
1
+ import type { RspackOptionsNormalized } from '@rspack/core';
2
+ declare const statsOptions: RspackOptionsNormalized['stats'];
3
3
  export default statsOptions;
@@ -1,22 +1,22 @@
1
+ import type * as rspack from '@rspack/core';
1
2
  import type { Options as SwcOptions } from '@swc/core';
2
- import type { Configuration as WebpackConfiguration, WebpackOptionsNormalized } from 'webpack';
3
3
  import type { Configuration as WebpackDevServerConfiguration } from 'webpack-dev-server';
4
4
  import { AppContextWithConfigs } from '../app-configs/types';
5
5
  import { createSingleClientWebpackConfig } from '../webpack.client';
6
6
  import { findLoader } from './find-loader';
7
7
  import { findPlugin } from './find-plugin';
8
8
  type Overrides = {
9
- webpack: WebpackConfiguration | WebpackConfiguration[];
10
- webpackClient: WebpackConfiguration | WebpackConfiguration[];
11
- webpackDev: WebpackConfiguration | WebpackConfiguration[];
12
- webpackClientDev: WebpackConfiguration | WebpackConfiguration[];
13
- webpackServer: WebpackConfiguration;
14
- webpackServerDev: WebpackConfiguration;
15
- webpackProd: WebpackConfiguration;
16
- webpackClientProd: WebpackConfiguration | WebpackConfiguration[];
17
- webpackServerProd: WebpackConfiguration;
9
+ webpack: rspack.Configuration | rspack.Configuration[];
10
+ webpackClient: rspack.Configuration | rspack.Configuration[];
11
+ webpackDev: rspack.Configuration | rspack.Configuration[];
12
+ webpackClientDev: rspack.Configuration | rspack.Configuration[];
13
+ webpackServer: rspack.Configuration;
14
+ webpackServerDev: rspack.Configuration;
15
+ webpackProd: rspack.Configuration;
16
+ webpackClientProd: rspack.Configuration | rspack.Configuration[];
17
+ webpackServerProd: rspack.Configuration;
18
18
  devServer: WebpackDevServerConfiguration;
19
- stats: WebpackOptionsNormalized['stats'];
19
+ stats: rspack.RspackOptionsNormalized['stats'];
20
20
  babel: any;
21
21
  babelClient: any;
22
22
  babelServer: any;
@@ -1,2 +1,2 @@
1
- import webpack from 'webpack';
2
- export declare function findLoader(config: webpack.Configuration, testRule: string): webpack.RuleSetRule | undefined;
1
+ import type { Configuration, RuleSetRule } from '@rspack/core';
2
+ export declare function findLoader(config: Configuration, testRule: string): RuleSetRule | undefined;
@@ -1,12 +1,13 @@
1
1
  import { Cluster } from 'cluster';
2
2
  import { ReactRefreshPluginOptions } from '@pmmmwh/react-refresh-webpack-plugin/types/lib/types';
3
+ import { type CssExtractRspackPluginOptions, Configuration, DefinePlugin, NormalModuleReplacementPlugin } from '@rspack/core';
4
+ import { BannerPluginOptions } from '@rspack/core/dist/builtin-plugin/BannerPlugin';
3
5
  import AssetsPlugin from 'assets-webpack-plugin';
4
6
  import CaseSensitivePathsPlugin from 'case-sensitive-paths-webpack-plugin';
5
7
  import CompressionPlugin from 'compression-webpack-plugin';
6
8
  import { ForkTsCheckerWebpackPluginOptions } from 'fork-ts-checker-webpack-plugin/lib/ForkTsCheckerWebpackPluginOptions';
7
9
  import MiniCssExtractPlugin from 'mini-css-extract-plugin';
8
10
  import { RunScriptWebpackPlugin } from 'run-script-webpack-plugin';
9
- import webpack from 'webpack';
10
11
  import { WebpackDeduplicationPlugin } from 'webpack-deduplication-plugin';
11
12
  import { WebpackManifestPlugin } from 'webpack-manifest-plugin';
12
13
  type PluginsListClient = {
@@ -14,7 +15,10 @@ type PluginsListClient = {
14
15
  options: AssetsPlugin.Options;
15
16
  };
16
17
  DefinePlugin: {
17
- definitions: ConstructorParameters<typeof webpack.DefinePlugin>[number];
18
+ definitions: ConstructorParameters<typeof DefinePlugin>[number];
19
+ };
20
+ CssExtractRspackPlugin: {
21
+ options: CssExtractRspackPluginOptions;
18
22
  };
19
23
  MiniCssExtractPlugin: {
20
24
  options: MiniCssExtractPlugin.PluginOptions;
@@ -30,7 +34,6 @@ type PluginsListClient = {
30
34
  } | {
31
35
  checkResource: (resource: string, context: string) => boolean;
32
36
  };
33
- checkIgnore: (resolveData: webpack.ResolveData) => undefined | false;
34
37
  };
35
38
  WebpackDeduplicationPlugin: WebpackDeduplicationPlugin;
36
39
  ReactRefreshPlugin: {
@@ -48,11 +51,11 @@ type PluginsListClient = {
48
51
  CompressionPlugin: {
49
52
  options: ConstructorParameters<typeof CompressionPlugin>[number];
50
53
  };
51
- NormalModuleReplacementPlugin: webpack.NormalModuleReplacementPlugin;
54
+ NormalModuleReplacementPlugin: NormalModuleReplacementPlugin;
52
55
  };
53
56
  type PluginsListServer = {
54
57
  BannerPlugin: {
55
- options: webpack.BannerPlugin['options'];
58
+ options: BannerPluginOptions;
56
59
  };
57
60
  RunScriptWebpackPlugin: {
58
61
  options: ConstructorParameters<typeof RunScriptWebpackPlugin>[number];
@@ -78,5 +81,5 @@ type SelectedPluginsList<Type extends 'client' | 'server'> = Type extends 'clien
78
81
  * @param pluginName имя плагина
79
82
  * @returns плагин или плагины, которые подошли под условие из testRule
80
83
  */
81
- export declare function findPlugin<Type extends 'client' | 'server'>(): <PluginName extends keyof SelectedPluginsList<Type>>(config: webpack.Configuration, pluginName: PluginName) => SelectedPluginsList<Type>[PluginName][];
84
+ export declare function findPlugin<Type extends 'client' | 'server'>(): <PluginName extends keyof SelectedPluginsList<Type>>(config: Configuration, pluginName: PluginName) => SelectedPluginsList<Type>[PluginName][];
82
85
  export {};
@@ -1,4 +1,4 @@
1
- import webpack, { Configuration } from 'webpack';
1
+ import { Configuration } from '@rspack/core';
2
2
  import { Entry } from './util/get-entry';
3
3
  /**
4
4
  * Создает конфигурацию для сборки клиентского кода. Может быть использована для создания дополнительных конфигураций.
@@ -7,4 +7,4 @@ import { Entry } from './util/get-entry';
7
7
  * @param configName Имя конфигурации, если не указано, то используется имя по умолчанию
8
8
  */
9
9
  export declare const createSingleClientWebpackConfig: (mode: "dev" | "prod", entry: Entry, configName?: string) => Configuration;
10
- export declare const createClientWebpackConfig: (mode: "dev" | "prod") => webpack.Configuration | webpack.Configuration[];
10
+ export declare const createClientWebpackConfig: (mode: "dev" | "prod") => import("@rspack/core").RspackOptions | import("@rspack/core").RspackOptions[];
@@ -1,2 +1,2 @@
1
- declare const config: import("webpack").Configuration | import("webpack").Configuration[];
1
+ declare const config: import("@rspack/core").RspackOptions | import("@rspack/core").RspackOptions[];
2
2
  export default config;
@@ -10,25 +10,22 @@ exports.createClientWebpackConfig = exports.createSingleClientWebpackConfig = vo
10
10
  const path_1 = __importDefault(require("path"));
11
11
  const getCSSModuleLocalIdent_1 = __importDefault(require("react-dev-utils/getCSSModuleLocalIdent"));
12
12
  const react_refresh_typescript_1 = __importDefault(require("react-refresh-typescript"));
13
- const react_refresh_webpack_plugin_1 = __importDefault(require("@pmmmwh/react-refresh-webpack-plugin"));
13
+ const core_1 = require("@rspack/core");
14
+ const plugin_react_refresh_1 = __importDefault(require("@rspack/plugin-react-refresh"));
14
15
  const assets_webpack_plugin_1 = __importDefault(require("assets-webpack-plugin"));
15
16
  const case_sensitive_paths_webpack_plugin_1 = __importDefault(require("case-sensitive-paths-webpack-plugin"));
16
17
  const compression_webpack_plugin_1 = __importDefault(require("compression-webpack-plugin"));
17
18
  const fork_ts_checker_webpack_plugin_1 = __importDefault(require("fork-ts-checker-webpack-plugin"));
18
19
  const html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
19
- const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
20
20
  const mini_svg_data_uri_1 = __importDefault(require("mini-svg-data-uri"));
21
+ const rspack_manifest_plugin_1 = require("rspack-manifest-plugin");
21
22
  const terser_webpack_plugin_1 = __importDefault(require("terser-webpack-plugin"));
22
- const tsconfig_paths_webpack_plugin_1 = __importDefault(require("tsconfig-paths-webpack-plugin"));
23
- const webpack_1 = __importDefault(require("webpack"));
24
23
  const webpack_deduplication_plugin_1 = require("webpack-deduplication-plugin");
25
- const webpack_manifest_plugin_1 = require("webpack-manifest-plugin");
26
24
  const arui_runtime_1 = require("../plugins/arui-runtime");
27
25
  const html_template_1 = require("../templates/html.template");
28
26
  const minimizers_1 = require("./config-extras/minimizers");
29
27
  const check_node_version_1 = __importDefault(require("./util/check-node-version"));
30
28
  const get_entry_1 = __importDefault(require("./util/get-entry"));
31
- const get_webpack_cache_dependencies_1 = require("./util/get-webpack-cache-dependencies");
32
29
  const app_configs_1 = require("./app-configs");
33
30
  const babel_client_1 = __importDefault(require("./babel-client"));
34
31
  const babel_dependencies_1 = require("./babel-dependencies");
@@ -37,7 +34,6 @@ const modules_1 = require("./modules");
37
34
  const postcss_1 = __importDefault(require("./postcss"));
38
35
  const process_assets_plugin_output_1 = require("./process-assets-plugin-output");
39
36
  const swc_1 = require("./swc");
40
- const PnpWebpackPlugin = require('pnp-webpack-plugin');
41
37
  const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
42
38
  const noopPath = require.resolve('./util/noop');
43
39
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -65,7 +61,6 @@ function getMinimizeConfig(mode) {
65
61
  return {
66
62
  minimize: true,
67
63
  minimizer: [
68
- ...(0, minimizers_1.getImageMin)(),
69
64
  new terser_webpack_plugin_1.default({
70
65
  terserOptions: {
71
66
  parse: {
@@ -138,7 +133,9 @@ function getMinimizeConfig(mode) {
138
133
  // eslint-disable-next-line complexity
139
134
  const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.assign(Object.assign({}, (configName ? { name: configName } : {})), { target: 'web', mode: mode === 'dev' ? 'development' : 'production', devtool: mode === 'dev' ? app_configs_1.configs.devSourceMaps : 'source-map', entry: (0, get_entry_1.default)(entry, getSingleEntry, mode),
140
135
  // in production mode we need to fail on first error
141
- bail: mode === 'prod', context: app_configs_1.configs.cwd, output: {
136
+ bail: mode === 'prod', context: app_configs_1.configs.cwd, experiments: {
137
+ css: false,
138
+ }, output: {
142
139
  assetModuleFilename: 'static/media/[name].[hash:8][ext]',
143
140
  // Add /* filename */ comments to generated require()s in the output.
144
141
  pathinfo: mode === 'dev',
@@ -157,20 +154,20 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
157
154
  commons: {
158
155
  chunks: 'initial',
159
156
  minChunks: 2,
160
- maxInitialRequests: 5, // The default limit is too small to showcase the effect
161
157
  minSize: 0, // This is example is too small to create commons chunks
162
158
  },
163
159
  vendor: {
164
160
  test: /node_modules/,
165
161
  chunks: 'initial',
166
- name: (_, chunks, cacheGroupKey) => {
162
+ // Почему то rspack предоставляет некорректные типы для этой функции.
163
+ name: ((_, chunks, cacheGroupKey) => {
167
164
  if (!configName) {
168
165
  return 'vendor';
169
166
  }
170
167
  // Нам нужно сделать так, чтобы у разных конфигураций были разные имена чанков
171
168
  const allChunksNames = chunks.map((item) => item.name).join('~');
172
169
  return `${cacheGroupKey}-${allChunksNames}`;
173
- },
170
+ }), // eslint-disable-line @typescript-eslint/no-explicit-any
174
171
  priority: 10,
175
172
  enforce: true,
176
173
  },
@@ -191,33 +188,8 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
191
188
  // `web` extension prefixes have been added for better support
192
189
  // for React Native Web.
193
190
  extensions: ['.web.js', '.mjs', '.cjs', '.js', '.json', '.web.jsx', '.jsx', '.ts', '.tsx'],
194
- plugins: [
195
- app_configs_1.configs.tsconfig &&
196
- new tsconfig_paths_webpack_plugin_1.default({
197
- configFile: app_configs_1.configs.tsconfig,
198
- extensions: [
199
- '.web.js',
200
- '.mjs',
201
- '.js',
202
- '.json',
203
- '.web.jsx',
204
- '.jsx',
205
- '.ts',
206
- '.tsx',
207
- ],
208
- }),
209
- ].filter(Boolean),
210
- }, resolveLoader: {
211
- plugins: [PnpWebpackPlugin.moduleLoader(module)],
212
- }, cache: mode === 'dev'
213
- ? {
214
- type: 'filesystem',
215
- buildDependencies: Object.assign({ config: [__filename] }, (0, get_webpack_cache_dependencies_1.getWebpackCacheDependencies)()),
216
- }
217
- : false, module: {
218
- // typescript interface will be removed from modules, and we will get an error on correct code
219
- // see https://github.com/webpack/webpack/issues/7378
220
- strictExportPresence: !app_configs_1.configs.tsconfig,
191
+ tsConfig: app_configs_1.configs.tsconfig ? { configFile: app_configs_1.configs.tsconfig } : undefined,
192
+ }, resolveLoader: {}, cache: mode === 'dev', module: {
221
193
  rules: [
222
194
  {
223
195
  // "oneOf" will traverse all following loaders until one will
@@ -236,7 +208,7 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
236
208
  exclude: /\.module\.css$/,
237
209
  use: [
238
210
  {
239
- loader: mini_css_extract_plugin_1.default.loader,
211
+ loader: core_1.CssExtractRspackPlugin.loader,
240
212
  options: { publicPath: './' },
241
213
  },
242
214
  {
@@ -261,7 +233,7 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
261
233
  test: /\.module\.css$/,
262
234
  use: [
263
235
  {
264
- loader: mini_css_extract_plugin_1.default.loader,
236
+ loader: core_1.CssExtractRspackPlugin.loader,
265
237
  options: { publicPath: './' },
266
238
  },
267
239
  {
@@ -288,7 +260,7 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
288
260
  test: /\.svg/,
289
261
  type: 'asset',
290
262
  generator: {
291
- dataUrl: (content) => (0, mini_svg_data_uri_1.default)(content.toString()),
263
+ dataUrl: (file) => (0, mini_svg_data_uri_1.default)(file.content.toString()),
292
264
  },
293
265
  parser: {
294
266
  dataUrlCondition: {
@@ -296,6 +268,7 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
296
268
  },
297
269
  },
298
270
  },
271
+ mode === 'prod' && (0, minimizers_1.getImageMinLoader)(),
299
272
  {
300
273
  exclude: [/\.(js|jsx|mjs|cjs|ts|tsx)$/, /\.(html|ejs)$/, /\.json$/],
301
274
  type: 'asset',
@@ -313,12 +286,12 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
313
286
  }, plugins: [
314
287
  assetsPlugin,
315
288
  clientAssetsPlugin,
316
- new webpack_1.default.DefinePlugin(Object.assign({
289
+ new core_1.DefinePlugin(Object.assign({
317
290
  // Tell Webpack to provide empty mocks for process.env.
318
291
  'process.env': '{}' }, (mode === 'dev'
319
292
  ? { 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV) }
320
293
  : {}))),
321
- new mini_css_extract_plugin_1.default((() => {
294
+ new core_1.CssExtractRspackPlugin((() => {
322
295
  const prefix = `${configName ? `${configName}-` : ''}`;
323
296
  return {
324
297
  ignoreOrder: true,
@@ -338,7 +311,7 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
338
311
  // moment.js очень большая библиотека, которая включает в себя массу локализаций, которые мы не используем.
339
312
  // Поэтому мы их просто игнорируем, чтобы не включать в сборку.
340
313
  // https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
341
- new webpack_1.default.IgnorePlugin({
314
+ new core_1.IgnorePlugin({
342
315
  resourceRegExp: /^\.\/locale$/,
343
316
  contextRegExp: /moment$/,
344
317
  }),
@@ -353,10 +326,7 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
353
326
  rootPath: app_configs_1.configs.cwd,
354
327
  }),
355
328
  // dev plugins:
356
- mode === 'dev' &&
357
- new react_refresh_webpack_plugin_1.default({
358
- overlay: false,
359
- }),
329
+ mode === 'dev' && new plugin_react_refresh_1.default(),
360
330
  // Watcher doesn't work well if you mistype casing in a path so we use
361
331
  // a plugin that prints an error when you attempt to do this.
362
332
  // See https://github.com/facebookincubator/create-react-app/issues/240
@@ -371,7 +341,7 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
371
341
  }),
372
342
  mode === 'dev' && app_configs_1.configs.clientOnly && new client_env_config_1.ClientConfigPlugin(),
373
343
  // production plugins:
374
- mode === 'prod' && new webpack_manifest_plugin_1.WebpackManifestPlugin(),
344
+ mode === 'prod' && new rspack_manifest_plugin_1.RspackManifestPlugin({}),
375
345
  mode === 'prod' &&
376
346
  new compression_webpack_plugin_1.default({
377
347
  filename: '[file].gz',
@@ -396,13 +366,11 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
396
366
  // This should works fine, since proptypes usage should be eliminated in production mode
397
367
  mode === 'prod' &&
398
368
  !app_configs_1.configs.keepPropTypes &&
399
- new webpack_1.default.NormalModuleReplacementPlugin(/^react-style-proptype$/, noopPath),
369
+ new core_1.NormalModuleReplacementPlugin(/^react-style-proptype$/, noopPath),
400
370
  mode === 'prod' &&
401
371
  !app_configs_1.configs.keepPropTypes &&
402
- new webpack_1.default.NormalModuleReplacementPlugin(/^thrift-services\/proptypes/, noopPath),
403
- ].filter(Boolean), experiments: {
404
- backCompat: app_configs_1.configs.webpack4Compatibility,
405
- },
372
+ new core_1.NormalModuleReplacementPlugin(/^thrift-services\/proptypes/, noopPath),
373
+ ].filter(Boolean),
406
374
  // Без этого комиляция трирегилась на изменение в node_modules и приводила к утечке памяти
407
375
  watchOptions: {
408
376
  ignored: new RegExp(app_configs_1.configs.watchIgnorePath.join('|')),
@@ -437,7 +405,7 @@ function getCodeLoader(mode) {
437
405
  return {
438
406
  test: /\.(js|jsx|mjs|ts|tsx|cjs)$/,
439
407
  include: app_configs_1.configs.appSrc,
440
- loader: require.resolve('swc-loader'),
408
+ loader: 'builtin:swc-loader',
441
409
  options: Object.assign(Object.assign({ cacheDirectory: mode === 'dev', cacheCompression: false }, swc_1.swcClientConfig), { jsc: Object.assign(Object.assign({}, swc_1.swcClientConfig.jsc), { transform: Object.assign(Object.assign({}, (_a = swc_1.swcClientConfig.jsc) === null || _a === void 0 ? void 0 : _a.transform), { react: Object.assign(Object.assign({}, (_c = (_b = swc_1.swcClientConfig.jsc) === null || _b === void 0 ? void 0 : _b.transform) === null || _c === void 0 ? void 0 : _c.react), { refresh: mode === 'dev' }) }) }) }),
442
410
  };
443
411
  }
@@ -1,2 +1,2 @@
1
- declare const config: import("webpack").Configuration | import("webpack").Configuration[];
1
+ declare const config: import("@rspack/core").RspackOptions | import("@rspack/core").RspackOptions[];
2
2
  export default config;
@@ -1,2 +1,2 @@
1
- import { Configuration } from 'webpack';
1
+ import { Configuration } from '@rspack/core';
2
2
  export declare const createServerConfig: (mode: "dev" | "prod") => Configuration;
@@ -1,2 +1,2 @@
1
- declare const config: import("webpack").Configuration;
1
+ declare const config: import("@rspack/core").RspackOptions;
2
2
  export default config;
@@ -9,21 +9,19 @@ exports.createServerConfig = void 0;
9
9
  const fs_1 = __importDefault(require("fs"));
10
10
  const path_1 = __importDefault(require("path"));
11
11
  const getCSSModuleLocalIdent_1 = __importDefault(require("react-dev-utils/getCSSModuleLocalIdent"));
12
+ const core_1 = require("@rspack/core");
12
13
  const case_sensitive_paths_webpack_plugin_1 = __importDefault(require("case-sensitive-paths-webpack-plugin"));
13
14
  const run_script_webpack_plugin_1 = require("run-script-webpack-plugin");
14
- const tsconfig_paths_webpack_plugin_1 = __importDefault(require("tsconfig-paths-webpack-plugin"));
15
- const webpack_1 = __importDefault(require("webpack"));
16
15
  const webpack_node_externals_1 = __importDefault(require("webpack-node-externals"));
16
+ const reload_server_plugin_1 = require("../plugins/reload-server-plugin");
17
+ const watch_missing_node_modules_plugin_1 = require("../plugins/watch-missing-node-modules-plugin");
17
18
  const get_entry_1 = __importDefault(require("./util/get-entry"));
18
- const get_webpack_cache_dependencies_1 = require("./util/get-webpack-cache-dependencies");
19
19
  const app_configs_1 = __importDefault(require("./app-configs"));
20
20
  const babel_dependencies_1 = require("./babel-dependencies");
21
21
  const babel_server_1 = __importDefault(require("./babel-server"));
22
22
  const postcss_1 = __importDefault(require("./postcss"));
23
23
  const server_externals_exemptions_1 = require("./server-externals-exemptions");
24
24
  const swc_1 = require("./swc");
25
- const ReloadServerPlugin = require('../plugins/reload-server-webpack-plugin');
26
- const WatchMissingNodeModulesPlugin = require('../plugins/watch-missing-node-modules-plugin');
27
25
  const assetsIgnoreBanner = fs_1.default.readFileSync(require.resolve('./util/node-assets-ignore'), 'utf8');
28
26
  const sourceMapSupportBanner = fs_1.default.readFileSync(require.resolve('./util/install-sourcemap-support'), 'utf8');
29
27
  // style files regexes
@@ -31,7 +29,7 @@ const cssRegex = /\.css$/;
31
29
  const cssModuleRegex = /\.module\.css$/;
32
30
  function getSingleEntry(entryPoint, mode) {
33
31
  const prefix = mode === 'dev' && app_configs_1.default.useServerHMR
34
- ? [`${require.resolve('webpack/hot/poll')}?1000`]
32
+ ? [`${require.resolve('@rspack/core/hot/poll')}?1000`]
35
33
  : [];
36
34
  return [...prefix, ...entryPoint];
37
35
  }
@@ -59,13 +57,7 @@ const createServerConfig = (mode) => ({
59
57
  // Point sourcemap entries to original disk location (format as URL on Windows)
60
58
  devtoolModuleFilenameTemplate: (info) => path_1.default.relative(app_configs_1.default.appSrc, info.absoluteResourcePath).replace(/\\/g, '/'),
61
59
  },
62
- cache: mode === 'dev'
63
- ? {
64
- type: 'filesystem',
65
- name: 'server',
66
- buildDependencies: Object.assign({ config: [__filename] }, (0, get_webpack_cache_dependencies_1.getWebpackCacheDependencies)()),
67
- }
68
- : false,
60
+ cache: mode === 'dev',
69
61
  externalsPresets: { node: true },
70
62
  externals: [
71
63
  (0, webpack_node_externals_1.default)({
@@ -92,27 +84,9 @@ const createServerConfig = (mode) => ({
92
84
  // `web` extension prefixes have been added for better support
93
85
  // for React Native Web.
94
86
  extensions: ['.web.js', '.mjs', '.js', '.json', '.web.jsx', '.jsx', '.ts', '.tsx'],
95
- plugins: [
96
- app_configs_1.default.tsconfig &&
97
- new tsconfig_paths_webpack_plugin_1.default({
98
- configFile: app_configs_1.default.tsconfig,
99
- extensions: [
100
- '.web.js',
101
- '.mjs',
102
- '.js',
103
- '.json',
104
- '.web.jsx',
105
- '.jsx',
106
- '.ts',
107
- '.tsx',
108
- ],
109
- }),
110
- ].filter(Boolean),
87
+ tsConfig: app_configs_1.default.tsconfig ? { configFile: app_configs_1.default.tsconfig } : undefined,
111
88
  },
112
89
  module: {
113
- // typescript interface will be removed from modules, and we will get an error on correct code
114
- // see https://github.com/webpack/webpack/issues/7378
115
- strictExportPresence: !app_configs_1.default.tsconfig,
116
90
  rules: [
117
91
  {
118
92
  oneOf: [
@@ -163,13 +137,13 @@ const createServerConfig = (mode) => ({
163
137
  ],
164
138
  },
165
139
  plugins: [
166
- new webpack_1.default.BannerPlugin({
140
+ new core_1.BannerPlugin({
167
141
  banner: assetsIgnoreBanner,
168
142
  raw: true,
169
143
  entryOnly: false,
170
144
  }),
171
145
  app_configs_1.default.installServerSourceMaps &&
172
- new webpack_1.default.BannerPlugin({
146
+ new core_1.BannerPlugin({
173
147
  banner: sourceMapSupportBanner,
174
148
  raw: true,
175
149
  entryOnly: false,
@@ -180,10 +154,9 @@ const createServerConfig = (mode) => ({
180
154
  ? new run_script_webpack_plugin_1.RunScriptWebpackPlugin({
181
155
  name: app_configs_1.default.serverOutput,
182
156
  })
183
- : new ReloadServerPlugin({
157
+ : new reload_server_plugin_1.ReloadServerPlugin({
184
158
  script: path_1.default.join(app_configs_1.default.serverOutputPath, app_configs_1.default.serverOutput),
185
159
  })),
186
- mode === 'dev' && new webpack_1.default.NoEmitOnErrorsPlugin(),
187
160
  // Watcher doesn't work well if you mistype casing in a path so we use
188
161
  // a plugin that prints an error when you attempt to do this.
189
162
  // See https://github.com/facebookincubator/create-react-app/issues/240
@@ -192,12 +165,9 @@ const createServerConfig = (mode) => ({
192
165
  // to restart the development server for Webpack to discover it. This plugin
193
166
  // makes the discovery automatic so you don't have to restart.
194
167
  // See https://github.com/facebookincubator/create-react-app/issues/186
195
- mode === 'dev' && new WatchMissingNodeModulesPlugin(app_configs_1.default.appNodeModules),
196
- mode === 'dev' && app_configs_1.default.useServerHMR && new webpack_1.default.HotModuleReplacementPlugin(),
168
+ mode === 'dev' && new watch_missing_node_modules_plugin_1.WatchMissingNodeModulesPlugin(app_configs_1.default.appNodeModules),
169
+ mode === 'dev' && app_configs_1.default.useServerHMR && new core_1.HotModuleReplacementPlugin(),
197
170
  ].filter(Boolean),
198
- experiments: {
199
- backCompat: app_configs_1.default.webpack4Compatibility,
200
- },
201
171
  // Без этого комиляция трирегилась на изменение в node_modules и приводила к утечке памяти
202
172
  watchOptions: {
203
173
  ignored: new RegExp(app_configs_1.default.watchIgnorePath.join('|')),
@@ -214,7 +184,7 @@ function getCodeLoader(mode) {
214
184
  return {
215
185
  test: /\.(js|jsx|mjs|ts|tsx|cjs)$/,
216
186
  include: app_configs_1.default.appSrc,
217
- loader: require.resolve('swc-loader'),
187
+ loader: 'builtin:swc-loader',
218
188
  options: swc_1.swcServerConfig,
219
189
  };
220
190
  }
@@ -267,7 +237,7 @@ function getExternalCodeLoader(mode) {
267
237
  },
268
238
  };
269
239
  if (app_configs_1.default.codeLoader === 'swc') {
270
- return Object.assign(Object.assign({}, baseLoaderConfig), { loader: require.resolve('swc-loader') });
240
+ return Object.assign(Object.assign({}, baseLoaderConfig), { loader: 'builtin:swc-loader' });
271
241
  }
272
242
  return Object.assign(Object.assign({}, baseLoaderConfig), { loader: require.resolve('babel-loader'), options: Object.assign(Object.assign({}, babel_dependencies_1.babelDependencies), { babelrc: false, configFile: false, compact: false, cacheDirectory: mode === 'dev', cacheCompression: false }) });
273
243
  }
@@ -1,2 +1,2 @@
1
- declare const config: import("webpack").Configuration;
1
+ declare const config: import("@rspack/core").RspackOptions;
2
2
  export default config;
@@ -1,7 +1,7 @@
1
- import webpack from 'webpack';
1
+ import { RuntimeModule as RsPackRuntimeModule } from '@rspack/core';
2
2
  export declare const ARUI_RUNTIME_VARIABLE_NAME = "$ARUI";
3
3
  export declare const FULL_ARUI_RUNTIME_PATH: string;
4
- export declare class RuntimeModule extends webpack.RuntimeModule {
4
+ export declare class RuntimeModule extends RsPackRuntimeModule {
5
5
  constructor();
6
6
  generate(): string;
7
7
  }
@@ -1,19 +1,16 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.RuntimeModule = exports.FULL_ARUI_RUNTIME_PATH = exports.ARUI_RUNTIME_VARIABLE_NAME = void 0;
7
- const webpack_1 = __importDefault(require("webpack"));
4
+ const core_1 = require("@rspack/core");
8
5
  exports.ARUI_RUNTIME_VARIABLE_NAME = '$ARUI';
9
- exports.FULL_ARUI_RUNTIME_PATH = `${webpack_1.default.RuntimeGlobals.require}.${exports.ARUI_RUNTIME_VARIABLE_NAME}`;
10
- class RuntimeModule extends webpack_1.default.RuntimeModule {
6
+ exports.FULL_ARUI_RUNTIME_PATH = `${core_1.RuntimeGlobals.require}.${exports.ARUI_RUNTIME_VARIABLE_NAME}`;
7
+ class RuntimeModule extends core_1.RuntimeModule {
11
8
  constructor() {
12
- super('AruiRuntimeModule', webpack_1.default.RuntimeModule.STAGE_BASIC);
9
+ super('AruiRuntimeModule', core_1.RuntimeModule.STAGE_BASIC);
13
10
  }
14
11
  // eslint-disable-next-line class-methods-use-this
15
12
  generate() {
16
- return webpack_1.default.Template.asString([
13
+ return core_1.Template.asString([
17
14
  "if (typeof __webpack_modules__ !== 'undefined' && typeof document !== 'undefined') {", // По какой-то причине вебпак пытается выполнить этот код не только в браузере, но и при сборке.
18
15
  `${exports.FULL_ARUI_RUNTIME_PATH} = { scriptSource: document.currentScript };`,
19
16
  '}',
@@ -1,6 +1,6 @@
1
- import webpack from 'webpack';
1
+ import { Compiler } from '@rspack/core';
2
2
  export declare class AruiRuntimePlugin {
3
- apply(compiler: webpack.Compiler): void;
3
+ apply(compiler: Compiler): void;
4
4
  }
5
5
  /**
6
6
  * Метод для вставки runtime чанков css в документ. Нужен для того, чтобы модули могли использовать shadow-dom.
@@ -1,17 +1,14 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.AruiRuntimePlugin = void 0;
7
4
  exports.getInsertCssRuntimeMethod = getInsertCssRuntimeMethod;
8
- const webpack_1 = __importDefault(require("webpack"));
5
+ const core_1 = require("@rspack/core");
9
6
  const arui_runtime_module_1 = require("./arui-runtime-module");
10
7
  class AruiRuntimePlugin {
11
8
  apply(compiler) {
12
9
  compiler.hooks.compilation.tap(this.constructor.name, (compilation) => {
13
10
  compilation.hooks.runtimeRequirementInTree
14
- .for(webpack_1.default.RuntimeGlobals.require)
11
+ .for(core_1.RuntimeGlobals.require)
15
12
  .tap(this.constructor.name, (chunk) => {
16
13
  compilation.addRuntimeModule(chunk, new arui_runtime_module_1.RuntimeModule());
17
14
  return true;
@@ -9,6 +9,8 @@ exports.addGlobalVariable = addGlobalVariable;
9
9
  const fs_1 = __importDefault(require("fs"));
10
10
  const path_1 = __importDefault(require("path"));
11
11
  const postcss_1 = require("postcss");
12
+ // eslint-disable-next-line import/no-extraneous-dependencies
13
+ const postcss_media_query_parser_1 = __importDefault(require("postcss-media-query-parser"));
12
14
  const getMediaQueryName = (rule) => rule.params.split(' ')[0];
13
15
  exports.getMediaQueryName = getMediaQueryName;
14
16
  function parseImport(root, postcssHelpers, filePath) {
@@ -64,13 +66,25 @@ const insertParsedCss = (root, parsedVariables, parsedCustomMedia) => {
64
66
  addGlobalVariable(decl.value, rootRule, parsedVariables);
65
67
  });
66
68
  root.walkAtRules('media', (rule) => {
67
- const mediaFullName = (0, exports.getMediaQueryName)(rule);
68
- if (mediaFullName.startsWith('(--')) {
69
- const mediaName = mediaFullName.slice(1, -1);
70
- if (parsedCustomMedia[mediaName]) {
71
- root.append(parsedCustomMedia[mediaName]);
69
+ var _a;
70
+ // парсим параметры
71
+ const mediaParsed = (0, postcss_media_query_parser_1.default)(rule.params);
72
+ // регулярка для (--desktop), (--mobile), (--desktop-m) и тд
73
+ const parseRule = /--\w+-?\w+/gi;
74
+ (_a = mediaParsed.nodes) === null || _a === void 0 ? void 0 : _a.forEach(({ value }) => {
75
+ // value приходит в виде (--desktop); not screen and (--mobile) и тд
76
+ if (parseRule.test(value)) {
77
+ // берем все вхождения --desktop, --mobile
78
+ const mediaName = value.match(parseRule);
79
+ // итерируемся по [--desktop, --mobile]
80
+ mediaName === null || mediaName === void 0 ? void 0 : mediaName.forEach((rule) => {
81
+ // подставляем значения если у нас есть под это custom-media
82
+ if (parsedCustomMedia[rule]) {
83
+ root.append(parsedCustomMedia[rule]);
84
+ }
85
+ });
72
86
  }
73
- }
87
+ });
74
88
  });
75
89
  return rootRule;
76
90
  };
@@ -0,0 +1,10 @@
1
+ import cluster from 'cluster';
2
+ import { type Compiler } from 'webpack';
3
+ export declare class ReloadServerPlugin {
4
+ workers: cluster.Worker[];
5
+ done: null | (() => void);
6
+ constructor({ script }?: {
7
+ script: string;
8
+ });
9
+ apply(compiler: Compiler): void;
10
+ }