@gravity-ui/app-builder 0.15.1-beta.3 → 0.15.1-beta.5
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/commands/dev/client.js +2 -2
- package/dist/common/library/index.js +0 -1
- package/dist/common/models/index.d.ts +1 -0
- package/dist/common/webpack/compile.js +5 -7
- package/dist/common/webpack/config.js +145 -105
- package/dist/common/webpack/progress-plugin.d.ts +24 -9
- package/dist/common/webpack/progress-plugin.js +42 -38
- package/dist/common/webpack/rspack.d.ts +0 -11
- package/dist/common/webpack/rspack.js +1 -80
- package/dist/common/webpack/utils.d.ts +2 -1
- package/dist/common/webpack/utils.js +2 -2
- package/package.json +2 -1
|
@@ -64,7 +64,7 @@ async function buildDevServer(config) {
|
|
|
64
64
|
}),
|
|
65
65
|
];
|
|
66
66
|
if (isSsr) {
|
|
67
|
-
const ssrLogger = new logger_1.Logger('
|
|
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('
|
|
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,
|
|
46
|
-
|
|
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);
|
|
@@ -40,12 +40,12 @@ const fork_ts_checker_webpack_plugin_1 = __importDefault(require("fork-ts-checke
|
|
|
40
40
|
const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
|
|
41
41
|
const webpack_bundle_analyzer_1 = require("webpack-bundle-analyzer");
|
|
42
42
|
const webpack_assets_manifest_1 = __importDefault(require("webpack-assets-manifest"));
|
|
43
|
+
const rspack_manifest_plugin_1 = require("rspack-manifest-plugin");
|
|
43
44
|
const react_refresh_webpack_plugin_1 = __importDefault(require("@pmmmwh/react-refresh-webpack-plugin"));
|
|
44
45
|
const moment_timezone_data_webpack_plugin_1 = __importDefault(require("moment-timezone-data-webpack-plugin"));
|
|
45
46
|
const webpack_plugin_1 = __importDefault(require("@statoscope/webpack-plugin"));
|
|
46
47
|
const circular_dependency_plugin_1 = __importDefault(require("circular-dependency-plugin"));
|
|
47
48
|
const core_1 = require("@rspack/core");
|
|
48
|
-
const rspack_manifest_plugin_1 = require("rspack-manifest-plugin");
|
|
49
49
|
const rspack_1 = require("./rspack");
|
|
50
50
|
const ts_checker_rspack_plugin_1 = require("ts-checker-rspack-plugin");
|
|
51
51
|
const plugin_react_refresh_1 = __importDefault(require("@rspack/plugin-react-refresh"));
|
|
@@ -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:
|
|
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:
|
|
153
|
+
externals: configureExternals(helperOptions),
|
|
166
154
|
node: config.node,
|
|
167
155
|
watchOptions: configureWatchOptions(helperOptions),
|
|
168
156
|
ignoreWarnings: [/Failed to parse source map/],
|
|
@@ -381,19 +369,54 @@ 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, }) {
|
|
373
|
+
if (config.codeLoader === 'swc') {
|
|
374
|
+
return {
|
|
375
|
+
loader: 'builtin:swc-loader',
|
|
376
|
+
options: {
|
|
377
|
+
sourceMaps: !config.disableSourceMapGeneration,
|
|
378
|
+
env: {
|
|
379
|
+
loose: true,
|
|
380
|
+
bugfixes: true,
|
|
381
|
+
},
|
|
382
|
+
module: {
|
|
383
|
+
type: 'es6',
|
|
384
|
+
},
|
|
385
|
+
assumptions: {
|
|
386
|
+
setPublicClassFields: true,
|
|
387
|
+
privateFieldsAsProperties: true,
|
|
388
|
+
},
|
|
389
|
+
jsc: {
|
|
390
|
+
parser: {
|
|
391
|
+
syntax: 'typescript',
|
|
392
|
+
tsx: true,
|
|
393
|
+
},
|
|
394
|
+
transform: {
|
|
395
|
+
react: {
|
|
396
|
+
runtime: config.newJsxTransform ? 'automatic' : 'classic',
|
|
397
|
+
development: isEnvDevelopment,
|
|
398
|
+
refresh: !isSsr && isEnvDevelopment && config.reactRefresh !== false,
|
|
399
|
+
useBuiltIns: true,
|
|
400
|
+
},
|
|
401
|
+
},
|
|
402
|
+
experimental: {
|
|
403
|
+
plugins: !isSsr && isEnvProduction
|
|
404
|
+
? [
|
|
405
|
+
[
|
|
406
|
+
'@swc/plugin-transform-imports',
|
|
407
|
+
{
|
|
408
|
+
lodash: {
|
|
409
|
+
transform: 'lodash/{{member}}',
|
|
410
|
+
},
|
|
411
|
+
},
|
|
412
|
+
],
|
|
413
|
+
]
|
|
414
|
+
: [],
|
|
415
|
+
},
|
|
416
|
+
},
|
|
417
|
+
},
|
|
418
|
+
};
|
|
419
|
+
}
|
|
397
420
|
const plugins = [];
|
|
398
421
|
if (!isSsr) {
|
|
399
422
|
if (isEnvDevelopment && config.reactRefresh !== false) {
|
|
@@ -470,9 +493,7 @@ function createWorkerRule(options) {
|
|
|
470
493
|
loader: require.resolve('./worker/worker-loader'),
|
|
471
494
|
}
|
|
472
495
|
: {
|
|
473
|
-
loader: require.resolve(
|
|
474
|
-
? 'worker-rspack-loader'
|
|
475
|
-
: 'worker-loader'),
|
|
496
|
+
loader: require.resolve('worker-rspack-loader'),
|
|
476
497
|
// currently workers located on cdn are not working properly, so we are enforcing loading workers from
|
|
477
498
|
// service instead
|
|
478
499
|
options: {
|
|
@@ -518,7 +539,7 @@ function createStylesRule(options) {
|
|
|
518
539
|
function getCssLoaders({ isEnvDevelopment, isEnvProduction, config, isSsr }, additionalRules) {
|
|
519
540
|
const isRspack = config.bundler === 'rspack';
|
|
520
541
|
const loaders = [];
|
|
521
|
-
if (!config.transformCssWithLightningCss) {
|
|
542
|
+
if (!config.transformCssWithLightningCss && config.bundler !== 'rspack') {
|
|
522
543
|
loaders.push({
|
|
523
544
|
loader: require.resolve('postcss-loader'),
|
|
524
545
|
options: {
|
|
@@ -777,9 +798,41 @@ function getCssExtractPluginOptions({ isEnvProduction }) {
|
|
|
777
798
|
ignoreOrder: true,
|
|
778
799
|
};
|
|
779
800
|
}
|
|
801
|
+
const commonBundlerPlugins = {
|
|
802
|
+
DefinePlugin: {
|
|
803
|
+
rspack: core_1.rspack.DefinePlugin,
|
|
804
|
+
webpack: webpack.DefinePlugin,
|
|
805
|
+
},
|
|
806
|
+
ContextReplacementPlugin: {
|
|
807
|
+
rspack: core_1.rspack.ContextReplacementPlugin,
|
|
808
|
+
webpack: webpack.ContextReplacementPlugin,
|
|
809
|
+
},
|
|
810
|
+
ProvidePlugin: {
|
|
811
|
+
rspack: core_1.rspack.ProvidePlugin,
|
|
812
|
+
webpack: webpack.ProvidePlugin,
|
|
813
|
+
},
|
|
814
|
+
ProgressPlugin: {
|
|
815
|
+
rspack: progress_plugin_1.RspackProgressPlugin,
|
|
816
|
+
webpack: progress_plugin_1.WebpackProgressPlugin,
|
|
817
|
+
},
|
|
818
|
+
ManifestPlugin: {
|
|
819
|
+
rspack: rspack_manifest_plugin_1.RspackManifestPlugin,
|
|
820
|
+
webpack: webpack_manifest_plugin_1.WebpackManifestPlugin,
|
|
821
|
+
},
|
|
822
|
+
TsCheckerRspackPlugin: {
|
|
823
|
+
rspack: ts_checker_rspack_plugin_1.TsCheckerRspackPlugin,
|
|
824
|
+
webpack: fork_ts_checker_webpack_plugin_1.default,
|
|
825
|
+
},
|
|
826
|
+
CSSExtractPlugin: {
|
|
827
|
+
rspack: core_1.CssExtractRspackPlugin,
|
|
828
|
+
webpack: mini_css_extract_plugin_1.default,
|
|
829
|
+
},
|
|
830
|
+
};
|
|
780
831
|
function configureCommonPlugins(options) {
|
|
781
832
|
const { isEnvDevelopment, isEnvProduction, config, isSsr } = options;
|
|
782
833
|
const excludeFromClean = config.excludeFromClean || [];
|
|
834
|
+
const bundler = config.bundler;
|
|
835
|
+
const forkTsCheckerOptions = getForkTsCheckerOptions(options);
|
|
783
836
|
const plugins = [
|
|
784
837
|
new clean_webpack_plugin_1.CleanWebpackPlugin({
|
|
785
838
|
verbose: config.verbose,
|
|
@@ -789,6 +842,17 @@ function configureCommonPlugins(options) {
|
|
|
789
842
|
...excludeFromClean,
|
|
790
843
|
],
|
|
791
844
|
}),
|
|
845
|
+
new commonBundlerPlugins['ManifestPlugin'][bundler]({
|
|
846
|
+
writeToFileEmit: true,
|
|
847
|
+
publicPath: '',
|
|
848
|
+
}),
|
|
849
|
+
new commonBundlerPlugins['DefinePlugin'][bundler](getDefinitions(options)),
|
|
850
|
+
...(options.logger
|
|
851
|
+
? [new commonBundlerPlugins['ProgressPlugin'][bundler]({ logger: options.logger })]
|
|
852
|
+
: []),
|
|
853
|
+
...(forkTsCheckerOptions
|
|
854
|
+
? [new commonBundlerPlugins['TsCheckerRspackPlugin'][bundler](forkTsCheckerOptions)]
|
|
855
|
+
: []),
|
|
792
856
|
];
|
|
793
857
|
if (config.detectCircularDependencies) {
|
|
794
858
|
let circularPluginOptions = {
|
|
@@ -809,7 +873,17 @@ function configureCommonPlugins(options) {
|
|
|
809
873
|
}));
|
|
810
874
|
}
|
|
811
875
|
}
|
|
876
|
+
if (isEnvProduction || isSsr || config.ssr) {
|
|
877
|
+
plugins.push(new commonBundlerPlugins['CSSExtractPlugin'][bundler](getCssExtractPluginOptions(options)));
|
|
878
|
+
}
|
|
812
879
|
if (!isSsr) {
|
|
880
|
+
const contextReplacements = getContextReplacements(options);
|
|
881
|
+
contextReplacements.forEach(({ resourceRegExp, newResource }) => plugins.push(new commonBundlerPlugins['ContextReplacementPlugin'][bundler](resourceRegExp, newResource)));
|
|
882
|
+
if (config.polyfill?.process) {
|
|
883
|
+
plugins.push(new commonBundlerPlugins['ProvidePlugin'][bundler]({
|
|
884
|
+
process: 'process/browser.js',
|
|
885
|
+
}));
|
|
886
|
+
}
|
|
813
887
|
if (config.monaco) {
|
|
814
888
|
const MonacoEditorWebpackPlugin = require('monaco-editor-webpack-plugin');
|
|
815
889
|
plugins.push(new MonacoEditorWebpackPlugin({
|
|
@@ -823,6 +897,18 @@ function configureCommonPlugins(options) {
|
|
|
823
897
|
plugins.push(createMomentTimezoneDataPlugin(config.momentTz));
|
|
824
898
|
}
|
|
825
899
|
if (isEnvProduction) {
|
|
900
|
+
if (config.analyzeBundle === 'statoscope') {
|
|
901
|
+
const customStatoscopeConfig = config.statoscopeConfig || {};
|
|
902
|
+
plugins.push(new webpack_plugin_1.default({
|
|
903
|
+
saveReportTo: path.resolve(options.buildDirectory, 'report.html'),
|
|
904
|
+
saveStatsTo: path.resolve(options.buildDirectory, 'stats.json'),
|
|
905
|
+
open: false,
|
|
906
|
+
statsOptions: {
|
|
907
|
+
all: true,
|
|
908
|
+
},
|
|
909
|
+
...customStatoscopeConfig,
|
|
910
|
+
}));
|
|
911
|
+
}
|
|
826
912
|
if (config.sentryConfig) {
|
|
827
913
|
const sentryPlugin = require('@sentry/webpack-plugin').sentryWebpackPlugin;
|
|
828
914
|
plugins.push(sentryPlugin({ ...config.sentryConfig }));
|
|
@@ -835,15 +921,8 @@ function configureCommonPlugins(options) {
|
|
|
835
921
|
}
|
|
836
922
|
function configureWebpackPlugins(options) {
|
|
837
923
|
const { isEnvDevelopment, isEnvProduction, config, isSsr } = options;
|
|
838
|
-
const forkTsCheckerOptions = getForkTsCheckerOptions(options);
|
|
839
924
|
const webpackPlugins = [
|
|
840
925
|
...configureCommonPlugins(options),
|
|
841
|
-
...(options.logger ? [new progress_plugin_1.ProgressPlugin({ logger: options.logger })] : []),
|
|
842
|
-
new webpack.DefinePlugin(getDefinitions(options)),
|
|
843
|
-
new webpack_manifest_plugin_1.WebpackManifestPlugin({
|
|
844
|
-
writeToFileEmit: true,
|
|
845
|
-
publicPath: '',
|
|
846
|
-
}),
|
|
847
926
|
new webpack_assets_manifest_1.default(isEnvProduction
|
|
848
927
|
? {
|
|
849
928
|
entrypoints: true,
|
|
@@ -855,24 +934,8 @@ function configureWebpackPlugins(options) {
|
|
|
855
934
|
output: path.resolve(options.buildDirectory, assetsManifestFile),
|
|
856
935
|
}),
|
|
857
936
|
...(process.env.WEBPACK_PROFILE === 'true' ? [new webpack.debug.ProfilingPlugin()] : []),
|
|
858
|
-
...(forkTsCheckerOptions ? [new fork_ts_checker_webpack_plugin_1.default(forkTsCheckerOptions)] : []),
|
|
859
937
|
];
|
|
860
|
-
if (isEnvProduction || isSsr || config.ssr) {
|
|
861
|
-
webpackPlugins.push(new mini_css_extract_plugin_1.default(getCssExtractPluginOptions(options)));
|
|
862
|
-
}
|
|
863
938
|
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
939
|
if (config.analyzeBundle === 'rsdoctor') {
|
|
877
940
|
const { RsdoctorWebpackPlugin } = require('@rsdoctor/webpack-plugin');
|
|
878
941
|
webpackPlugins.push(new RsdoctorWebpackPlugin({
|
|
@@ -880,44 +943,30 @@ function configureWebpackPlugins(options) {
|
|
|
880
943
|
}));
|
|
881
944
|
}
|
|
882
945
|
}
|
|
883
|
-
if (!isSsr) {
|
|
884
|
-
const
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
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
|
-
}
|
|
946
|
+
if (!isSsr && isEnvDevelopment && config.reactRefresh !== false) {
|
|
947
|
+
const { webSocketPath = path.normalize(`/${config.publicPathPrefix}/build/sockjs-node`) } = config.devServer || {};
|
|
948
|
+
const reactRefreshConfig = config.reactRefresh({
|
|
949
|
+
overlay: { sockPath: webSocketPath },
|
|
950
|
+
exclude: [/node_modules/, /\.worker\.[jt]sx?$/],
|
|
951
|
+
});
|
|
952
|
+
webpackPlugins.push(new react_refresh_webpack_plugin_1.default(reactRefreshConfig));
|
|
897
953
|
}
|
|
898
954
|
return webpackPlugins;
|
|
899
955
|
}
|
|
900
956
|
function configureRspackPlugins(options) {
|
|
901
957
|
const { isEnvDevelopment, isEnvProduction, config, isSsr } = options;
|
|
902
|
-
const forkTsCheckerOptions = getForkTsCheckerOptions(options);
|
|
903
958
|
const rspackPlugins = [
|
|
904
959
|
...configureCommonPlugins(options),
|
|
905
|
-
...(options.logger ? [new rspack_1.RspackProgressPlugin({ logger: options.logger })] : []),
|
|
906
|
-
new core_1.rspack.DefinePlugin(getDefinitions(options)),
|
|
907
960
|
new rspack_manifest_plugin_1.RspackManifestPlugin({
|
|
908
961
|
fileName: isEnvProduction
|
|
909
962
|
? assetsManifestFile
|
|
910
|
-
: path.resolve(
|
|
963
|
+
: path.resolve(options.buildDirectory, assetsManifestFile),
|
|
911
964
|
writeToFileEmit: true,
|
|
912
965
|
useLegacyEmit: true,
|
|
913
966
|
publicPath: '',
|
|
914
967
|
generate: rspack_1.generateAssetsManifest,
|
|
915
968
|
}),
|
|
916
|
-
...(forkTsCheckerOptions ? [new ts_checker_rspack_plugin_1.TsCheckerRspackPlugin(forkTsCheckerOptions)] : []),
|
|
917
969
|
];
|
|
918
|
-
if (isEnvProduction || isSsr || config.ssr) {
|
|
919
|
-
rspackPlugins.push(new core_1.CssExtractRspackPlugin(getCssExtractPluginOptions(options)));
|
|
920
|
-
}
|
|
921
970
|
if (isEnvProduction) {
|
|
922
971
|
if (config.analyzeBundle === 'rsdoctor') {
|
|
923
972
|
const { RsdoctorRspackPlugin } = require('@rsdoctor/rspack-plugin');
|
|
@@ -926,35 +975,26 @@ function configureRspackPlugins(options) {
|
|
|
926
975
|
}));
|
|
927
976
|
}
|
|
928
977
|
}
|
|
929
|
-
if (!isSsr) {
|
|
930
|
-
const
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
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
|
-
}
|
|
978
|
+
if (!isSsr && isEnvDevelopment && config.reactRefresh !== false) {
|
|
979
|
+
const { webSocketPath = path.normalize(`/${config.publicPathPrefix}/build/sockjs-node`) } = config.devServer || {};
|
|
980
|
+
const { overlay, ...reactRefreshConfig } = config.reactRefresh({
|
|
981
|
+
overlay: { sockPath: webSocketPath },
|
|
982
|
+
exclude: [/node_modules/, /\.worker\.[jt]sx?$/],
|
|
983
|
+
});
|
|
984
|
+
rspackPlugins.push(new plugin_react_refresh_1.default({
|
|
985
|
+
...reactRefreshConfig,
|
|
986
|
+
overlay: typeof overlay === 'object'
|
|
987
|
+
? {
|
|
988
|
+
entry: typeof overlay.entry === 'string' ? overlay.entry : undefined,
|
|
989
|
+
module: typeof overlay.module === 'string' ? overlay.module : undefined,
|
|
990
|
+
sockPath: overlay.sockPath,
|
|
991
|
+
sockHost: overlay.sockHost,
|
|
992
|
+
sockPort: overlay.sockPort?.toString(),
|
|
993
|
+
sockProtocol: overlay.sockProtocol,
|
|
994
|
+
sockIntegration: overlay.sockIntegration === 'wds' ? 'wds' : undefined,
|
|
995
|
+
}
|
|
996
|
+
: undefined,
|
|
997
|
+
}));
|
|
958
998
|
}
|
|
959
999
|
return rspackPlugins;
|
|
960
1000
|
}
|
|
@@ -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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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.
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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.
|
|
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
|
-
|
|
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.
|
|
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
|
|
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
|
+
"version": "0.15.1-beta.5",
|
|
4
4
|
"description": "Develop and build your React client-server projects, powered by typescript and webpack",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -79,6 +79,7 @@
|
|
|
79
79
|
"@svgr/core": "^8.1.0",
|
|
80
80
|
"@svgr/plugin-jsx": "^8.1.0",
|
|
81
81
|
"@svgr/webpack": "^8.1.0",
|
|
82
|
+
"@swc/plugin-transform-imports": "^6.1.0",
|
|
82
83
|
"babel-loader": "^9.2.1",
|
|
83
84
|
"babel-plugin-import": "^1.13.8",
|
|
84
85
|
"babel-plugin-inline-react-svg": "^2.0.2",
|