@gravity-ui/app-builder 0.12.0 → 0.12.1-beta.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.
@@ -1,3 +1,3 @@
1
- import WebpackDevServer from 'webpack-dev-server';
1
+ import { RspackDevServer } from '@rspack/dev-server';
2
2
  import type { NormalizedServiceConfig } from '../../common/models';
3
- export declare function watchClientCompilation(config: NormalizedServiceConfig, onCompilationEnd: () => void): Promise<WebpackDevServer>;
3
+ export declare function watchClientCompilation(config: NormalizedServiceConfig, onCompilationEnd: () => void): Promise<RspackDevServer>;
@@ -29,15 +29,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.watchClientCompilation = watchClientCompilation;
30
30
  const path = __importStar(require("node:path"));
31
31
  const fs = __importStar(require("node:fs"));
32
- const webpack_1 = __importDefault(require("webpack"));
33
- const webpack_dev_server_1 = __importDefault(require("webpack-dev-server"));
34
- const webpack_manifest_plugin_1 = require("webpack-manifest-plugin");
32
+ const core_1 = require("@rspack/core");
33
+ const dev_server_1 = require("@rspack/dev-server");
34
+ const rspack_manifest_plugin_1 = require("rspack-manifest-plugin");
35
35
  const paths_1 = __importDefault(require("../../common/paths"));
36
36
  const logger_1 = require("../../common/logger");
37
37
  const config_1 = require("../../common/webpack/config");
38
38
  async function watchClientCompilation(config, onCompilationEnd) {
39
39
  const clientCompilation = await buildWebpackServer(config);
40
- const { afterEmit } = (0, webpack_manifest_plugin_1.getCompilerHooks)(clientCompilation.compiler);
40
+ const { afterEmit } = (0, rspack_manifest_plugin_1.getCompilerHooks)(clientCompilation.compiler);
41
41
  afterEmit.tap('app-builder: afterEmit', onCompilationEnd);
42
42
  return clientCompilation;
43
43
  }
@@ -111,8 +111,8 @@ async function buildWebpackServer(config) {
111
111
  });
112
112
  }
113
113
  options.proxy = proxy;
114
- const compiler = (0, webpack_1.default)(webpackConfig);
115
- const server = new webpack_dev_server_1.default(options, compiler);
114
+ const compiler = (0, core_1.rspack)(webpackConfig);
115
+ const server = new dev_server_1.RspackDevServer(options, compiler);
116
116
  try {
117
117
  await server.start();
118
118
  }
@@ -2,7 +2,7 @@ import type { EditorLanguage } from 'monaco-editor-webpack-plugin/out/languages'
2
2
  import type { EditorFeature } from 'monaco-editor-webpack-plugin/out/features';
3
3
  import type { IFeatureDefinition } from 'monaco-editor-webpack-plugin/out/types';
4
4
  import type { Options as MomentTzOptions } from 'moment-timezone-data-webpack-plugin';
5
- import type { Configuration, DefinePlugin, FileCacheOptions, MemoryCacheOptions, ResolveOptions } from 'webpack';
5
+ import type { Configuration, DefinePluginOptions, ResolveOptions } from '@rspack/core';
6
6
  import type * as Babel from '@babel/core';
7
7
  import type { ServerConfiguration } from 'webpack-dev-server';
8
8
  import type { Options as CircularDependenciesOptions } from 'circular-dependency-plugin';
@@ -13,7 +13,7 @@ import type { SentryWebpackPluginOptions } from '@sentry/webpack-plugin';
13
13
  import type { WebpackMode } from '../webpack/config';
14
14
  import type { UploadOptions } from '../s3-upload/upload';
15
15
  import type { TerserOptions } from 'terser-webpack-plugin';
