@gravity-ui/app-builder 0.15.1-beta.1 → 0.15.1-beta.2
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/dist/common/models/index.d.ts +1 -1
- package/dist/common/webpack/compile.js +6 -3
- package/dist/common/webpack/config.js +16 -2
- package/dist/common/webpack/rspack.d.ts +11 -0
- package/dist/common/webpack/rspack.js +80 -1
- package/dist/create-cli.d.ts +4 -4
- package/dist/create-cli.js +1 -1
- package/package.json +3 -1
|
@@ -128,7 +128,7 @@ export interface ClientConfig {
|
|
|
128
128
|
svgr?: SvgrConfig;
|
|
129
129
|
entryFilter?: string[];
|
|
130
130
|
excludeFromClean?: string[];
|
|
131
|
-
analyzeBundle?: 'true' | 'statoscope';
|
|
131
|
+
analyzeBundle?: 'true' | 'statoscope' | 'rsdoctor';
|
|
132
132
|
statoscopeConfig?: Partial<StatoscopeOptions>;
|
|
133
133
|
reactProfiling?: boolean;
|
|
134
134
|
/**
|
|
@@ -9,6 +9,7 @@ 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");
|
|
12
13
|
async function clientCompile(config) {
|
|
13
14
|
const logger = new logger_1.Logger('client', config.verbose);
|
|
14
15
|
const webpackConfigs = [];
|
|
@@ -41,17 +42,19 @@ async function clientCompile(config) {
|
|
|
41
42
|
logger.verbose('Config created');
|
|
42
43
|
return new Promise((resolve) => {
|
|
43
44
|
const compiler = config.bundler === 'rspack'
|
|
44
|
-
? (0, core_1.rspack)(rspackConfigs)
|
|
45
|
+
? (0, core_1.rspack)(rspackConfigs, (0, rspack_1.rspackCompilerHandlerFactory)(logger, async () => {
|
|
46
|
+
resolve();
|
|
47
|
+
}))
|
|
45
48
|
: (0, webpack_1.default)(webpackConfigs, (0, utils_1.webpackCompilerHandlerFactory)(logger, async () => {
|
|
46
49
|
resolve();
|
|
47
50
|
}));
|
|
48
51
|
process.on('SIGINT', async () => {
|
|
49
|
-
compiler
|
|
52
|
+
compiler?.close(() => {
|
|
50
53
|
process.exit(1);
|
|
51
54
|
});
|
|
52
55
|
});
|
|
53
56
|
process.on('SIGTERM', async () => {
|
|
54
|
-
compiler
|
|
57
|
+
compiler?.close(() => {
|
|
55
58
|
process.exit(1);
|
|
56
59
|
});
|
|
57
60
|
});
|
|
@@ -774,7 +774,6 @@ function configureCommonPlugins(options) {
|
|
|
774
774
|
...excludeFromClean,
|
|
775
775
|
],
|
|
776
776
|
}),
|
|
777
|
-
...(options.logger ? [new progress_plugin_1.ProgressPlugin({ logger: options.logger })] : []),
|
|
778
777
|
];
|
|
779
778
|
if (config.detectCircularDependencies) {
|
|
780
779
|
let circularPluginOptions = {
|
|
@@ -824,6 +823,7 @@ function configureWebpackPlugins(options) {
|
|
|
824
823
|
const forkTsCheckerOptions = getForkTsCheckerOptions(options);
|
|
825
824
|
const webpackPlugins = [
|
|
826
825
|
...configureCommonPlugins(options),
|
|
826
|
+
...(options.logger ? [new progress_plugin_1.ProgressPlugin({ logger: options.logger })] : []),
|
|
827
827
|
new webpack.DefinePlugin(getDefinitions(options)),
|
|
828
828
|
new webpack_manifest_plugin_1.WebpackManifestPlugin({
|
|
829
829
|
writeToFileEmit: true,
|
|
@@ -858,6 +858,12 @@ function configureWebpackPlugins(options) {
|
|
|
858
858
|
...customStatoscopeConfig,
|
|
859
859
|
}));
|
|
860
860
|
}
|
|
861
|
+
if (config.analyzeBundle === 'rsdoctor') {
|
|
862
|
+
const { RsdoctorWebpackPlugin } = require('@rsdoctor/webpack-plugin');
|
|
863
|
+
webpackPlugins.push(new RsdoctorWebpackPlugin({
|
|
864
|
+
mode: 'brief',
|
|
865
|
+
}));
|
|
866
|
+
}
|
|
861
867
|
}
|
|
862
868
|
if (!isSsr) {
|
|
863
869
|
const contextReplacements = getContextReplacements(options);
|
|
@@ -881,6 +887,7 @@ function configureRspackPlugins(options) {
|
|
|
881
887
|
const forkTsCheckerOptions = getForkTsCheckerOptions(options);
|
|
882
888
|
const rspackPlugins = [
|
|
883
889
|
...configureCommonPlugins(options),
|
|
890
|
+
...(options.logger ? [new rspack_1.RspackProgressPlugin({ logger: options.logger })] : []),
|
|
884
891
|
new core_1.rspack.DefinePlugin(getDefinitions(options)),
|
|
885
892
|
new rspack_manifest_plugin_1.RspackManifestPlugin({
|
|
886
893
|
fileName: isEnvProduction
|
|
@@ -896,7 +903,14 @@ function configureRspackPlugins(options) {
|
|
|
896
903
|
if (isEnvProduction || isSsr || config.ssr) {
|
|
897
904
|
rspackPlugins.push(new core_1.CssExtractRspackPlugin(getCssExtractPluginOptions(options)));
|
|
898
905
|
}
|
|
899
|
-
|
|
906
|
+
if (isEnvProduction) {
|
|
907
|
+
if (config.analyzeBundle === 'rsdoctor') {
|
|
908
|
+
const { RsdoctorRspackPlugin } = require('@rsdoctor/rspack-plugin');
|
|
909
|
+
rspackPlugins.push(new RsdoctorRspackPlugin({
|
|
910
|
+
mode: 'brief',
|
|
911
|
+
}));
|
|
912
|
+
}
|
|
913
|
+
}
|
|
900
914
|
if (!isSsr) {
|
|
901
915
|
const contextReplacements = getContextReplacements(options);
|
|
902
916
|
contextReplacements.forEach(({ resourceRegExp, newResource }) => rspackPlugins.push(new core_1.rspack.ContextReplacementPlugin(resourceRegExp, newResource)));
|
|
@@ -1,7 +1,18 @@
|
|
|
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';
|
|
3
4
|
import type { Configuration, RuleSetRule as RspackRuleSetRule } from '@rspack/core';
|
|
4
5
|
import type { Logger } from '../logger';
|
|
5
6
|
export declare function clearCacheDirectory(config: Configuration, logger: Logger): void;
|
|
6
7
|
export declare const generateAssetsManifest: ManifestPluginOptions['generate'];
|
|
7
8
|
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,9 +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.generateAssetsManifest = void 0;
|
|
29
|
+
exports.RspackProgressPlugin = 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");
|
|
32
34
|
const fs = __importStar(require("node:fs"));
|
|
33
35
|
const path = __importStar(require("node:path"));
|
|
34
36
|
const paths_1 = __importDefault(require("../../common/paths"));
|
|
@@ -109,3 +111,80 @@ function prepareRspackRules(webpackRules) {
|
|
|
109
111
|
}
|
|
110
112
|
return rspackRules;
|
|
111
113
|
}
|
|
114
|
+
const pretty_time_1 = require("../logger/pretty-time");
|
|
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
|
+
}
|
package/dist/create-cli.d.ts
CHANGED
|
@@ -19,8 +19,8 @@ export declare function createCli(argv: string[]): {
|
|
|
19
19
|
"lazy-compilation": boolean | undefined;
|
|
20
20
|
reactProfiling: boolean | undefined;
|
|
21
21
|
"react-profiling": boolean | undefined;
|
|
22
|
-
analyzeBundle: "true" | "statoscope" | undefined;
|
|
23
|
-
"analyze-bundle": "true" | "statoscope" | undefined;
|
|
22
|
+
analyzeBundle: "true" | "statoscope" | "rsdoctor" | undefined;
|
|
23
|
+
"analyze-bundle": "true" | "statoscope" | "rsdoctor" | undefined;
|
|
24
24
|
disableSourceMapGeneration: boolean | undefined;
|
|
25
25
|
"disable-source-map-generation": boolean | undefined;
|
|
26
26
|
"debug-webpack": boolean | undefined;
|
|
@@ -47,8 +47,8 @@ export declare function createCli(argv: string[]): {
|
|
|
47
47
|
"lazy-compilation": boolean | undefined;
|
|
48
48
|
reactProfiling: boolean | undefined;
|
|
49
49
|
"react-profiling": boolean | undefined;
|
|
50
|
-
analyzeBundle: "true" | "statoscope" | undefined;
|
|
51
|
-
"analyze-bundle": "true" | "statoscope" | undefined;
|
|
50
|
+
analyzeBundle: "true" | "statoscope" | "rsdoctor" | undefined;
|
|
51
|
+
"analyze-bundle": "true" | "statoscope" | "rsdoctor" | undefined;
|
|
52
52
|
disableSourceMapGeneration: boolean | undefined;
|
|
53
53
|
"disable-source-map-generation": boolean | undefined;
|
|
54
54
|
"debug-webpack": boolean | undefined;
|
package/dist/create-cli.js
CHANGED
|
@@ -176,7 +176,7 @@ function createCli(argv) {
|
|
|
176
176
|
.option('analyze-bundle', {
|
|
177
177
|
group: 'Client',
|
|
178
178
|
describe: 'Analyze bundle',
|
|
179
|
-
choices: ['true', 'statoscope'],
|
|
179
|
+
choices: ['true', 'statoscope', 'rsdoctor'],
|
|
180
180
|
})
|
|
181
181
|
.option('disable-fork-ts-checker', {
|
|
182
182
|
group: 'Client',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravity-ui/app-builder",
|
|
3
|
-
"version": "0.15.1-beta.
|
|
3
|
+
"version": "0.15.1-beta.2",
|
|
4
4
|
"description": "Develop and build your React client-server projects, powered by typescript and webpack",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -70,6 +70,8 @@
|
|
|
70
70
|
"@babel/runtime": "^7.26.0",
|
|
71
71
|
"@okikio/sharedworker": "^1.0.7",
|
|
72
72
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
|
|
73
|
+
"@rsdoctor/rspack-plugin": "^0.4.13",
|
|
74
|
+
"@rsdoctor/webpack-plugin": "^0.4.13",
|
|
73
75
|
"@rspack/core": "^1.2.2",
|
|
74
76
|
"@rspack/dev-server": "^1.0.10",
|
|
75
77
|
"@rspack/plugin-react-refresh": "^1.0.0",
|