@gravity-ui/app-builder 0.11.3 → 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.
- package/README.md +3 -3
- package/dist/commands/dev/client.d.ts +2 -2
- package/dist/commands/dev/client.js +6 -6
- package/dist/common/config.js +4 -0
- package/dist/common/models/index.d.ts +11 -5
- package/dist/common/s3-upload/webpack-plugin.d.ts +1 -1
- package/dist/common/s3-upload/webpack-plugin.js +8 -4
- package/dist/common/webpack/compile.js +4 -7
- package/dist/common/webpack/config.d.ts +7 -5
- package/dist/common/webpack/config.js +110 -106
- package/dist/common/webpack/progress-plugin.d.ts +1 -1
- package/dist/common/webpack/progress-plugin.js +1 -1
- package/dist/common/webpack/storybook.d.ts +7 -7
- package/dist/common/webpack/storybook.js +6 -6
- package/dist/common/webpack/utils.d.ts +2 -2
- package/dist/common/webpack/utils.js +1 -1
- package/dist/create-cli.d.ts +4 -4
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -205,7 +205,7 @@ With this `{rootDir}/src/ui/tsconfig.json`:
|
|
|
205
205
|
- `options` (`import('https').ServerOptions`) — allow to provide your own certificate.
|
|
206
206
|
- `watchOptions` — a set of options used to customize watch mode, [more](https://webpack.js.org/configuration/watch/#watchoptions)
|
|
207
207
|
- `watchPackages` (`boolean`) - watch all changes in `node_modules`.
|
|
208
|
-
- `
|
|
208
|
+
- `reactRefresh` (`false | (options: ReactRefreshPluginOptions) => ReactRefreshPluginOptions`) — disable or configure `react-refresh` in dev mode, [more](https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/main/docs/API.md#options)
|
|
209
209
|
- `detectCircularDependencies` (`true | CircularDependenciesOptions`) - detect modules with circular dependencies, [more](https://github.com/aackerman/circular-dependency-plugin)
|
|
210
210
|
- `lazyCompilation` (`true | LazyCompilationConfig`) — enable experimental [lazy compilation](https://webpack.js.org/configuration/experiments/#experimentslazycompilation) feature
|
|
211
211
|
- `true` — enable feature
|
|
@@ -244,8 +244,8 @@ With this `{rootDir}/src/ui/tsconfig.json`:
|
|
|
244
244
|
|
|
245
245
|
- `monaco` (`object`) — use [monaco-editor-webpack-plugin](https://github.com/microsoft/monaco-editor/tree/main/webpack-plugin#monaco-editor-webpack-loader-plugin)
|
|
246
246
|
|
|
247
|
-
- `fileName` (`string`) — custom filename template for worker scripts
|
|
248
|
-
- `languages` (`string[]`) - include only a subset of the languages supported.
|
|
247
|
+
- `fileName` (`string`) — custom filename template for worker scripts.
|
|
248
|
+
- `languages` (`string[]`) - include only a subset of the languages supported. If you don't need support for all languages, set needed languages explicitly, since it may significantly affect build time.
|
|
249
249
|
- `features` (`string[]`) - include only a subset of the editor features.
|
|
250
250
|
- `customLanguages` (`IFeatureDefinition[]`) - include custom languages (outside of the ones shipped with the `monaco-editor`).
|
|
251
251
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
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<
|
|
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
|
|
33
|
-
const
|
|
34
|
-
const
|
|
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,
|
|
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,
|
|
115
|
-
const server = new
|
|
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
|
}
|
package/dist/common/config.js
CHANGED
|
@@ -28,6 +28,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.getProjectConfig = getProjectConfig;
|
|
30
30
|
exports.normalizeConfig = normalizeConfig;
|
|
31
|
+
/* eslint-disable complexity */
|
|
31
32
|
const path = __importStar(require("node:path"));
|
|
32
33
|
const lodash_1 = __importDefault(require("lodash"));
|
|
33
34
|
const cosmiconfig_1 = require("cosmiconfig");
|
|
@@ -183,6 +184,9 @@ async function normalizeClientConfig(client, mode) {
|
|
|
183
184
|
const normalizedConfig = {
|
|
184
185
|
...client,
|
|
185
186
|
forkTsChecker: client.disableForkTsChecker ? false : client.forkTsChecker,
|
|
187
|
+
reactRefresh: client.disableReactRefresh
|
|
188
|
+
? false
|
|
189
|
+
: client.reactRefresh ?? ((options) => options),
|
|
186
190
|
newJsxTransform: client.newJsxTransform ?? true,
|
|
187
191
|
publicPathPrefix: client.publicPathPrefix || '',
|
|
188
192
|
modules: client.modules && remapPaths(client.modules),
|
|
@@ -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,
|
|
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,6 +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 { PluginOptions as ReactRefreshPluginOptions } from '@rspack/plugin-react-refresh';
|
|
16
17
|
export interface Entities<T> {
|
|
17
18
|
data: Record<string, T>;
|
|
18
19
|
keys: string[];
|
|
@@ -129,9 +130,13 @@ export interface ClientConfig {
|
|
|
129
130
|
statoscopeConfig?: Partial<StatoscopeOptions>;
|
|
130
131
|
reactProfiling?: boolean;
|
|
131
132
|
/**
|
|
132
|
-
*
|
|
133
|
+
* Disable react-refresh in dev mode
|
|
134
|
+
*
|
|
135
|
+
* @deprecated use `reactRefresh: false` instead
|
|
133
136
|
*/
|
|
134
137
|
disableReactRefresh?: boolean;
|
|
138
|
+
/** Disable or configure react-refresh in dev mode */
|
|
139
|
+
reactRefresh?: false | ((options: ReactRefreshPluginOptions) => ReactRefreshPluginOptions);
|
|
135
140
|
/**
|
|
136
141
|
* Detect modules with circular dependencies
|
|
137
142
|
*/
|
|
@@ -153,7 +158,7 @@ export interface ClientConfig {
|
|
|
153
158
|
/**
|
|
154
159
|
* Add additional options to DefinePlugin
|
|
155
160
|
*/
|
|
156
|
-
definitions?:
|
|
161
|
+
definitions?: DefinePluginOptions;
|
|
157
162
|
watchOptions?: Configuration['watchOptions'] & {
|
|
158
163
|
/**
|
|
159
164
|
* watch changes in node_modules
|
|
@@ -166,7 +171,7 @@ export interface ClientConfig {
|
|
|
166
171
|
*/
|
|
167
172
|
newWebWorkerSyntax?: boolean;
|
|
168
173
|
babelCacheDirectory?: boolean | string;
|
|
169
|
-
cache?: boolean
|
|
174
|
+
cache?: boolean;
|
|
170
175
|
/** Use [Lighting CSS](https://lightningcss.dev) to transform and minimize css instead of PostCSS and cssnano*/
|
|
171
176
|
transformCssWithLightningCss?: boolean;
|
|
172
177
|
sentryConfig?: SentryWebpackPluginOptions;
|
|
@@ -213,7 +218,7 @@ export interface ServiceConfig {
|
|
|
213
218
|
lib?: never;
|
|
214
219
|
verbose?: boolean;
|
|
215
220
|
}
|
|
216
|
-
export type NormalizedClientConfig = Omit<ClientConfig, 'publicPathPrefix' | 'hiddenSourceMap' | 'svgr' | 'lazyCompilation' | 'devServer' | 'disableForkTsChecker'> & {
|
|
221
|
+
export type NormalizedClientConfig = Omit<ClientConfig, 'publicPathPrefix' | 'hiddenSourceMap' | 'svgr' | 'lazyCompilation' | 'devServer' | 'disableForkTsChecker' | 'disableReactRefresh'> & {
|
|
217
222
|
publicPathPrefix: string;
|
|
218
223
|
hiddenSourceMap: boolean;
|
|
219
224
|
svgr: NonNullable<ClientConfig['svgr']>;
|
|
@@ -230,6 +235,7 @@ export type NormalizedClientConfig = Omit<ClientConfig, 'publicPathPrefix' | 'hi
|
|
|
230
235
|
babel: (config: Babel.TransformOptions, options: {
|
|
231
236
|
configType: `${WebpackMode}`;
|
|
232
237
|
}) => Babel.TransformOptions | Promise<Babel.TransformOptions>;
|
|
238
|
+
reactRefresh: NonNullable<ClientConfig['reactRefresh']>;
|
|
233
239
|
};
|
|
234
240
|
export type NormalizedServerConfig = Omit<ServerConfig, 'port' | 'inspect' | 'inspectBrk'> & {
|
|
235
241
|
port?: number;
|
|
@@ -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(
|
|
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
|
-
|
|
43
|
-
|
|
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
|
|
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,
|
|
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
|
|
17
|
+
compiler?.close(() => {
|
|
21
18
|
process.exit(1);
|
|
22
19
|
});
|
|
23
20
|
});
|
|
24
21
|
process.on('SIGTERM', async () => {
|
|
25
|
-
compiler
|
|
22
|
+
compiler?.close(() => {
|
|
26
23
|
process.exit(1);
|
|
27
24
|
});
|
|
28
25
|
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import
|
|
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<
|
|
18
|
-
export declare function configureModuleRules(helperOptions: HelperOptions, additionalRules?: NonNullable<
|
|
19
|
-
export declare function configureResolve({ isEnvProduction, config }: HelperOptions):
|
|
20
|
-
type Optimization = NonNullable<
|
|
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
|
|
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
|
|
43
|
-
const
|
|
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
|
-
|
|
129
|
+
// TODO с воркерами разобраться
|
|
130
|
+
// createWorkerRule(helperOptions),
|
|
108
131
|
createJavaScriptRule(helperOptions, jsLoader),
|
|
109
132
|
createStylesRule(helperOptions),
|
|
110
133
|
createSassStylesRule(helperOptions),
|
|
@@ -223,7 +246,7 @@ function configureOutput({ isEnvDevelopment, ...rest }) {
|
|
|
223
246
|
}
|
|
224
247
|
function createJavaScriptLoader({ isEnvProduction, isEnvDevelopment, configType, config, }) {
|
|
225
248
|
const plugins = [];
|
|
226
|
-
if (isEnvDevelopment &&
|
|
249
|
+
if (isEnvDevelopment && config.reactRefresh !== false) {
|
|
227
250
|
plugins.push([
|
|
228
251
|
require.resolve('react-refresh/babel'),
|
|
229
252
|
config.devServer?.webSocketPath
|
|
@@ -286,27 +309,29 @@ function createSourceMapRules(shouldUseSourceMap) {
|
|
|
286
309
|
}
|
|
287
310
|
return [];
|
|
288
311
|
}
|
|
289
|
-
|
|
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
|
-
|
|
297
|
-
|
|
320
|
+
loader: require.resolve('./worker/worker-loader'),
|
|
321
|
+
}
|
|
298
322
|
: {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
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(
|
|
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
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
...
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
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
|
-
|
|
543
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
}
|
|
@@ -564,12 +585,14 @@ function configurePlugins(options) {
|
|
|
564
585
|
publicPath: path.normalize(config.publicPathPrefix + '/build/'),
|
|
565
586
|
}));
|
|
566
587
|
}
|
|
567
|
-
if (isEnvDevelopment &&
|
|
568
|
-
const {
|
|
569
|
-
|
|
570
|
-
|
|
588
|
+
if (isEnvDevelopment && config.reactRefresh !== false) {
|
|
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
|
}
|
|
574
597
|
if (config.detectCircularDependencies) {
|
|
575
598
|
let circularPluginOptions = {
|
|
@@ -596,10 +619,10 @@ function configurePlugins(options) {
|
|
|
596
619
|
}));
|
|
597
620
|
}
|
|
598
621
|
if (config.polyfill?.process) {
|
|
599
|
-
plugins.push(new
|
|
622
|
+
plugins.push(new core_1.rspack.ProvidePlugin({ process: 'process/browser.js' }));
|
|
600
623
|
}
|
|
601
624
|
if (isEnvProduction) {
|
|
602
|
-
plugins.push(new
|
|
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
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
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
|
-
(
|
|
732
|
-
|
|
733
|
-
|
|
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
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
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;
|
|
@@ -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("
|
|
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
|
|
3
|
+
import * as rspack from '@rspack/core';
|
|
4
4
|
type Mode = `${WebpackMode}`;
|
|
5
|
-
export declare function configureServiceWebpackConfig(mode: Mode, storybookConfig:
|
|
6
|
-
type ModuleRule = NonNullable<NonNullable<
|
|
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:
|
|
9
|
+
rules: rspack.RuleSetRule[];
|
|
10
10
|
};
|
|
11
|
-
resolve:
|
|
12
|
-
plugins:
|
|
11
|
+
resolve: rspack.ResolveOptions;
|
|
12
|
+
plugins: rspack.Plugins;
|
|
13
13
|
optimization: {
|
|
14
|
-
minimizer: (
|
|
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
|
|
123
|
-
plugins.push(new
|
|
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
|
}
|
|
@@ -133,8 +132,9 @@ function configurePlugins({ isEnvDevelopment, isEnvProduction, config }) {
|
|
|
133
132
|
publicPath: '/',
|
|
134
133
|
}));
|
|
135
134
|
}
|
|
136
|
-
if (isEnvDevelopment &&
|
|
137
|
-
|
|
135
|
+
if (isEnvDevelopment && config.reactRefresh !== false) {
|
|
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
|
|
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?:
|
|
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 {
|
package/dist/create-cli.d.ts
CHANGED
|
@@ -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.
|
|
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": {
|