@gravity-ui/app-builder 0.24.0 → 0.24.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.
|
@@ -57,7 +57,6 @@ const s3_upload_1 = require("../s3-upload");
|
|
|
57
57
|
const log_config_1 = require("../logger/log-config");
|
|
58
58
|
const utils_2 = require("../typescript/utils");
|
|
59
59
|
const node_externals_1 = require("./node-externals");
|
|
60
|
-
const statoscope_1 = require("./statoscope");
|
|
61
60
|
const imagesSizeLimit = 2048;
|
|
62
61
|
const fontSizeLimit = 8192;
|
|
63
62
|
function getHelperOptions({ webpackMode, config, logger, isSsr = false, configPath, }) {
|
|
@@ -936,7 +935,7 @@ function configureCommonPlugins(options, bundlerPlugins) {
|
|
|
936
935
|
}
|
|
937
936
|
if (config.analyzeBundle === 'statoscope') {
|
|
938
937
|
const customStatoscopeConfig = config.statoscopeConfig || {};
|
|
939
|
-
|
|
938
|
+
plugins.push(new webpack_plugin_1.default({
|
|
940
939
|
saveReportTo: path.resolve(options.buildDirectory, 'report.html'),
|
|
941
940
|
saveStatsTo: path.resolve(options.buildDirectory, 'stats.json'),
|
|
942
941
|
open: false,
|
|
@@ -944,14 +943,7 @@ function configureCommonPlugins(options, bundlerPlugins) {
|
|
|
944
943
|
all: true,
|
|
945
944
|
},
|
|
946
945
|
...customStatoscopeConfig,
|
|
947
|
-
});
|
|
948
|
-
// TIP: statoscope doesn't support rspack, but this workaround helps to run it
|
|
949
|
-
if (config.bundler === 'rspack') {
|
|
950
|
-
const compressor = statoscopePlugin.options.compressor;
|
|
951
|
-
statoscopePlugin.extensions =
|
|
952
|
-
compressor === false ? [] : [new statoscope_1.RspackCompressedExtension(compressor)];
|
|
953
|
-
}
|
|
954
|
-
plugins.push(statoscopePlugin);
|
|
946
|
+
}));
|
|
955
947
|
}
|
|
956
948
|
if (config.analyzeBundle === 'rsdoctor') {
|
|
957
949
|
plugins.push(new bundlerPlugins.RSDoctorPlugin({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravity-ui/app-builder",
|
|
3
|
-
"version": "0.24.0",
|
|
3
|
+
"version": "0.24.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",
|
|
@@ -75,10 +75,10 @@
|
|
|
75
75
|
"@rspack/core": "1.2.8",
|
|
76
76
|
"@rspack/dev-server": "^1.0.10",
|
|
77
77
|
"@rspack/plugin-react-refresh": "^1.0.1",
|
|
78
|
-
"@statoscope/webpack-plugin": "^5.
|
|
78
|
+
"@statoscope/webpack-plugin": "^5.29.0",
|
|
79
79
|
"@statoscope/stats": "^5.28.1",
|
|
80
80
|
"@statoscope/stats-extension-compressed": "^5.28.1",
|
|
81
|
-
"@statoscope/webpack-model": "^5.
|
|
81
|
+
"@statoscope/webpack-model": "^5.29.0",
|
|
82
82
|
"@svgr/core": "^8.1.0",
|
|
83
83
|
"@svgr/plugin-jsx": "^8.1.0",
|
|
84
84
|
"@svgr/webpack": "^8.1.0",
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Compiler } from 'webpack';
|
|
2
|
-
import { ExtensionDescriptor } from '@statoscope/stats/spec/extension';
|
|
3
|
-
import CompressedExtensionGenerator, { CompressorOrPreset, Format, Payload } from '@statoscope/stats-extension-compressed/dist/generator';
|
|
4
|
-
import { StatsExtensionWebpackAdapter } from '@statoscope/webpack-model';
|
|
5
|
-
export declare class RspackCompressedExtension implements StatsExtensionWebpackAdapter<Payload> {
|
|
6
|
-
compressor: CompressorOrPreset;
|
|
7
|
-
descriptor: ExtensionDescriptor;
|
|
8
|
-
compressedExtensionGenerator: CompressedExtensionGenerator;
|
|
9
|
-
constructor(compressor: CompressorOrPreset);
|
|
10
|
-
getExtension(): Format;
|
|
11
|
-
handleCompiler(compiler: Compiler): void;
|
|
12
|
-
}
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.RspackCompressedExtension = void 0;
|
|
7
|
-
/* eslint-disable max-depth */
|
|
8
|
-
/**
|
|
9
|
-
* Adapted Statoscope extension @statoscope/webpack-stats-extension-compressed to support Rspack.
|
|
10
|
-
* This workaround will be removed once the pull request is merged into Statoscope:
|
|
11
|
-
* https://github.com/statoscope/statoscope/pull/239
|
|
12
|
-
*/
|
|
13
|
-
const path_1 = __importDefault(require("path"));
|
|
14
|
-
const util_1 = require("util");
|
|
15
|
-
const generator_1 = __importDefault(require("@statoscope/stats-extension-compressed/dist/generator"));
|
|
16
|
-
const name = '@statoscope/webpack-stats-extension-compressed';
|
|
17
|
-
const version = 'app-builder-version';
|
|
18
|
-
const pluginName = `${name}@${version}`;
|
|
19
|
-
class RspackCompressedExtension {
|
|
20
|
-
compressor;
|
|
21
|
-
descriptor = { name, version };
|
|
22
|
-
compressedExtensionGenerator = new generator_1.default(this.descriptor);
|
|
23
|
-
// eslint-disable-next-line @typescript-eslint/parameter-properties
|
|
24
|
-
constructor(compressor) {
|
|
25
|
-
this.compressor = compressor;
|
|
26
|
-
}
|
|
27
|
-
getExtension() {
|
|
28
|
-
return this.compressedExtensionGenerator.get();
|
|
29
|
-
}
|
|
30
|
-
handleCompiler(compiler) {
|
|
31
|
-
const isRspack = 'rspackVersion' in compiler.webpack;
|
|
32
|
-
const rspackCodeGenerationResults = new Map();
|
|
33
|
-
if (isRspack) {
|
|
34
|
-
compiler.hooks.thisCompilation.tap(pluginName, (compilation) => {
|
|
35
|
-
rspackCodeGenerationResults.clear();
|
|
36
|
-
compilation.hooks.executeModule.tap(pluginName, ({ moduleObject, codeGenerationResult }) => {
|
|
37
|
-
if (!moduleObject) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
rspackCodeGenerationResults.set(moduleObject.id, codeGenerationResult);
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
compiler.hooks.done.tapAsync(pluginName, async (stats, cb) => {
|
|
45
|
-
const stack = [stats.compilation];
|
|
46
|
-
let cursor;
|
|
47
|
-
while ((cursor = stack.pop())) {
|
|
48
|
-
stack.push(...cursor.children);
|
|
49
|
-
// webpack 4
|
|
50
|
-
let readFile = (0, util_1.promisify)(cursor.compiler.inputFileSystem.readFile.bind(cursor.compiler.inputFileSystem));
|
|
51
|
-
// webpack 5
|
|
52
|
-
if (cursor.compiler.outputFileSystem &&
|
|
53
|
-
typeof cursor.compiler.outputFileSystem.readFile === 'function') {
|
|
54
|
-
readFile = (0, util_1.promisify)(cursor.compiler.outputFileSystem.readFile.bind(cursor.compiler.outputFileSystem));
|
|
55
|
-
}
|
|
56
|
-
for (const name of Object.keys(cursor.assets)) {
|
|
57
|
-
const assetPath = path_1.default.join(cursor.compiler.outputPath, name);
|
|
58
|
-
let content;
|
|
59
|
-
try {
|
|
60
|
-
content = await readFile(assetPath);
|
|
61
|
-
if (!content) {
|
|
62
|
-
throw new Error();
|
|
63
|
-
}
|
|
64
|
-
this.compressedExtensionGenerator.handleResource(cursor.hash, name, content, this.compressor);
|
|
65
|
-
}
|
|
66
|
-
catch (e) {
|
|
67
|
-
console.warn(`Can't read the asset ${name}`);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
const modulesStack = [...cursor.modules];
|
|
71
|
-
let modulesCursor;
|
|
72
|
-
while ((modulesCursor = modulesStack.pop())) {
|
|
73
|
-
// @ts-ignore
|
|
74
|
-
if (modulesCursor.modules) {
|
|
75
|
-
// @ts-ignore
|
|
76
|
-
modulesStack.push(...modulesCursor.modules);
|
|
77
|
-
}
|
|
78
|
-
let concatenated = Buffer.from('');
|
|
79
|
-
if (modulesCursor.constructor.name === 'CssModule' &&
|
|
80
|
-
// @ts-ignore
|
|
81
|
-
(typeof modulesCursor.content === 'string' ||
|
|
82
|
-
// @ts-ignore
|
|
83
|
-
modulesCursor.content instanceof Buffer)) {
|
|
84
|
-
this.compressedExtensionGenerator.handleResource(cursor.hash, modulesCursor.identifier(),
|
|
85
|
-
// @ts-ignore
|
|
86
|
-
modulesCursor.content, this.compressor);
|
|
87
|
-
}
|
|
88
|
-
else if (cursor.chunkGraph) {
|
|
89
|
-
// webpack 5 and rspack
|
|
90
|
-
if (isRspack) {
|
|
91
|
-
// Identifier contains source type and path, but keys in rspackCodeGenerationResults don't contain the source type.
|
|
92
|
-
const id = modulesCursor.identifier().split('|')[1];
|
|
93
|
-
if (!id) {
|
|
94
|
-
continue;
|
|
95
|
-
}
|
|
96
|
-
const codeGenerationResult = rspackCodeGenerationResults.get(id);
|
|
97
|
-
if (!codeGenerationResult || !('get' in codeGenerationResult)) {
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
// @ts-ignore
|
|
101
|
-
const content = codeGenerationResult.get('javascript');
|
|
102
|
-
if (content) {
|
|
103
|
-
concatenated = Buffer.concat([
|
|
104
|
-
// @ts-ignore
|
|
105
|
-
concatenated,
|
|
106
|
-
// @ts-ignore
|
|
107
|
-
content instanceof Buffer ? content : Buffer.from(content),
|
|
108
|
-
]);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
for (const type of modulesCursor.getSourceTypes()) {
|
|
113
|
-
const runtimeChunk = cursor.chunkGraph
|
|
114
|
-
.getModuleChunks(modulesCursor)
|
|
115
|
-
.find((chunk) => chunk.runtime);
|
|
116
|
-
if (runtimeChunk) {
|
|
117
|
-
const source = cursor.codeGenerationResults.getSource(modulesCursor, runtimeChunk.runtime, type);
|
|
118
|
-
if (!source) {
|
|
119
|
-
continue;
|
|
120
|
-
}
|
|
121
|
-
const content = source.source();
|
|
122
|
-
concatenated = Buffer.concat([
|
|
123
|
-
// @ts-ignore
|
|
124
|
-
concatenated,
|
|
125
|
-
// @ts-ignore
|
|
126
|
-
content instanceof Buffer ? content : Buffer.from(content),
|
|
127
|
-
]);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
// webpack 4
|
|
134
|
-
try {
|
|
135
|
-
// @ts-ignore
|
|
136
|
-
const source = cursor.moduleTemplates.javascript.render(modulesCursor, cursor.dependencyTemplates, { chunk: modulesCursor.getChunks()[0] });
|
|
137
|
-
const content = source.source();
|
|
138
|
-
concatenated = Buffer.concat([
|
|
139
|
-
// @ts-ignore
|
|
140
|
-
concatenated,
|
|
141
|
-
// @ts-ignore
|
|
142
|
-
content instanceof Buffer ? content : Buffer.from(content),
|
|
143
|
-
]);
|
|
144
|
-
}
|
|
145
|
-
catch (e) {
|
|
146
|
-
// in webpack 4 we can't generate source for all the modules :(
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
if (!concatenated.length) {
|
|
150
|
-
continue;
|
|
151
|
-
}
|
|
152
|
-
this.compressedExtensionGenerator.handleResource(cursor.hash, modulesCursor.identifier(), concatenated, this.compressor);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
cb();
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
exports.RspackCompressedExtension = RspackCompressedExtension;
|