16
- import type { ReactRefreshPluginOptions } from '@pmmmwh/react-refresh-webpack-plugin/types/lib/types';
16
+ import type { PluginOptions as ReactRefreshPluginOptions } from '@rspack/plugin-react-refresh';
17
17
  export interface Entities<T> {
18
18
  data: Record<string, T>;
19
19
  keys: string[];
@@ -158,7 +158,7 @@ export interface ClientConfig {
158
158
  /**
159
159
  * Add additional options to DefinePlugin
160
160
  */
161
- definitions?: DefinePlugin['definitions'];
161
+ definitions?: DefinePluginOptions;
162
162
  watchOptions?: Configuration['watchOptions'] & {
163
163
  /**
164
164
  * watch changes in node_modules
@@ -171,7 +171,7 @@ export interface ClientConfig {
171
171
  */
172
172
  newWebWorkerSyntax?: boolean;
173
173
  babelCacheDirectory?: boolean | string;
174
- cache?: boolean | FileCacheOptions | MemoryCacheOptions;
174
+ cache?: boolean;
175
175
  /** Use [Lighting CSS](https://lightningcss.dev) to transform and minimize css instead of PostCSS and cssnano*/
176
176
  transformCssWithLightningCss?: boolean;
177
177
  sentryConfig?: SentryWebpackPluginOptions;
@@ -1,4 +1,4 @@
1
- import type { Compiler } from 'webpack';
1
+ import type { Compiler } from '@rspack/core';
2
2
  import type { Logger } from '../logger/index.js';
3
3
  import type { UploadOptions } from './upload.js';
4
4
  import type { S3ClientOptions } from './s3-client.js';
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.S3UploadPlugin = void 0;
4
- const webpack_1 = require("webpack");
5
4
  const fast_glob_1 = require("fast-glob");
6
5
  const upload_js_1 = require("./upload.js");
7
6
  class S3UploadPlugin {
@@ -12,7 +11,10 @@ class S3UploadPlugin {
12
11
  apply(compiler) {
13
12
  compiler.hooks.done.tapPromise('s3-upload-plugin', async (stats) => {
14
13
  if (stats.hasErrors()) {
15
- stats.compilation.warnings.push(new webpack_1.WebpackError('s3-upload-plugin: skipped upload to s3 due to compilation errors'));
14
+ stats.compilation.warnings.push({
15
+ name: 's3-upload-plugin',
16
+ message: 's3-upload-plugin: skipped upload to s3 due to compilation errors',
17
+ });
16
18
  return;
17
19
  }
18
20
  let fileNames = Object.keys(stats.compilation.assets);
@@ -39,8 +41,10 @@ class S3UploadPlugin {
39
41
  this.options.logger?.success(`Files successfully uploaded to bucket ${this.options.s3UploadOptions.bucket}`);
40
42
  }
41
43
  catch (e) {
42
- const error = new webpack_1.WebpackError(`s3-upload-plugin: ${e instanceof Error ? e.message : e}`);
43
- stats.compilation.errors.push(error);
44
+ stats.compilation.errors.push({
45
+ name: 's3-upload-plugin',
46
+ message: `s3-upload-plugin: ${e instanceof Error ? e.message : e}`,
47
+ });
44
48
  }
45
49
  });
46
50
  }
@@ -1,10 +1,7 @@
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.webpackCompile = webpackCompile;
7
- const webpack_1 = __importDefault(require("webpack"));
4
+ const core_1 = require("@rspack/core");
8
5
  const logger_1 = require("../logger");
9
6
  const config_1 = require("./config");
10
7
  const utils_1 = require("./utils");
@@ -13,16 +10,16 @@ async function webpackCompile(config) {
13
10
  const webpackConfig = await (0, config_1.webpackConfigFactory)("production" /* WebpackMode.Prod */, config, { logger });
14
11
  logger.verbose('Config created');
15
12
  return new Promise((resolve) => {
16
- const compiler = (0, webpack_1.default)(webpackConfig, (0, utils_1.webpackCompilerHandlerFactory)(logger, async () => {
13
+ const compiler = (0, core_1.rspack)(webpackConfig, (0, utils_1.webpackCompilerHandlerFactory)(logger, async () => {
17
14
  resolve();
18
15
  }));
19
16
  process.on('SIGINT', async () => {
20
- compiler.close(() => {
17
+ compiler?.close(() => {
21
18
  process.exit(1);
22
19
  });
23
20
  });
24
21
  process.on('SIGTERM', async () => {
25
- compiler.close(() => {
22
+ compiler?.close(() => {
26
23
  process.exit(1);
27
24
  });
28
25
  });
@@ -1,6 +1,8 @@
1
- import * as webpack from 'webpack';
1
+ import { Configuration, ResolveOptions, RuleSetRule } from '@rspack/core';
2
+ import { ManifestPluginOptions } from 'rspack-manifest-plugin';
2
3
  import type { NormalizedClientConfig } from '../models';
3
4
  import type { Logger } from '../logger';
5
+ export declare const generateManifest: ManifestPluginOptions['generate'];
4
6
  export interface HelperOptions {
5
7
  config: NormalizedClientConfig;
6
8
  logger?: Logger;
@@ -14,9 +16,9 @@ export declare const enum WebpackMode {
14
16
  }
15
17
  export declare function webpackConfigFactory(webpackMode: WebpackMode, config: NormalizedClientConfig, { logger }?: {
16
18
  logger?: Logger;
17
- }): Promise<webpack.Configuration>;
18
- export declare function configureModuleRules(helperOptions: HelperOptions, additionalRules?: NonNullable<webpack.RuleSetRule['oneOf']>): webpack.RuleSetRule[];
19
- export declare function configureResolve({ isEnvProduction, config }: HelperOptions): webpack.ResolveOptions;
20
- type Optimization = NonNullable<webpack.Configuration['optimization']>;
19
+ }): Promise<Configuration>;
20
+ export declare function configureModuleRules(helperOptions: HelperOptions, additionalRules?: NonNullable<RuleSetRule['oneOf']>): RuleSetRule[];
21
+ export declare function configureResolve({ isEnvProduction, config }: HelperOptions): ResolveOptions;
22
+ type Optimization = NonNullable<Configuration['optimization']>;
21
23
  export declare function configureOptimization({ config }: HelperOptions): Optimization;
22
24
  export {};
@@ -26,6 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.generateManifest = void 0;
29
30
  exports.webpackConfigFactory = webpackConfigFactory;
30
31
  exports.configureModuleRules = configureModuleRules;
31
32
  exports.configureResolve = configureResolve;
@@ -33,15 +34,11 @@ exports.configureOptimization = configureOptimization;
33
34
  /* eslint-disable complexity */
34
35
  const path = __importStar(require("node:path"));
35
36
  const fs = __importStar(require("node:fs"));
36
- const webpack = __importStar(require("webpack"));
37
- const clean_webpack_plugin_1 = require("clean-webpack-plugin");
38
- const webpack_manifest_plugin_1 = require("webpack-manifest-plugin");
37
+ const core_1 = require("@rspack/core");
39
38
  const fork_ts_checker_webpack_plugin_1 = __importDefault(require("fork-ts-checker-webpack-plugin"));
40
- const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
41
39
  const webpack_bundle_analyzer_1 = require("webpack-bundle-analyzer");
42
- const webpack_assets_manifest_1 = __importDefault(require("webpack-assets-manifest"));
43
- const react_refresh_webpack_plugin_1 = __importDefault(require("@pmmmwh/react-refresh-webpack-plugin"));
44
- const moment_timezone_data_webpack_plugin_1 = __importDefault(require("moment-timezone-data-webpack-plugin"));
40
+ const rspack_manifest_plugin_1 = require("rspack-manifest-plugin");
41
+ const plugin_react_refresh_1 = __importDefault(require("@rspack/plugin-react-refresh"));
45
42
  const webpack_plugin_1 = __importDefault(require("@statoscope/webpack-plugin"));
46
43
  const circular_dependency_plugin_1 = __importDefault(require("circular-dependency-plugin"));
47
44
  const paths_1 = __importDefault(require("../paths"));
@@ -53,6 +50,28 @@ const log_config_1 = require("../logger/log-config");
53
50
  const utils_2 = require("../typescript/utils");
54
51
  const imagesSizeLimit = 2048;
55
52
  const fontSizeLimit = 8192;
53
+ const generateManifest = (seed, files, entries) => {
54
+ const manifestFiles = files.reduce((manifest, file) => {
55
+ manifest[file.name] = file.path;
56
+ return manifest;
57
+ }, seed);
58
+ const entrypoints = Object.keys(entries).reduce((previous, name) => {
59
+ return {
60
+ ...previous,
61
+ [name]: {
62
+ assets: {
63
+ js: entries[name].filter((file) => file.endsWith('.js')),
64
+ css: entries[name].filter((file) => file.endsWith('.css')),
65
+ },
66
+ },
67
+ };
68
+ }, {});
69
+ return {
70
+ files: manifestFiles,
71
+ entrypoints,
72
+ };
73
+ };
74
+ exports.generateManifest = generateManifest;
56
75
  async function webpackConfigFactory(webpackMode, config, { logger } = {}) {
57
76
  const isEnvDevelopment = webpackMode === "development" /* WebpackMode.Dev */;
58
77
  const isEnvProduction = webpackMode === "production" /* WebpackMode.Prod */;
@@ -87,9 +106,12 @@ async function webpackConfigFactory(webpackMode, config, { logger } = {}) {
87
106
  }
88
107
  : undefined,
89
108
  experiments: configureExperiments(helperOptions),
109
+ // TODO не поддерживается?
110
+ /*
90
111
  snapshot: {
91
112
  managedPaths: config.watchOptions?.watchPackages ? [] : undefined,
92
113
  },
114
+ */
93
115
  cache: config.cache,
94
116
  };
95
117
  webpackConfig = await config.webpack(webpackConfig, { configType: webpackMode });
@@ -104,7 +126,8 @@ function configureModuleRules(helperOptions, additionalRules = []) {
104
126
  ...createSourceMapRules(!helperOptions.config.disableSourceMapGeneration),
105
127
  {
106
128
  oneOf: [
107
- createWorkerRule(helperOptions),
129
+ // TODO с воркерами разобраться
130
+ // createWorkerRule(helperOptions),
108
131
  createJavaScriptRule(helperOptions, jsLoader),
109
132
  createStylesRule(helperOptions),
110
133
  createSassStylesRule(helperOptions),
@@ -286,27 +309,29 @@ function createSourceMapRules(shouldUseSourceMap) {
286
309
  }
287
310
  return [];
288
311
  }
289
- function createWorkerRule(options) {
312
+ /*
313
+ function createWorkerRule(options: HelperOptions): RuleSetRule {
290
314
  return {
291
315
  test: /\.worker\.[jt]sx?$/,
292
316
  exclude: /node_modules/,
293
317
  use: [
294
318
  options.config.newWebWorkerSyntax
295
319
  ? {
296
- loader: require.resolve('./worker/worker-loader'),
297
- }
320
+ loader: require.resolve('./worker/worker-loader'),
321
+ }
298
322
  : {
299
- loader: require.resolve('worker-loader'),
300
- // currently workers located on cdn are not working properly, so we are enforcing loading workers from
301
- // service instead
302
- options: {
303
- inline: 'no-fallback',
304
- },
305
- },
323
+ loader: require.resolve('worker-loader'),
324
+ // currently workers located on cdn are not working properly, so we are enforcing loading workers from
325
+ // service instead
326
+ options: {
327
+ inline: 'no-fallback',
328
+ },
329
+ },
306
330
  createJavaScriptLoader(options),
307
331
  ],
308
332
  };
309
333
  }
334
+ */
310
335
  function createSassStylesRule(options) {
311
336
  const loaders = getCssLoaders(options);
312
337
  loaders.push({
@@ -341,7 +366,7 @@ function createStylesRule(options) {
341
366
  function getCssLoaders({ isEnvDevelopment, isEnvProduction, config }) {
342
367
  const loaders = [];
343
368
  if (isEnvProduction) {
344
- loaders.push(mini_css_extract_plugin_1.default.loader);
369
+ loaders.push(core_1.CssExtractRspackPlugin.loader);
345
370
  }
346
371
  if (isEnvDevelopment) {
347
372
  loaders.push({
@@ -506,32 +531,27 @@ function createFallbackRules({ isEnvProduction }) {
506
531
  }
507
532
  return rules;
508
533
  }
509
- function createMomentTimezoneDataPlugin(options = {}) {
510
- const currentYear = new Date().getFullYear();
511
- // By default get data for current year only
512
- // https://momentjs.com/timezone/docs/#/use-it/webpack/
513
- const startYear = options.startYear ?? currentYear;
514
- const endYear = options.endYear ?? currentYear;
515
- return new moment_timezone_data_webpack_plugin_1.default({ ...options, startYear, endYear });
516
- }
517
534
  function configurePlugins(options) {
518
535
  const { isEnvDevelopment, isEnvProduction, config } = options;
519
- const excludeFromClean = config.excludeFromClean || [];
536
+ // const excludeFromClean = config.excludeFromClean || [];
520
537
  const plugins = [
521
- new clean_webpack_plugin_1.CleanWebpackPlugin({
522
- verbose: config.verbose,
523
- cleanOnceBeforeBuildPatterns: [
524
- '**/*',
525
- ...(isEnvDevelopment ? ['!manifest.json'] : []),
526
- ...excludeFromClean,
527
- ],
528
- }),
529
- new webpack_manifest_plugin_1.WebpackManifestPlugin({
530
- writeToFileEmit: true,
531
- publicPath: '',
532
- }),
533
- createMomentTimezoneDataPlugin(config.momentTz),
534
- new webpack.DefinePlugin({
538
+ // TODO CleanWebpackPlugin
539
+ // new CleanWebpackPlugin({
540
+ // verbose: config.verbose,
541
+ // cleanOnceBeforeBuildPatterns: [
542
+ // '**/*',
543
+ // ...(isEnvDevelopment ? ['!manifest.json'] : []),
544
+ // ...excludeFromClean,
545
+ // ],
546
+ // }),
547
+ // TODO WebpackManifestPlugin
548
+ // new WebpackManifestPlugin({
549
+ // writeToFileEmit: true,
550
+ // publicPath: '',
551
+ // }),
552
+ // TODO а этот плагин вообще нужен?
553
+ // createMomentTimezoneDataPlugin(config.momentTz),
554
+ new core_1.rspack.DefinePlugin({
535
555
  'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
536
556
  ...config.definitions,
537
557
  }),
@@ -539,18 +559,19 @@ function configurePlugins(options) {
539
559
  if (options.logger) {
540
560
  plugins.push(new progress_plugin_1.ProgressPlugin({ logger: options.logger }));
541
561
  }
542
- if (process.env.WEBPACK_PROFILE === 'true') {
543
- plugins.push(new webpack.debug.ProfilingPlugin());
544
- }
562
+ // TODO ProfilingPlugin
563
+ // if (process.env.WEBPACK_PROFILE === 'true') {
564
+ // plugins.push(new webpack.debug.ProfilingPlugin());
565
+ // }
545
566
  const contextReplacement = config.contextReplacement || {};
546
- plugins.push(new webpack.ContextReplacementPlugin(/moment[\\/]locale$/,
567
+ plugins.push(new core_1.ContextReplacementPlugin(/moment[\\/]locale$/,
547
568
  // eslint-disable-next-line security/detect-non-literal-regexp
548
569
  new RegExp(`^\\./(${(contextReplacement.locale || ['ru']).join('|')})$`)));
549
- plugins.push(new webpack.ContextReplacementPlugin(/dayjs[\\/]locale$/,
570
+ plugins.push(new core_1.ContextReplacementPlugin(/dayjs[\\/]locale$/,
550
571
  // eslint-disable-next-line security/detect-non-literal-regexp
551
572
  new RegExp(`^\\./(${(contextReplacement.locale || ['ru']).join('|')})\\.js$`)));
552
573
  if (contextReplacement['highlight.js']) {
553
- plugins.push(new webpack.ContextReplacementPlugin(/highlight\.js[\\/]lib[\\/]languages$/,
574
+ plugins.push(new core_1.ContextReplacementPlugin(/highlight\.js[\\/]lib[\\/]languages$/,
554
575
  // eslint-disable-next-line security/detect-non-literal-regexp
555
576
  new RegExp(`^\\./(${contextReplacement['highlight.js'].join('|')})$`)));
556
577
  }
@@ -565,9 +586,11 @@ function configurePlugins(options) {
565
586
  }));
566
587
  }
567
588
  if (isEnvDevelopment && config.reactRefresh !== false) {
568
- const { webSocketPath = path.normalize(`/${config.publicPathPrefix}/build/sockjs-node`) } = config.devServer || {};
569
- plugins.push(new react_refresh_webpack_plugin_1.default(config.reactRefresh({
570
- overlay: { sockPath: webSocketPath },
589
+ //const {webSocketPath = path.normalize(`/${config.publicPathPrefix}/build/sockjs-node`)} =
590
+ // config.devServer || {};
591
+ plugins.push(new plugin_react_refresh_1.default(config.reactRefresh({
592
+ // TODO допилить параметры
593
+ // overlay: {sockPath: webSocketPath},
571
594
  exclude: [/node_modules/, /\.worker\.[jt]sx?$/],
572
595
  })));
573
596
  }
@@ -596,10 +619,10 @@ function configurePlugins(options) {
596
619
  }));
597
620
  }
598
621
  if (config.polyfill?.process) {
599
- plugins.push(new webpack.ProvidePlugin({ process: 'process/browser.js' }));
622
+ plugins.push(new core_1.rspack.ProvidePlugin({ process: 'process/browser.js' }));
600
623
  }
601
624
  if (isEnvProduction) {
602
- plugins.push(new mini_css_extract_plugin_1.default({
625
+ plugins.push(new core_1.CssExtractRspackPlugin({
603
626
  filename: 'css/[name].[contenthash:8].css',
604
627
  chunkFilename: 'css/[name].[contenthash:8].chunk.css',
605
628
  ignoreOrder: true,
@@ -629,16 +652,12 @@ function configurePlugins(options) {
629
652
  }
630
653
  }
631
654
  const manifestFile = 'assets-manifest.json';
632
- plugins.push(new webpack_assets_manifest_1.default(isEnvProduction
633
- ? {
634
- entrypoints: true,
635
- output: manifestFile,
636
- }
637
- : {
638
- entrypoints: true,
639
- writeToDisk: true,
640
- output: path.resolve(paths_1.default.appBuild, manifestFile),
641
- }));
655
+ plugins.push(new rspack_manifest_plugin_1.RspackManifestPlugin({
656
+ fileName: manifestFile,
657
+ writeToFileEmit: true,
658
+ publicPath: '',
659
+ generate: exports.generateManifest,
660
+ }));
642
661
  if (config.cdn) {
643
662
  let credentialsGlobal;
644
663
  if (process.env.FRONTEND_S3_ACCESS_KEY_ID && process.env.FRONTEND_S3_SECRET_ACCESS_KEY) {
@@ -728,49 +747,34 @@ function configureOptimization({ config }) {
728
747
  },
729
748
  runtimeChunk: 'single',
730
749
  minimizer: [
731
- (compiler) => {
732
- // CssMinimizerWebpackPlugin works with MiniCSSExtractPlugin, so only relevant for production builds.
733
- // Lazy load the CssMinimizerPlugin plugin
734
- const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
735
- if (config.transformCssWithLightningCss) {
736
- const lightningCss = require('lightningcss');
737
- const browserslist = require('browserslist');
738
- new CssMinimizerPlugin({
739
- minify: CssMinimizerPlugin.lightningCssMinify,
740
- minimizerOptions: {
741
- targets: lightningCss.browserslistToTargets(browserslist()),
742
- },
743
- }).apply(compiler);
744
- }
745
- else {
746
- new CssMinimizerPlugin({
747
- minimizerOptions: {
748
- preset: [
749
- 'default',
750
- {
751
- svgo: false,
752
- },
753
- ],
754
- },
755
- }).apply(compiler);
756
- }
757
- },
758
- (compiler) => {
759
- // Lazy load the Terser plugin
760
- const TerserPlugin = require('terser-webpack-plugin');
761
- let terserOptions = {
750
+ new core_1.rspack.SwcJsMinimizerRspackPlugin({
751
+ minimizerOptions: {
752
+ mangle: !config.reactProfiling,
762
753
  compress: {
763
754
  passes: 2,
764
755
  },
765
- safari10: config.safari10,
766
- mangle: !config.reactProfiling,
767
- };
768
- const { terser } = config;
769
- if (typeof terser === 'function') {
770
- terserOptions = terser(terserOptions);
771
- }
772
- new TerserPlugin({ terserOptions }).apply(compiler);
773
- },
756
+ format: {
757
+ safari10: config.safari10,
758
+ },
759
+ },
760
+ }),
761
+ new core_1.rspack.LightningCssMinimizerRspackPlugin({
762
+ minimizerOptions: {
763
+ // TODO че то не срослось
764
+ // targets: browserslist(),
765
+ targets: [
766
+ 'last 2 major versions and last 2 years and fully supports es6 and > 0.05%',
767
+ 'not dead',
768
+ 'not op_mini all',
769
+ 'not and_qq > 0',
770
+ 'not and_uc > 0',
771
+ 'Firefox ESR',
772
+ 'Chrome > 0 and last 2 years and > 0.05%',
773
+ 'Safari > 0 and last 2 years and > 0.05%',
774
+ 'Firefox > 0 and last 2 years and > 0.01%',
775
+ ],
776
+ },
777
+ }),
774
778
  ],
775
779
  };
776
780
  return optimization;
@@ -1,4 +1,4 @@
1
- import * as webpack from 'webpack';
1
+ import * as webpack from '@rspack/core';
2
2
  import type { Logger } from '../logger';
3
3
  export declare class ProgressPlugin extends webpack.ProgressPlugin {
4
4
  private _logger;
@@ -24,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.ProgressPlugin = void 0;
27
- const webpack = __importStar(require("webpack"));
27
+ const webpack = __importStar(require("@rspack/core"));
28
28
  const pretty_time_1 = require("../logger/pretty-time");
29
29
  class ProgressPlugin extends webpack.ProgressPlugin {
30
30
  _logger;
@@ -1,17 +1,17 @@
1
1
  import { WebpackMode } from './config';
2
2
  import type { ClientConfig } from '../models';
3
- import type * as Webpack from 'webpack';
3
+ import * as rspack from '@rspack/core';
4
4
  type Mode = `${WebpackMode}`;
5
- export declare function configureServiceWebpackConfig(mode: Mode, storybookConfig: Webpack.Configuration): Promise<Webpack.Configuration>;
6
- type ModuleRule = NonNullable<NonNullable<Webpack.Configuration['module']>['rules']>[number];
5
+ export declare function configureServiceWebpackConfig(mode: Mode, storybookConfig: rspack.Configuration): Promise<rspack.Configuration>;
6
+ type ModuleRule = NonNullable<NonNullable<rspack.Configuration['module']>['rules']>[number];
7
7
  export declare function configureWebpackConfigForStorybook(mode: Mode, userConfig?: ClientConfig, storybookModuleRules?: ModuleRule[]): Promise<{
8
8
  module: {
9
- rules: Webpack.RuleSetRule[];
9
+ rules: rspack.RuleSetRule[];
10
10
  };
11
- resolve: Webpack.ResolveOptions;
12
- plugins: (false | "" | 0 | ((this: Webpack.Compiler, compiler: Webpack.Compiler) => void) | Webpack.WebpackPluginInstance | null | undefined)[];
11
+ resolve: rspack.ResolveOptions;
12
+ plugins: rspack.Plugins;
13
13
  optimization: {
14
- minimizer: (false | "" | 0 | "..." | Webpack.WebpackPluginInstance | ((this: Webpack.Compiler, compiler: Webpack.Compiler) => void) | null | undefined)[] | undefined;
14
+ minimizer: ("..." | rspack.Plugin)[] | undefined;
15
15
  };
16
16
  }>;
17
17
  export {};
@@ -29,7 +29,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.configureServiceWebpackConfig = configureServiceWebpackConfig;
30
30
  exports.configureWebpackConfigForStorybook = configureWebpackConfigForStorybook;
31
31
  const path = __importStar(require("node:path"));
32
- const react_refresh_webpack_plugin_1 = __importDefault(require("@pmmmwh/react-refresh-webpack-plugin"));
33
32
  const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
34
33
  const css_minimizer_webpack_plugin_1 = __importDefault(require("css-minimizer-webpack-plugin"));
35
34
  const config_1 = require("./config");
@@ -107,7 +106,7 @@ async function configureWebpackConfigForStorybook(mode, userConfig = {}, storybo
107
106
  };
108
107
  return {
109
108
  module: {
110
- rules: (0, config_1.configureModuleRules)(helperOptions, storybookModuleRules.filter((rule) => rule !== '...')),
109
+ rules: (0, config_1.configureModuleRules)(helperOptions, storybookModuleRules.filter((rule) => rule !== '...' && rule)),
111
110
  },
112
111
  resolve: (0, config_1.configureResolve)(helperOptions),
113
112
  plugins: configurePlugins(helperOptions),
@@ -119,8 +118,8 @@ async function configureWebpackConfigForStorybook(mode, userConfig = {}, storybo
119
118
  function configurePlugins({ isEnvDevelopment, isEnvProduction, config }) {
120
119
  const plugins = [];
121
120
  if (config.definitions) {
122
- const webpack = require(path.resolve(process.cwd(), 'node_modules/webpack'));
123
- plugins.push(new webpack.DefinePlugin({
121
+ const rspackLibrary = require(path.resolve(process.cwd(), 'node_modules/@rspack/core'));
122
+ plugins.push(new rspackLibrary.DefinePlugin({
124
123
  ...config.definitions,
125
124
  }));
126
125
  }
@@ -134,7 +133,8 @@ function configurePlugins({ isEnvDevelopment, isEnvProduction, config }) {
134
133
  }));
135
134
  }
136
135
  if (isEnvDevelopment && config.reactRefresh !== false) {
137
- plugins.push(new react_refresh_webpack_plugin_1.default(config.reactRefresh({})));
136
+ // TODO поправить типы
137
+ // plugins.push(new ReactRefreshWebpackPlugin(config.reactRefresh({})));
138
138
  }
139
139
  if (isEnvProduction) {
140
140
  plugins.push(new mini_css_extract_plugin_1.default({
@@ -1,6 +1,6 @@
1
- import type webpack from 'webpack';
1
+ import type { Stats } from '@rspack/core';
2
2
  import type { Logger } from '../logger';
3
- export declare function webpackCompilerHandlerFactory(logger: Logger, onCompilationEnd?: () => void): (err?: Error | null, stats?: webpack.Stats) => Promise<void>;
3
+ export declare function webpackCompilerHandlerFactory(logger: Logger, onCompilationEnd?: () => void): (err?: Error | null, stats?: Stats) => Promise<void>;
4
4
  export declare function resolveTsconfigPathsToAlias(tsConfigPath: string): {
5
5
  aliases: Record<string, string[]>;
6
6
  modules: string[];
@@ -51,7 +51,7 @@ function webpackCompilerHandlerFactory(logger, onCompilationEnd) {
51
51
  await onCompilationEnd();
52
52
  }
53
53
  if (stats) {
54
- const time = stats.endTime - stats.startTime;
54
+ const time = (stats.endTime || 0) - (stats.startTime || 0);
55
55
  logger.success(`Client was successfully compiled in ${(0, pretty_time_1.prettyTime)(BigInt(time) * BigInt(1_000_000))}`);
56
56
  }
57
57
  else {
@@ -4,9 +4,9 @@ export declare function createCli(argv: string[]): {
4
4
  verbose: boolean | undefined;
5
5
  cdn: string | undefined;
6
6
  env: string[] | undefined;
7
- target: "client" | "server" | undefined;
8
- inspect: number | undefined;
9
7
  c: unknown;
8
+ inspect: number | undefined;
9
+ target: "server" | "client" | undefined;
10
10
  inspectBrk: number | undefined;
11
11
  "inspect-brk": number | undefined;
12
12
  entryFilter: string[] | undefined;
@@ -32,9 +32,9 @@ export declare function createCli(argv: string[]): {
32
32
  verbose: boolean | undefined;
33
33
  cdn: string | undefined;
34
34
  env: string[] | undefined;
35
- target: "client" | "server" | undefined;
36
- inspect: number | undefined;
37
35
  c: unknown;
36
+ inspect: number | undefined;
37
+ target: "server" | "client" | undefined;
38
38
  inspectBrk: number | undefined;
39
39
  "inspect-brk": number | undefined;
40
40
  entryFilter: string[] | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/app-builder",
3
- "version": "0.12.0",
3
+ "version": "0.12.1-beta.0",
4
4
  "description": "Develop and build your React client-server projects, powered by typescript and webpack",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",
@@ -71,6 +71,7 @@
71
71
  "@babel/runtime": "^7.24.0",
72
72
  "@okikio/sharedworker": "^1.0.7",
73
73
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
74
+ "@rspack/dev-server": "^1.0.7",
74
75
  "@statoscope/webpack-plugin": "^5.28.2",
75
76
  "@svgr/core": "^8.1.0",
76
77
  "@svgr/plugin-jsx": "^8.1.0",
@@ -109,9 +110,9 @@
109
110
  "postcss-preset-env": "^9.1.3",
110
111
  "react": "^18.3.1",
111
112
  "react-dom": "^18.3.1",
112
- "react-refresh": "^0.14.2",
113
113
  "resolve-url-loader": "^5.0.0",
114
114
  "rimraf": "^5.0.7",
115
+ "rspack-manifest-plugin": "^5.0.1",
115
116
  "sass": "^1.77.5",
116
117
  "sass-loader": "^14.2.1",
117
118
  "semver": "^7.6.2",
@@ -128,7 +129,6 @@
128
129
  "webpack-assets-manifest": "^5.2.1",
129
130
  "webpack-bundle-analyzer": "^4.10.2",
130
131
  "webpack-dev-server": "^5.0.4",
131
- "webpack-manifest-plugin": "^5.0.0",
132
132
  "worker-loader": "^3.0.8",
133
133
  "yargs": "^17.7.2"
134
134
  },
@@ -138,6 +138,9 @@
138
138
  "@gravity-ui/eslint-config": "^3.2.0",
139
139
  "@gravity-ui/prettier-config": "^1.1.0",
140
140
  "@gravity-ui/tsconfig": "^1.0.0",
141
+ "@rspack/cli": "^1.2.0",
142
+ "@rspack/core": "^1.2.0",
143
+ "@rspack/plugin-react-refresh": "^1.0.0",
141
144
  "@sentry/webpack-plugin": "^2.7.1",
142
145
  "@types/babel__helper-plugin-utils": "^7.10.3",
143
146
  "@types/circular-dependency-plugin": "^5.0.8",
@@ -162,6 +165,7 @@
162
165
  "nano-staged": "^0.8.0",
163
166
  "npm-run-all": "^4.1.5",
164
167
  "prettier": "3.3.2",
168
+ "react-refresh": "^0.14.2",
165
169
  "ts-jest": "^29.1.2"
166
170
  },
167
171
  "peerDependencies": {