@gravity-ui/app-builder 0.18.0 → 0.19.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.
@@ -40,7 +40,6 @@ const dev_server_1 = require("@rspack/dev-server");
40
40
  const paths_1 = __importDefault(require("../../common/paths"));
41
41
  const logger_1 = require("../../common/logger");
42
42
  const config_1 = require("../../common/webpack/config");
43
- const rspack_1 = require("../../common/webpack/rspack");
44
43
  async function watchClientCompilation(config, onManifestReady) {
45
44
  const clientCompilation = await buildDevServer(config);
46
45
  const compiler = clientCompilation.compiler;
@@ -173,8 +172,6 @@ async function buildDevServer(config) {
173
172
  // Pass a single config to avoid multicompiler when SSR disabled.
174
173
  const compiler = (0, core_1.rspack)(isSsr ? rspackConfigs : rspackConfigs[0]);
175
174
  server = new dev_server_1.RspackDevServer(options, compiler);
176
- // Need to clean cache before start. https://github.com/web-infra-dev/rspack/issues/9025
177
- (0, rspack_1.clearCacheDirectory)(rspackConfigs[0], logger);
178
175
  }
179
176
  else {
180
177
  const compiler = (0, webpack_1.default)(webpackConfigs);
@@ -3,7 +3,7 @@ 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
5
  import type { Configuration, DefinePlugin, FileCacheOptions, MemoryCacheOptions } from 'webpack';
6
- import type { Configuration as RspackConfiguration } from '@rspack/core';
6
+ import type { Configuration as RspackConfiguration, SwcJsMinimizerRspackPluginOptions } from '@rspack/core';
7
7
  import type * as Babel from '@babel/core';
8
8
  import type * as Swc from '@swc/core';
9
9
  import type { ServerConfiguration } from 'webpack-dev-server';
@@ -214,6 +214,11 @@ export interface ClientConfig {
214
214
  * Modify or return a custom [Terser options](https://github.com/terser/terser#minify-options).
215
215
  */
216
216
  terser?: (options: TerserOptions) => TerserOptions;
217
+ /**
218
+ * Modify or return a custom [SWC minification options](https://swc.rs/docs/configuration/minification).
219
+ * Available with rspack bundler.
220
+ */
221
+ swcMinimizerOptions?: (options: SwcJsMinimizerRspackPluginOptions) => SwcJsMinimizerRspackPluginOptions;
217
222
  ssr?: {
218
223
  noExternal?: string | RegExp | (string | RegExp)[] | true;
219
224
  moduleType?: 'commonjs' | 'esm';
@@ -273,7 +273,7 @@ function configureRspackExperiments({ config, isEnvProduction, isSsr, }) {
273
273
  },
274
274
  test(module) {
275
275
  // make sure that lazy-client.js won't be lazy compiled)
276
- return !module.nameForCondition().endsWith('lazy-client.js');
276
+ return !module.nameForCondition()?.endsWith('lazy-client.js');
277
277
  },
278
278
  };
279
279
  }
@@ -1109,23 +1109,25 @@ function configureRspackOptimization(helperOptions) {
1109
1109
  },
1110
1110
  });
1111
1111
  }
1112
+ let swcMinifyOptions = {
1113
+ minimizerOptions: {
1114
+ mangle: !config.reactProfiling,
1115
+ compress: {
1116
+ passes: 2,
1117
+ },
1118
+ format: {
1119
+ safari10: config.safari10,
1120
+ },
1121
+ },
1122
+ };
1123
+ const { swcMinimizerOptions } = config;
1124
+ if (typeof swcMinimizerOptions === 'function') {
1125
+ swcMinifyOptions = swcMinimizerOptions(swcMinifyOptions);
1126
+ }
1112
1127
  const optimization = {
1113
1128
  splitChunks: getOptimizationSplitChunks(helperOptions),
1114
1129
  runtimeChunk: 'single',
1115
- minimizer: [
1116
- new core_1.rspack.SwcJsMinimizerRspackPlugin({
1117
- minimizerOptions: {
1118
- mangle: !config.reactProfiling,
1119
- compress: {
1120
- passes: 2,
1121
- },
1122
- format: {
1123
- safari10: config.safari10,
1124
- },
1125
- },
1126
- }),
1127
- cssMinimizer,
1128
- ],
1130
+ minimizer: [new core_1.rspack.SwcJsMinimizerRspackPlugin(swcMinifyOptions), cssMinimizer],
1129
1131
  };
1130
1132
  return optimization;
1131
1133
  }
@@ -1,5 +1,2 @@
1
1
  import { ManifestPluginOptions } from 'rspack-manifest-plugin';
2
- import type { Configuration } from '@rspack/core';
3
- import type { Logger } from '../logger';
4
- export declare function clearCacheDirectory(config: Configuration, logger: Logger): void;
5
2
  export declare const generateAssetsManifest: ManifestPluginOptions['generate'];
@@ -1,51 +1,6 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
2
  Object.defineProperty(exports, "__esModule", { value: true });
29
3
  exports.generateAssetsManifest = void 0;
30
- exports.clearCacheDirectory = clearCacheDirectory;
31
- const fs = __importStar(require("node:fs"));
32
- const path = __importStar(require("node:path"));
33
- const paths_1 = __importDefault(require("../../common/paths"));
34
- function clearCacheDirectory(config, logger) {
35
- if (!config.cache) {
36
- return;
37
- }
38
- let cacheDirectory = path.join(paths_1.default.appNodeModules, '.cache/rspack');
39
- if (typeof config.experiments?.cache === 'object' &&
40
- config.experiments.cache.type === 'persistent' &&
41
- config.experiments.cache.storage?.directory) {
42
- cacheDirectory = config.experiments.cache.storage?.directory;
43
- }
44
- if (fs.existsSync(cacheDirectory)) {
45
- fs.rmdirSync(cacheDirectory, { recursive: true });
46
- logger.message(`Rspack cache ${cacheDirectory} successfully cleared`);
47
- }
48
- }
49
4
  const generateAssetsManifest = (seed, files, entries) => {
50
5
  const manifestFiles = files.reduce((manifest, file) => {
51
6
  manifest[file.name] = file.path;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/app-builder",
3
- "version": "0.18.0",
3
+ "version": "0.19.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",
@@ -72,7 +72,7 @@
72
72
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
73
73
  "@rsdoctor/rspack-plugin": "^0.4.13",
74
74
  "@rsdoctor/webpack-plugin": "^0.4.13",
75
- "@rspack/core": "1.2.3",
75
+ "@rspack/core": "1.2.6",
76
76
  "@rspack/dev-server": "^1.0.10",
77
77
  "@rspack/plugin-react-refresh": "^1.0.1",
78
78
  "@statoscope/webpack-plugin": "^5.28.2",
@@ -121,7 +121,7 @@
121
121
  "react-refresh": "^0.14.2",
122
122
  "resolve-url-loader": "^5.0.0",
123
123
  "rimraf": "^5.0.7",
124
- "rspack-manifest-plugin": "^5.0.1",
124
+ "rspack-manifest-plugin": "^5.0.3",
125
125
  "sass": "^1.79.0",
126
126
  "sass-loader": "^16.0.0",
127
127
  "semver": "^7.6.3",