@gravity-ui/app-builder 0.15.1-beta.3 → 0.15.1-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -64,7 +64,7 @@ async function buildDevServer(config) {
64
64
  }),
65
65
  ];
66
66
  if (isSsr) {
67
- const ssrLogger = new logger_1.Logger('webpack(SSR)', config.verbose);
67
+ const ssrLogger = new logger_1.Logger('client(SSR)', config.verbose);
68
68
  webpackConfigs.push(await (0, config_1.webpackConfigFactory)({
69
69
  webpackMode: "development" /* WebpackMode.Dev */,
70
70
  config: normalizedConfig,
@@ -82,7 +82,7 @@ async function buildDevServer(config) {
82
82
  }),
83
83
  ];
84
84
  if (isSsr) {
85
- const ssrLogger = new logger_1.Logger('rspack(SSR)', config.verbose);
85
+ const ssrLogger = new logger_1.Logger('client(SSR)', config.verbose);
86
86
  rspackConfigs.push(await (0, config_1.rspackConfigFactory)({
87
87
  webpackMode: "development" /* WebpackMode.Dev */,
88
88
  config: normalizedConfig,
@@ -129,7 +129,6 @@ function compileStyles(inputDir, outputDir, onFinish, additionalGlobs = []) {
129
129
  const sassTransformed = sass_1.default.compile(scssFile, {
130
130
  sourceMap: true,
131
131
  sourceMapIncludeSources: true,
132
- silenceDeprecations: ['legacy-js-api'],
133
132
  importers: [
134
133
  {
135
134
  findFileUrl(url) {
@@ -9,7 +9,6 @@ const core_1 = require("@rspack/core");
9
9
  const logger_1 = require("../logger");
10
10
  const config_1 = require("./config");
11
11
  const utils_1 = require("./utils");
12
- const rspack_1 = require("./rspack");
13
12
  async function clientCompile(config) {
14
13
  const logger = new logger_1.Logger('client', config.verbose);
15
14
  const webpackConfigs = [];
@@ -41,13 +40,12 @@ async function clientCompile(config) {
41
40
  }
42
41
  logger.verbose('Config created');
43
42
  return new Promise((resolve) => {
43
+ const compilerHandler = (0, utils_1.compilerHandlerFactory)(logger, async () => {
44
+ resolve();
45
+ });
44
46
  const compiler = config.bundler === 'rspack'
45
- ? (0, core_1.rspack)(rspackConfigs, (0, rspack_1.rspackCompilerHandlerFactory)(logger, async () => {
46
- resolve();
47
- }))
48
- : (0, webpack_1.default)(webpackConfigs, (0, utils_1.webpackCompilerHandlerFactory)(logger, async () => {
49
- resolve();
50
- }));
47
+ ? (0, core_1.rspack)(rspackConfigs, compilerHandler)
48
+ : (0, webpack_1.default)(webpackConfigs, compilerHandler);
51
49
  process.on('SIGINT', async () => {
52
50
  compiler?.close(() => {
53
51
  process.exit(1);
@@ -87,18 +87,6 @@ function configureExternals({ config, isSsr }) {
87
87
  }
88
88
  return externals;
89
89
  }
90
- function prepareRspackExternals(externals) {
91
- if (Array.isArray(externals)) {
92
- const rspackExternals = {};
93
- for (const ext of externals) {
94
- if (typeof ext === 'object' && ext !== null) {
95
- Object.assign(rspackExternals, ext);
96
- }
97
- }
98
- return rspackExternals;
99
- }
100
- return externals;
101
- }
102
90
  async function webpackConfigFactory(options) {
103
91
  const { config } = options;
104
92
  const helperOptions = getHelperOptions(options);
@@ -155,14 +143,14 @@ async function rspackConfigFactory(options) {
155
143
  target: isSsr ? 'node' : undefined,
156
144
  devtool: configureDevTool(helperOptions),
157
145
  entry: configureEntry(helperOptions),
158
- output: configureRspackOutput(helperOptions),
146
+ output: configureOutput(helperOptions),
159
147
  resolve: configureRspackResolve(helperOptions),
160
148
  module: {
161
149
  rules: (0, rspack_1.prepareRspackRules)(configureModuleRules(helperOptions)),
162
150
  },
163
151
  plugins: configureRspackPlugins(helperOptions),
164
152
  optimization: configureRspackOptimization(helperOptions),
165
- externals: prepareRspackExternals(configureExternals(helperOptions)),
153
+ externals: configureExternals(helperOptions),
166
154
  node: config.node,
167
155
  watchOptions: configureWatchOptions(helperOptions),
168
156
  ignoreWarnings: [/Failed to parse source map/],
@@ -381,18 +369,6 @@ function configureOutput(options) {
381
369
  ...ssrOptions,
382
370
  };
383
371
  }
384
- function configureRspackOutput(options) {
385
- const { filename, chunkFilename, library, chunkFormat, path, pathinfo } = configureOutput(options);
386
- return {
387
- filename: typeof filename === 'string' ? filename : undefined,
388
- chunkFilename: typeof chunkFilename === 'string' ? chunkFilename : undefined,
389
- library,
390
- chunkFormat,
391
- path,
392
- pathinfo,
393
- clean: false,
394
- };
395
- }
396
372
  function createJavaScriptLoader({ isEnvProduction, isEnvDevelopment, configType, config, isSsr, }) {
397
373
  const plugins = [];
398
374
  if (!isSsr) {
@@ -470,9 +446,7 @@ function createWorkerRule(options) {
470
446
  loader: require.resolve('./worker/worker-loader'),
471
447
  }
472
448
  : {
473
- loader: require.resolve(options.config.bundler === 'rspack'
474
- ? 'worker-rspack-loader'
475
- : 'worker-loader'),
449
+ loader: require.resolve('worker-rspack-loader'),
476
450
  // currently workers located on cdn are not working properly, so we are enforcing loading workers from
477
451
  // service instead
478
452
  options: {
@@ -777,9 +751,28 @@ function getCssExtractPluginOptions({ isEnvProduction }) {
777
751
  ignoreOrder: true,
778
752
  };
779
753
  }
754
+ const commonBundlerPlugins = {
755
+ DefinePlugin: {
756
+ rspack: core_1.rspack.DefinePlugin,
757
+ webpack: webpack.DefinePlugin,
758
+ },
759
+ ContextReplacementPlugin: {
760
+ rspack: core_1.rspack.ContextReplacementPlugin,
761
+ webpack: webpack.ContextReplacementPlugin,
762
+ },
763
+ ProvidePlugin: {
764
+ rspack: core_1.rspack.ProvidePlugin,
765
+ webpack: webpack.ProvidePlugin,
766
+ },
767
+ ProgressPlugin: {
768
+ rspack: progress_plugin_1.RspackProgressPlugin,
769
+ webpack: progress_plugin_1.WebpackProgressPlugin,
770
+ },
771
+ };
780
772
  function configureCommonPlugins(options) {
781
773
  const { isEnvDevelopment, isEnvProduction, config, isSsr } = options;
782
774
  const excludeFromClean = config.excludeFromClean || [];
775
+ const bundler = config.bundler;
783
776
  const plugins = [
784
777
  new clean_webpack_plugin_1.CleanWebpackPlugin({
785
778
  verbose: config.verbose,
@@ -789,6 +782,10 @@ function configureCommonPlugins(options) {
789
782
  ...excludeFromClean,
790
783
  ],
791
784
  }),
785
+ new commonBundlerPlugins['DefinePlugin'][bundler](getDefinitions(options)),
786
+ ...(options.logger
787
+ ? [new commonBundlerPlugins['ProgressPlugin'][bundler]({ logger: options.logger })]
788
+ : []),
792
789
  ];
793
790
  if (config.detectCircularDependencies) {
794
791
  let circularPluginOptions = {
@@ -810,6 +807,13 @@ function configureCommonPlugins(options) {
810
807
  }
811
808
  }
812
809
  if (!isSsr) {
810
+ const contextReplacements = getContextReplacements(options);
811
+ contextReplacements.forEach(({ resourceRegExp, newResource }) => plugins.push(new commonBundlerPlugins['ContextReplacementPlugin'][bundler](resourceRegExp, newResource)));
812
+ if (config.polyfill?.process) {
813
+ plugins.push(new commonBundlerPlugins['ProvidePlugin'][bundler]({
814
+ process: 'process/browser.js',
815
+ }));
816
+ }
813
817
  if (config.monaco) {
814
818
  const MonacoEditorWebpackPlugin = require('monaco-editor-webpack-plugin');
815
819
  plugins.push(new MonacoEditorWebpackPlugin({
@@ -823,6 +827,18 @@ function configureCommonPlugins(options) {
823
827
  plugins.push(createMomentTimezoneDataPlugin(config.momentTz));
824
828
  }
825
829
  if (isEnvProduction) {
830
+ if (config.analyzeBundle === 'statoscope') {
831
+ const customStatoscopeConfig = config.statoscopeConfig || {};
832
+ plugins.push(new webpack_plugin_1.default({
833
+ saveReportTo: path.resolve(options.buildDirectory, 'report.html'),
834
+ saveStatsTo: path.resolve(options.buildDirectory, 'stats.json'),
835
+ open: false,
836
+ statsOptions: {
837
+ all: true,
838
+ },
839
+ ...customStatoscopeConfig,
840
+ }));
841
+ }
826
842
  if (config.sentryConfig) {
827
843
  const sentryPlugin = require('@sentry/webpack-plugin').sentryWebpackPlugin;
828
844
  plugins.push(sentryPlugin({ ...config.sentryConfig }));
@@ -838,8 +854,6 @@ function configureWebpackPlugins(options) {
838
854
  const forkTsCheckerOptions = getForkTsCheckerOptions(options);
839
855
  const webpackPlugins = [
840
856
  ...configureCommonPlugins(options),
841
- ...(options.logger ? [new progress_plugin_1.ProgressPlugin({ logger: options.logger })] : []),
842
- new webpack.DefinePlugin(getDefinitions(options)),
843
857
  new webpack_manifest_plugin_1.WebpackManifestPlugin({
844
858
  writeToFileEmit: true,
845
859
  publicPath: '',
@@ -861,18 +875,6 @@ function configureWebpackPlugins(options) {
861
875
  webpackPlugins.push(new mini_css_extract_plugin_1.default(getCssExtractPluginOptions(options)));
862
876
  }
863
877
  if (isEnvProduction) {
864
- if (config.analyzeBundle === 'statoscope') {
865
- const customStatoscopeConfig = config.statoscopeConfig || {};
866
- webpackPlugins.push(new webpack_plugin_1.default({
867
- saveReportTo: path.resolve(options.buildDirectory, 'report.html'),
868
- saveStatsTo: path.resolve(options.buildDirectory, 'stats.json'),
869
- open: false,
870
- statsOptions: {
871
- all: true,
872
- },
873
- ...customStatoscopeConfig,
874
- }));
875
- }
876
878
  if (config.analyzeBundle === 'rsdoctor') {
877
879
  const { RsdoctorWebpackPlugin } = require('@rsdoctor/webpack-plugin');
878
880
  webpackPlugins.push(new RsdoctorWebpackPlugin({
@@ -880,20 +882,13 @@ function configureWebpackPlugins(options) {
880
882
  }));
881
883
  }
882
884
  }
883
- if (!isSsr) {
884
- const contextReplacements = getContextReplacements(options);
885
- contextReplacements.forEach(({ resourceRegExp, newResource }) => webpackPlugins.push(new webpack.ContextReplacementPlugin(resourceRegExp, newResource)));
886
- if (isEnvDevelopment && config.reactRefresh !== false) {
887
- const { webSocketPath = path.normalize(`/${config.publicPathPrefix}/build/sockjs-node`), } = config.devServer || {};
888
- const reactRefreshConfig = config.reactRefresh({
889
- overlay: { sockPath: webSocketPath },
890
- exclude: [/node_modules/, /\.worker\.[jt]sx?$/],
891
- });
892
- webpackPlugins.push(new react_refresh_webpack_plugin_1.default(reactRefreshConfig));
893
- }
894
- if (config.polyfill?.process) {
895
- webpackPlugins.push(new webpack.ProvidePlugin({ process: 'process/browser.js' }));
896
- }
885
+ if (!isSsr && isEnvDevelopment && config.reactRefresh !== false) {
886
+ const { webSocketPath = path.normalize(`/${config.publicPathPrefix}/build/sockjs-node`) } = config.devServer || {};
887
+ const reactRefreshConfig = config.reactRefresh({
888
+ overlay: { sockPath: webSocketPath },
889
+ exclude: [/node_modules/, /\.worker\.[jt]sx?$/],
890
+ });
891
+ webpackPlugins.push(new react_refresh_webpack_plugin_1.default(reactRefreshConfig));
897
892
  }
898
893
  return webpackPlugins;
899
894
  }
@@ -902,8 +897,6 @@ function configureRspackPlugins(options) {
902
897
  const forkTsCheckerOptions = getForkTsCheckerOptions(options);
903
898
  const rspackPlugins = [
904
899
  ...configureCommonPlugins(options),
905
- ...(options.logger ? [new rspack_1.RspackProgressPlugin({ logger: options.logger })] : []),
906
- new core_1.rspack.DefinePlugin(getDefinitions(options)),
907
900
  new rspack_manifest_plugin_1.RspackManifestPlugin({
908
901
  fileName: isEnvProduction
909
902
  ? assetsManifestFile
@@ -926,35 +919,26 @@ function configureRspackPlugins(options) {
926
919
  }));
927
920
  }
928
921
  }
929
- if (!isSsr) {
930
- const contextReplacements = getContextReplacements(options);
931
- contextReplacements.forEach(({ resourceRegExp, newResource }) => rspackPlugins.push(new core_1.rspack.ContextReplacementPlugin(resourceRegExp, newResource)));
932
- if (isEnvDevelopment && config.reactRefresh !== false) {
933
- const { webSocketPath = path.normalize(`/${config.publicPathPrefix}/build/sockjs-node`), } = config.devServer || {};
934
- const { overlay, ...reactRefreshConfig } = config.reactRefresh({
935
- overlay: { sockPath: webSocketPath },
936
- exclude: [/node_modules/, /\.worker\.[jt]sx?$/],
937
- });
938
- rspackPlugins.push(new plugin_react_refresh_1.default({
939
- ...reactRefreshConfig,
940
- overlay: typeof overlay === 'object'
941
- ? {
942
- entry: typeof overlay.entry === 'string' ? overlay.entry : undefined,
943
- module: typeof overlay.module === 'string'
944
- ? overlay.module
945
- : undefined,
946
- sockPath: overlay.sockPath,
947
- sockHost: overlay.sockHost,
948
- sockPort: overlay.sockPort?.toString(),
949
- sockProtocol: overlay.sockProtocol,
950
- sockIntegration: overlay.sockIntegration === 'wds' ? 'wds' : undefined,
951
- }
952
- : undefined,
953
- }));
954
- }
955
- if (config.polyfill?.process) {
956
- rspackPlugins.push(new core_1.rspack.ProvidePlugin({ process: 'process/browser.js' }));
957
- }
922
+ if (!isSsr && isEnvDevelopment && config.reactRefresh !== false) {
923
+ const { webSocketPath = path.normalize(`/${config.publicPathPrefix}/build/sockjs-node`) } = config.devServer || {};
924
+ const { overlay, ...reactRefreshConfig } = config.reactRefresh({
925
+ overlay: { sockPath: webSocketPath },
926
+ exclude: [/node_modules/, /\.worker\.[jt]sx?$/],
927
+ });
928
+ rspackPlugins.push(new plugin_react_refresh_1.default({
929
+ ...reactRefreshConfig,
930
+ overlay: typeof overlay === 'object'
931
+ ? {
932
+ entry: typeof overlay.entry === 'string' ? overlay.entry : undefined,
933
+ module: typeof overlay.module === 'string' ? overlay.module : undefined,
934
+ sockPath: overlay.sockPath,
935
+ sockHost: overlay.sockHost,
936
+ sockPort: overlay.sockPort?.toString(),
937
+ sockProtocol: overlay.sockProtocol,
938
+ sockIntegration: overlay.sockIntegration === 'wds' ? 'wds' : undefined,
939
+ }
940
+ : undefined,
941
+ }));
958
942
  }
959
943
  return rspackPlugins;
960
944
  }
@@ -1,12 +1,27 @@
1
- import webpack from 'webpack';
2
1
  import type * as Webpack from 'webpack';
3
2
  import type { Logger } from '../logger';
4
- export declare class ProgressPlugin extends webpack.ProgressPlugin {
5
- private _logger;
6
- private _state;
7
- constructor({ logger }: {
8
- logger: Logger;
9
- });
10
- handler: (percent: number, message: string, ...details: string[]) => void;
11
- apply(compiler: Webpack.Compiler): void;
3
+ interface State {
4
+ done?: boolean;
5
+ start?: bigint;
12
6
  }
7
+ export declare const WebpackProgressPlugin: {
8
+ new ({ logger }: {
9
+ logger: Logger;
10
+ }): {
11
+ logger: Logger;
12
+ state: State;
13
+ handler: (percent: number, message: string, ...details: string[]) => void;
14
+ apply(compiler: Webpack.Compiler): void;
15
+ };
16
+ };
17
+ export declare const RspackProgressPlugin: {
18
+ new ({ logger }: {
19
+ logger: Logger;
20
+ }): {
21
+ logger: Logger;
22
+ state: State;
23
+ handler: (percent: number, message: string, ...details: string[]) => void;
24
+ apply(compiler: Webpack.Compiler): void;
25
+ };
26
+ };
27
+ export {};
@@ -3,49 +3,53 @@ 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.ProgressPlugin = void 0;
6
+ exports.RspackProgressPlugin = exports.WebpackProgressPlugin = void 0;
7
7
  const webpack_1 = __importDefault(require("webpack"));
8
8
  const pretty_time_1 = require("../logger/pretty-time");
9
- class ProgressPlugin extends webpack_1.default.ProgressPlugin {
10
- _logger;
11
- _state = {};
12
- constructor({ logger }) {
13
- super();
14
- this._logger = logger;
15
- }
16
- handler = (percent, message, ...details) => {
17
- const progress = Math.floor(percent * 100);
18
- this._logger.status(`${this._logger.colors.green(`${progress}%`)} - ${this._logger.colors.yellow(message)}${details.length > 0 ? `: ${this._logger.colors.dim(...details)}` : ''}`);
9
+ const core_1 = require("@rspack/core");
10
+ function createProgressPlugin(BaseClass) {
11
+ return class ProgressPlugin extends BaseClass {
12
+ logger;
13
+ state = {};
14
+ constructor({ logger }) {
15
+ super();
16
+ this.logger = logger;
17
+ }
18
+ handler = (percent, message, ...details) => {
19
+ const progress = Math.floor(percent * 100);
20
+ this.logger.status(`${this.logger.colors.green(`${progress}%`)} - ${this.logger.colors.yellow(message)}${details.length > 0 ? `: ${this.logger.colors.dim(...details)}` : ''}`);
21
+ };
22
+ apply(compiler) {
23
+ super.apply(compiler);
24
+ hook(compiler, 'compile', () => {
25
+ this.logger.message('Start compilation');
26
+ if ('rspackVersion' in compiler.webpack) {
27
+ this.logger.message(`Rspack v${compiler.webpack.rspackVersion}`);
28
+ }
29
+ else {
30
+ this.logger.message(`Webpack v${compiler.webpack.version}`);
31
+ }
32
+ this.state.start = process.hrtime.bigint();
33
+ });
34
+ hook(compiler, 'invalid', (fileName, changeTime) => {
35
+ this.logger.verbose(`Invalidate file: ${fileName} at ${changeTime}`);
36
+ });
37
+ hook(compiler, 'done', (stats) => {
38
+ const time = this.state.start ? ' in ' + (0, pretty_time_1.elapsedTime)(this.state.start) : '';
39
+ const hasErrors = stats.hasErrors();
40
+ if (hasErrors) {
41
+ this.logger.error('Compiled with some errors' + time);
42
+ }
43
+ else {
44
+ this.logger.success('Compiled successfully' + time);
45
+ }
46
+ });
47
+ }
19
48
  };
20
- apply(compiler) {
21
- super.apply(compiler);
22
- hook(compiler, 'compile', () => {
23
- this._logger.message('Start compilation');
24
- if ('rspackVersion' in compiler.webpack) {
25
- this._logger.message(`Rspack v${compiler.webpack.rspackVersion}`);
26
- }
27
- else {
28
- this._logger.message(`Webpack v${compiler.webpack.version}`);
29
- }
30
- this._state.start = process.hrtime.bigint();
31
- });
32
- hook(compiler, 'invalid', (fileName, changeTime) => {
33
- this._logger.verbose(`Invalidate file: ${fileName} at ${changeTime}`);
34
- });
35
- hook(compiler, 'done', (stats) => {
36
- const time = this._state.start ? ' in ' + (0, pretty_time_1.elapsedTime)(this._state.start) : '';
37
- const hasErrors = stats.hasErrors();
38
- if (hasErrors) {
39
- this._logger.error('Compiled with some errors' + time);
40
- }
41
- else {
42
- this._logger.success('Compiled successfully' + time);
43
- }
44
- });
45
- }
46
49
  }
47
- exports.ProgressPlugin = ProgressPlugin;
48
50
  function hook(compiler, hookName, callback) {
49
51
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
50
52
  compiler.hooks[hookName].tap(`app-builder: ${hookName}`, callback);
51
53
  }
54
+ exports.WebpackProgressPlugin = createProgressPlugin(webpack_1.default.ProgressPlugin);
55
+ exports.RspackProgressPlugin = createProgressPlugin(core_1.rspack.ProgressPlugin);
@@ -1,18 +1,7 @@
1
1
  import { ManifestPluginOptions } from 'rspack-manifest-plugin';
2
2
  import type { RuleSetRule as WebpackRuleSetRule } from 'webpack';
3
- import { Compiler, MultiStats, rspack } from '@rspack/core';
4
3
  import type { Configuration, RuleSetRule as RspackRuleSetRule } from '@rspack/core';
5
4
  import type { Logger } from '../logger';
6
5
  export declare function clearCacheDirectory(config: Configuration, logger: Logger): void;
7
6
  export declare const generateAssetsManifest: ManifestPluginOptions['generate'];
8
7
  export declare function prepareRspackRules(webpackRules: (undefined | null | false | '' | 0 | WebpackRuleSetRule | '...')[]): (RspackRuleSetRule | '...')[];
9
- export declare class RspackProgressPlugin extends rspack.ProgressPlugin {
10
- private _logger;
11
- private _state;
12
- constructor({ logger }: {
13
- logger: Logger;
14
- });
15
- handler: (percent: number, message: string, ...details: string[]) => void;
16
- apply(compiler: Compiler): void;
17
- }
18
- export declare function rspackCompilerHandlerFactory(logger: Logger, onCompilationEnd?: () => void): (err?: Error | null, stats?: MultiStats) => Promise<void>;
@@ -26,14 +26,11 @@ 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.RspackProgressPlugin = exports.generateAssetsManifest = void 0;
29
+ exports.generateAssetsManifest = void 0;
30
30
  exports.clearCacheDirectory = clearCacheDirectory;
31
31
  exports.prepareRspackRules = prepareRspackRules;
32
- exports.rspackCompilerHandlerFactory = rspackCompilerHandlerFactory;
33
- const core_1 = require("@rspack/core");
34
32
  const fs = __importStar(require("node:fs"));
35
33
  const path = __importStar(require("node:path"));
36
- const pretty_time_1 = require("../logger/pretty-time");
37
34
  const paths_1 = __importDefault(require("../../common/paths"));
38
35
  function clearCacheDirectory(config, logger) {
39
36
  if (!config.cache) {
@@ -112,79 +109,3 @@ function prepareRspackRules(webpackRules) {
112
109
  }
113
110
  return rspackRules;
114
111
  }
115
- class RspackProgressPlugin extends core_1.rspack.ProgressPlugin {
116
- _logger;
117
- _state = {};
118
- constructor({ logger }) {
119
- super();
120
- this._logger = logger;
121
- }
122
- handler = (percent, message, ...details) => {
123
- const progress = Math.floor(percent * 100);
124
- this._logger.status(`${this._logger.colors.green(`${progress}%`)} - ${this._logger.colors.yellow(message)}${details.length > 0 ? `: ${this._logger.colors.dim(...details)}` : ''}`);
125
- };
126
- apply(compiler) {
127
- super.apply(compiler);
128
- hook(compiler, 'compile', () => {
129
- this._logger.message('Start compilation');
130
- this._logger.message(`rspack v${compiler.rspack.rspackVersion}`);
131
- this._state.start = process.hrtime.bigint();
132
- });
133
- hook(compiler, 'invalid', (fileName, changeTime) => {
134
- this._logger.verbose(`Invalidate file: ${fileName} at ${changeTime}`);
135
- });
136
- hook(compiler, 'done', (stats) => {
137
- const time = this._state.start ? ' in ' + (0, pretty_time_1.elapsedTime)(this._state.start) : '';
138
- const hasErrors = stats.hasErrors();
139
- if (hasErrors) {
140
- this._logger.error('Compiled with some errors' + time);
141
- }
142
- else {
143
- this._logger.success('Compiled successfully' + time);
144
- }
145
- });
146
- }
147
- }
148
- exports.RspackProgressPlugin = RspackProgressPlugin;
149
- function hook(compiler, hookName, callback) {
150
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
151
- compiler.hooks[hookName].tap(`app-builder: ${hookName}`, callback);
152
- }
153
- function rspackCompilerHandlerFactory(logger, onCompilationEnd) {
154
- return async (err, stats) => {
155
- if (err) {
156
- logger.panic(err.message, err);
157
- }
158
- if (stats) {
159
- logger.message('Stats:\n' +
160
- stats.toString({
161
- preset: 'errors-warnings',
162
- colors: process.stdout.isTTY,
163
- assets: logger.isVerbose,
164
- modules: logger.isVerbose,
165
- entrypoints: logger.isVerbose,
166
- timings: logger.isVerbose,
167
- }));
168
- if (stats.hasErrors()) {
169
- process.exit(1);
170
- }
171
- }
172
- if (onCompilationEnd) {
173
- await onCompilationEnd();
174
- }
175
- const [clientStats, ssrStats] = stats?.stats ?? [];
176
- if (clientStats) {
177
- const { startTime = 0, endTime = 0 } = clientStats;
178
- const time = endTime - startTime;
179
- logger.success(`Client was successfully compiled in ${(0, pretty_time_1.prettyTime)(BigInt(time) * BigInt(1_000_000))}`);
180
- }
181
- if (ssrStats) {
182
- const { startTime = 0, endTime = 0 } = ssrStats;
183
- const time = endTime - startTime;
184
- logger.success(`SSR: Client was successfully compiled in ${(0, pretty_time_1.prettyTime)(BigInt(time) * BigInt(1_000_000))}`);
185
- }
186
- if (!clientStats && !ssrStats) {
187
- logger.success(`Client was successfully compiled`);
188
- }
189
- };
190
- }
@@ -1,6 +1,7 @@
1
1
  import type * as Webpack from 'webpack';
2
2
  import type { Logger } from '../logger';
3
- export declare function webpackCompilerHandlerFactory(logger: Logger, onCompilationEnd?: () => void): (err?: Error | null, stats?: Webpack.MultiStats) => Promise<void>;
3
+ import { MultiStats } from '@rspack/core';
4
+ export declare function compilerHandlerFactory(logger: Logger, onCompilationEnd?: () => void): (err?: Error | null, stats?: Webpack.MultiStats | MultiStats) => Promise<void>;
4
5
  export declare function resolveTsConfigPathsToAlias(projectPath: string, filename?: string): {
5
6
  aliases?: undefined;
6
7
  modules?: undefined;
@@ -23,13 +23,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.webpackCompilerHandlerFactory = webpackCompilerHandlerFactory;
26
+ exports.compilerHandlerFactory = compilerHandlerFactory;
27
27
  exports.resolveTsConfigPathsToAlias = resolveTsConfigPathsToAlias;
28
28
  const path = __importStar(require("node:path"));
29
29
  const ts = __importStar(require("typescript"));
30
30
  const pretty_time_1 = require("../logger/pretty-time");
31
31
  const utils_1 = require("../typescript/utils");
32
- function webpackCompilerHandlerFactory(logger, onCompilationEnd) {
32
+ function compilerHandlerFactory(logger, onCompilationEnd) {
33
33
  return async (err, stats) => {
34
34
  if (err) {
35
35
  logger.panic(err.message, err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/app-builder",
3
- "version": "0.15.1-beta.3",
3
+ "version": "0.15.1-beta.4",
4
4
  "description": "Develop and build your React client-server projects, powered by typescript and webpack",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",