@gravity-ui/app-builder 0.30.0 → 0.30.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/README.md +1 -0
- package/dist/cli.js +20 -15
- package/dist/commands/build/build-lib.js +8 -5
- package/dist/commands/build/build-service/client.js +6 -3
- package/dist/commands/build/build-service/index.js +7 -4
- package/dist/commands/build/build-service/server.js +17 -11
- package/dist/commands/build/index.js +6 -3
- package/dist/commands/dev/client.js +63 -34
- package/dist/commands/dev/index.js +50 -21
- package/dist/commands/dev/server.js +42 -13
- package/dist/common/babel/index.js +4 -1
- package/dist/common/babel/ui-preset.d.ts +1 -1
- package/dist/common/babel/ui-preset.js +1 -0
- package/dist/common/child-process/controllable-script.js +32 -5
- package/dist/common/child-process/utils.js +30 -4
- package/dist/common/command.js +2 -1
- package/dist/common/config.js +49 -19
- package/dist/common/env.js +5 -3
- package/dist/common/library/babel-plugin-replace-paths.js +4 -2
- package/dist/common/library/index.js +95 -66
- package/dist/common/logger/colors.js +8 -2
- package/dist/common/logger/index.js +24 -17
- package/dist/common/logger/log-config.js +6 -3
- package/dist/common/logger/pretty-time.js +6 -2
- package/dist/common/models/index.d.ts +6 -1
- package/dist/common/models/index.js +8 -3
- package/dist/common/paths.js +28 -3
- package/dist/common/s3-upload/compress.js +12 -8
- package/dist/common/s3-upload/create-plugin.js +30 -4
- package/dist/common/s3-upload/index.js +9 -3
- package/dist/common/s3-upload/s3-client.js +37 -11
- package/dist/common/s3-upload/upload.js +38 -9
- package/dist/common/s3-upload/webpack-plugin.js +9 -5
- package/dist/common/swc/compile.js +12 -9
- package/dist/common/swc/index.js +7 -2
- package/dist/common/swc/utils.js +13 -6
- package/dist/common/swc/watch.js +9 -6
- package/dist/common/typescript/compile.js +14 -11
- package/dist/common/typescript/diagnostic.js +37 -11
- package/dist/common/typescript/transformers.js +29 -3
- package/dist/common/typescript/utils.js +18 -8
- package/dist/common/typescript/watch.js +13 -10
- package/dist/common/utils.js +25 -14
- package/dist/common/webpack/compile.js +22 -16
- package/dist/common/webpack/config.js +143 -89
- package/dist/common/webpack/node-externals.js +34 -5
- package/dist/common/webpack/progress-plugin.js +6 -3
- package/dist/common/webpack/public-path.d.ts +1 -0
- package/dist/common/webpack/public-path.js +1 -0
- package/dist/common/webpack/rspack.js +5 -1
- package/dist/common/webpack/runtime-versioning-plugin.js +3 -1
- package/dist/common/webpack/storybook.js +51 -21
- package/dist/common/webpack/utils.js +36 -9
- package/dist/common/webpack/worker/public-path.worker.d.ts +1 -0
- package/dist/common/webpack/worker/public-path.worker.js +1 -0
- package/dist/common/webpack/worker/worker-loader.js +34 -4
- package/dist/create-cli.js +48 -19
- package/dist/index.js +27 -5
- package/package.json +1 -2
|
@@ -1,35 +1,68 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.webpackConfigFactory = webpackConfigFactory;
|
|
30
|
+
exports.rspackConfigFactory = rspackConfigFactory;
|
|
31
|
+
exports.configureModuleRules = configureModuleRules;
|
|
32
|
+
exports.configureResolve = configureResolve;
|
|
33
|
+
exports.configureOptimization = configureOptimization;
|
|
34
|
+
const path = __importStar(require("node:path"));
|
|
35
|
+
const fs = __importStar(require("node:fs"));
|
|
36
|
+
const webpack = __importStar(require("webpack"));
|
|
37
|
+
const clean_webpack_plugin_1 = require("clean-webpack-plugin");
|
|
38
|
+
const webpack_manifest_plugin_1 = require("webpack-manifest-plugin");
|
|
39
|
+
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
|
+
const webpack_bundle_analyzer_1 = require("webpack-bundle-analyzer");
|
|
42
|
+
const webpack_assets_manifest_1 = __importDefault(require("webpack-assets-manifest"));
|
|
43
|
+
const rspack_manifest_plugin_1 = require("rspack-manifest-plugin");
|
|
44
|
+
const react_refresh_webpack_plugin_1 = __importDefault(require("@pmmmwh/react-refresh-webpack-plugin"));
|
|
45
|
+
const moment_timezone_data_webpack_plugin_1 = __importDefault(require("moment-timezone-data-webpack-plugin"));
|
|
46
|
+
const webpack_plugin_1 = __importDefault(require("@statoscope/webpack-plugin"));
|
|
47
|
+
const circular_dependency_plugin_1 = __importDefault(require("circular-dependency-plugin"));
|
|
48
|
+
const core_1 = require("@rspack/core");
|
|
49
|
+
const rspack_1 = require("./rspack");
|
|
50
|
+
const ts_checker_rspack_plugin_1 = require("ts-checker-rspack-plugin");
|
|
51
|
+
const plugin_react_refresh_1 = __importDefault(require("@rspack/plugin-react-refresh"));
|
|
52
|
+
const paths_1 = __importDefault(require("../paths"));
|
|
53
|
+
const babel_1 = require("../babel");
|
|
54
|
+
const progress_plugin_1 = require("./progress-plugin");
|
|
55
|
+
const utils_1 = require("./utils");
|
|
56
|
+
const s3_upload_1 = require("../s3-upload");
|
|
57
|
+
const log_config_1 = require("../logger/log-config");
|
|
58
|
+
const utils_2 = require("../typescript/utils");
|
|
59
|
+
const node_externals_1 = require("./node-externals");
|
|
27
60
|
const imagesSizeLimit = 2048;
|
|
28
61
|
const fontSizeLimit = 8192;
|
|
29
62
|
function getHelperOptions({ webpackMode, config, logger, isSsr = false, configPath, }) {
|
|
30
63
|
const isEnvDevelopment = webpackMode === "development" /* WebpackMode.Dev */;
|
|
31
64
|
const isEnvProduction = webpackMode === "production" /* WebpackMode.Prod */;
|
|
32
|
-
let buildDirectory = config.outputPath || (isSsr ?
|
|
65
|
+
let buildDirectory = config.outputPath || (isSsr ? paths_1.default.appSsrBuild : paths_1.default.appBuild);
|
|
33
66
|
if (config.moduleFederation) {
|
|
34
67
|
buildDirectory = path.resolve(buildDirectory, config.moduleFederation.name);
|
|
35
68
|
}
|
|
@@ -40,7 +73,7 @@ function getHelperOptions({ webpackMode, config, logger, isSsr = false, configPa
|
|
|
40
73
|
isEnvProduction,
|
|
41
74
|
configType: webpackMode,
|
|
42
75
|
buildDirectory,
|
|
43
|
-
entriesDirectory: isSsr ?
|
|
76
|
+
entriesDirectory: isSsr ? paths_1.default.appSsrEntry : paths_1.default.appEntry,
|
|
44
77
|
isSsr,
|
|
45
78
|
configPath,
|
|
46
79
|
};
|
|
@@ -51,7 +84,7 @@ function configureExternals({ config, isSsr }) {
|
|
|
51
84
|
externals =
|
|
52
85
|
config.ssr?.noExternal === true
|
|
53
86
|
? undefined
|
|
54
|
-
: nodeExternals({
|
|
87
|
+
: (0, node_externals_1.nodeExternals)({
|
|
55
88
|
noExternal: config.ssr?.noExternal,
|
|
56
89
|
module: config.ssr?.moduleType === 'esm',
|
|
57
90
|
});
|
|
@@ -76,13 +109,13 @@ function configureWebpackCache(options) {
|
|
|
76
109
|
}
|
|
77
110
|
return cache;
|
|
78
111
|
}
|
|
79
|
-
|
|
112
|
+
async function webpackConfigFactory(options) {
|
|
80
113
|
const { config } = options;
|
|
81
114
|
const helperOptions = getHelperOptions(options);
|
|
82
115
|
const { isSsr, isEnvProduction } = helperOptions;
|
|
83
116
|
let webpackConfig = {
|
|
84
117
|
mode: isEnvProduction ? 'production' : 'development',
|
|
85
|
-
context:
|
|
118
|
+
context: paths_1.default.app,
|
|
86
119
|
bail: isEnvProduction,
|
|
87
120
|
target: isSsr ? 'node' : undefined,
|
|
88
121
|
devtool: configureDevTool(helperOptions),
|
|
@@ -115,11 +148,11 @@ export async function webpackConfigFactory(options) {
|
|
|
115
148
|
isSsr,
|
|
116
149
|
});
|
|
117
150
|
if (config.debugWebpack) {
|
|
118
|
-
logConfig('Preview webpack config', webpackConfig);
|
|
151
|
+
(0, log_config_1.logConfig)('Preview webpack config', webpackConfig);
|
|
119
152
|
}
|
|
120
153
|
return webpackConfig;
|
|
121
154
|
}
|
|
122
|
-
|
|
155
|
+
async function rspackConfigFactory(options) {
|
|
123
156
|
const { config } = options;
|
|
124
157
|
const helperOptions = getHelperOptions(options);
|
|
125
158
|
const { isSsr, isEnvProduction, isEnvDevelopment } = helperOptions;
|
|
@@ -127,7 +160,7 @@ export async function rspackConfigFactory(options) {
|
|
|
127
160
|
const cache = Boolean(config.cache) || (isEnvDevelopment && Boolean(config.lazyCompilation));
|
|
128
161
|
let rspackConfig = {
|
|
129
162
|
mode: isEnvProduction ? 'production' : 'development',
|
|
130
|
-
context:
|
|
163
|
+
context: paths_1.default.app,
|
|
131
164
|
bail: isEnvProduction,
|
|
132
165
|
target: isSsr ? 'node' : undefined,
|
|
133
166
|
devtool: configureDevTool(helperOptions),
|
|
@@ -157,11 +190,11 @@ export async function rspackConfigFactory(options) {
|
|
|
157
190
|
isSsr,
|
|
158
191
|
});
|
|
159
192
|
if (config.debugWebpack) {
|
|
160
|
-
logConfig('Preview rspack config', rspackConfig);
|
|
193
|
+
(0, log_config_1.logConfig)('Preview rspack config', rspackConfig);
|
|
161
194
|
}
|
|
162
195
|
return rspackConfig;
|
|
163
196
|
}
|
|
164
|
-
|
|
197
|
+
async function configureModuleRules(helperOptions, additionalRules = []) {
|
|
165
198
|
const jsLoader = await createJavaScriptLoader(helperOptions);
|
|
166
199
|
return [
|
|
167
200
|
...createSourceMapRules(!helperOptions.config.disableSourceMapGeneration),
|
|
@@ -202,10 +235,10 @@ function getCacheBuildDependencies({ config, configPath }) {
|
|
|
202
235
|
const buildDependencies = {};
|
|
203
236
|
const dependenciesGroups = {
|
|
204
237
|
appBuilderConfig: configPath ? [configPath] : [],
|
|
205
|
-
packageJson: [path.join(
|
|
238
|
+
packageJson: [path.join(paths_1.default.app, 'package.json')],
|
|
206
239
|
tsconfig: [
|
|
207
|
-
path.join(
|
|
208
|
-
path.join(
|
|
240
|
+
path.join(paths_1.default.app, 'tsconfig.json'),
|
|
241
|
+
path.join(paths_1.default.appClient, 'tsconfig.json'),
|
|
209
242
|
],
|
|
210
243
|
};
|
|
211
244
|
for (const [group, filePaths] of Object.entries(dependenciesGroups)) {
|
|
@@ -277,12 +310,15 @@ function configureRspackExperiments(options) {
|
|
|
277
310
|
const filesystemCacheOptions = typeof config.cache === 'object' && config.cache.type === 'filesystem'
|
|
278
311
|
? config.cache
|
|
279
312
|
: undefined;
|
|
280
|
-
const
|
|
313
|
+
const cacheVersion = [
|
|
314
|
+
config.moduleFederation?.name || filesystemCacheOptions?.name,
|
|
315
|
+
config.moduleFederation?.version || filesystemCacheOptions?.version,
|
|
316
|
+
]
|
|
281
317
|
.filter(Boolean)
|
|
282
318
|
.join('-');
|
|
283
319
|
return {
|
|
284
320
|
cache: {
|
|
285
|
-
version:
|
|
321
|
+
version: cacheVersion || undefined,
|
|
286
322
|
type: 'persistent',
|
|
287
323
|
snapshot: {
|
|
288
324
|
managedPaths: config.watchOptions?.watchPackages ? [] : undefined,
|
|
@@ -296,16 +332,16 @@ function configureRspackExperiments(options) {
|
|
|
296
332
|
lazyCompilation,
|
|
297
333
|
};
|
|
298
334
|
}
|
|
299
|
-
|
|
335
|
+
function configureResolve({ isEnvProduction, config }) {
|
|
300
336
|
const alias = { ...config.alias };
|
|
301
337
|
for (const [key, value] of Object.entries(alias)) {
|
|
302
|
-
alias[key] = path.resolve(
|
|
338
|
+
alias[key] = path.resolve(paths_1.default.app, value);
|
|
303
339
|
}
|
|
304
340
|
if (isEnvProduction && config.reactProfiling) {
|
|
305
341
|
alias['react-dom$'] = 'react-dom/profiling';
|
|
306
342
|
alias['scheduler/tracing'] = 'scheduler/tracing-profiling';
|
|
307
343
|
}
|
|
308
|
-
const { aliases, modules = [] } = resolveTsConfigPathsToAlias(
|
|
344
|
+
const { aliases, modules = [] } = (0, utils_1.resolveTsConfigPathsToAlias)(paths_1.default.appClient);
|
|
309
345
|
return {
|
|
310
346
|
alias: {
|
|
311
347
|
...aliases,
|
|
@@ -501,7 +537,7 @@ async function createJavaScriptLoader({ isEnvProduction, isEnvDevelopment, confi
|
|
|
501
537
|
}
|
|
502
538
|
}
|
|
503
539
|
const babelTransformOptions = await config.babel({
|
|
504
|
-
presets: [babelPreset({ newJsxTransform: config.newJsxTransform, isSsr })],
|
|
540
|
+
presets: [(0, babel_1.babelPreset)({ newJsxTransform: config.newJsxTransform, isSsr })],
|
|
505
541
|
plugins,
|
|
506
542
|
}, { configType, isSsr });
|
|
507
543
|
return {
|
|
@@ -520,9 +556,9 @@ async function createJavaScriptLoader({ isEnvProduction, isEnvDevelopment, confi
|
|
|
520
556
|
}
|
|
521
557
|
function createJavaScriptRule({ config, isEnvProduction }, jsLoader) {
|
|
522
558
|
const include = [
|
|
523
|
-
|
|
559
|
+
paths_1.default.appClient,
|
|
524
560
|
...(config.monaco && isEnvProduction
|
|
525
|
-
? [path.resolve(
|
|
561
|
+
? [path.resolve(paths_1.default.appNodeModules, 'monaco-editor/esm/vs')]
|
|
526
562
|
: []),
|
|
527
563
|
...(config.includes || []),
|
|
528
564
|
];
|
|
@@ -579,7 +615,7 @@ function createSassStylesRule(options) {
|
|
|
579
615
|
options: {
|
|
580
616
|
sourceMap: true, // must be always true for work with resolve-url-loader
|
|
581
617
|
sassOptions: {
|
|
582
|
-
loadPaths: [
|
|
618
|
+
loadPaths: [paths_1.default.appClient],
|
|
583
619
|
},
|
|
584
620
|
},
|
|
585
621
|
},
|
|
@@ -652,7 +688,7 @@ function getCssLoaders({ isEnvDevelopment, isEnvProduction, config, isSsr }, add
|
|
|
652
688
|
});
|
|
653
689
|
if (isEnvProduction) {
|
|
654
690
|
loaders.unshift({
|
|
655
|
-
loader: isRspack ? rspack.CssExtractRspackPlugin.loader :
|
|
691
|
+
loader: isRspack ? core_1.rspack.CssExtractRspackPlugin.loader : mini_css_extract_plugin_1.default.loader,
|
|
656
692
|
options: { emit: !isSsr },
|
|
657
693
|
});
|
|
658
694
|
}
|
|
@@ -660,8 +696,8 @@ function getCssLoaders({ isEnvDevelopment, isEnvProduction, config, isSsr }, add
|
|
|
660
696
|
if (isSsr || config.ssr) {
|
|
661
697
|
loaders.unshift({
|
|
662
698
|
loader: isRspack
|
|
663
|
-
? rspack.CssExtractRspackPlugin.loader
|
|
664
|
-
:
|
|
699
|
+
? core_1.rspack.CssExtractRspackPlugin.loader
|
|
700
|
+
: mini_css_extract_plugin_1.default.loader,
|
|
665
701
|
options: { emit: !isSsr },
|
|
666
702
|
});
|
|
667
703
|
}
|
|
@@ -719,7 +755,7 @@ function createIconsRule({ isEnvProduction, config, isSsr }, jsLoader) {
|
|
|
719
755
|
function createAssetsRules({ isEnvProduction, config, isSsr }) {
|
|
720
756
|
const imagesRule = {
|
|
721
757
|
test: /\.(ico|bmp|gif|jpe?g|png|svg)$/,
|
|
722
|
-
include: [
|
|
758
|
+
include: [paths_1.default.appClient, ...(config.images || [])],
|
|
723
759
|
type: 'asset',
|
|
724
760
|
parser: {
|
|
725
761
|
dataUrlCondition: {
|
|
@@ -733,7 +769,7 @@ function createAssetsRules({ isEnvProduction, config, isSsr }) {
|
|
|
733
769
|
};
|
|
734
770
|
const fontsRule = {
|
|
735
771
|
test: /\.(ttf|eot|woff2?)$/,
|
|
736
|
-
include: [
|
|
772
|
+
include: [paths_1.default.appClient],
|
|
737
773
|
type: 'asset',
|
|
738
774
|
parser: {
|
|
739
775
|
dataUrlCondition: {
|
|
@@ -752,7 +788,7 @@ function createAssetsRules({ isEnvProduction, config, isSsr }) {
|
|
|
752
788
|
rules.unshift({
|
|
753
789
|
test: /\.(ico|bmp|gif|jpe?g|png|svg)$/,
|
|
754
790
|
issuer: /\.s?css$/,
|
|
755
|
-
include: [
|
|
791
|
+
include: [paths_1.default.appClient, ...(config.images || [])],
|
|
756
792
|
type: 'asset',
|
|
757
793
|
parser: {
|
|
758
794
|
dataUrlCondition: {
|
|
@@ -767,7 +803,7 @@ function createAssetsRules({ isEnvProduction, config, isSsr }) {
|
|
|
767
803
|
}, {
|
|
768
804
|
test: /\.(ttf|eot|woff2?)$/,
|
|
769
805
|
issuer: /\.s?css$/,
|
|
770
|
-
include: [
|
|
806
|
+
include: [paths_1.default.appClient],
|
|
771
807
|
type: 'asset',
|
|
772
808
|
parser: {
|
|
773
809
|
dataUrlCondition: {
|
|
@@ -816,7 +852,7 @@ function createMomentTimezoneDataPlugin(options = {}) {
|
|
|
816
852
|
// https://momentjs.com/timezone/docs/#/use-it/webpack/
|
|
817
853
|
const startYear = options.startYear ?? currentYear;
|
|
818
854
|
const endYear = options.endYear ?? currentYear;
|
|
819
|
-
return new
|
|
855
|
+
return new moment_timezone_data_webpack_plugin_1.default({ ...options, startYear, endYear });
|
|
820
856
|
}
|
|
821
857
|
function getDefinitions({ config, isSsr }) {
|
|
822
858
|
return {
|
|
@@ -856,8 +892,8 @@ function getForkTsCheckerOptions({ config, }) {
|
|
|
856
892
|
: {
|
|
857
893
|
...config.forkTsChecker,
|
|
858
894
|
typescript: {
|
|
859
|
-
typescriptPath: resolveTypescript(),
|
|
860
|
-
configFile: path.resolve(
|
|
895
|
+
typescriptPath: (0, utils_2.resolveTypescript)(),
|
|
896
|
+
configFile: path.resolve(paths_1.default.appClient, 'tsconfig.json'),
|
|
861
897
|
diagnosticOptions: {
|
|
862
898
|
syntactic: true,
|
|
863
899
|
},
|
|
@@ -880,7 +916,7 @@ function configureCommonPlugins(options, bundlerPlugins) {
|
|
|
880
916
|
const excludeFromClean = config.excludeFromClean || [];
|
|
881
917
|
const forkTsCheckerOptions = getForkTsCheckerOptions(options);
|
|
882
918
|
const plugins = [
|
|
883
|
-
new CleanWebpackPlugin({
|
|
919
|
+
new clean_webpack_plugin_1.CleanWebpackPlugin({
|
|
884
920
|
verbose: config.verbose,
|
|
885
921
|
cleanOnceBeforeBuildPatterns: [
|
|
886
922
|
'**/*',
|
|
@@ -904,7 +940,7 @@ function configureCommonPlugins(options, bundlerPlugins) {
|
|
|
904
940
|
if (typeof config.detectCircularDependencies === 'object') {
|
|
905
941
|
circularPluginOptions = config.detectCircularDependencies;
|
|
906
942
|
}
|
|
907
|
-
plugins.push(new
|
|
943
|
+
plugins.push(new circular_dependency_plugin_1.default(circularPluginOptions));
|
|
908
944
|
}
|
|
909
945
|
if (isEnvProduction || isSsr || config.ssr) {
|
|
910
946
|
plugins.push(new bundlerPlugins.CSSExtractPlugin(getCssExtractPluginOptions(options)));
|
|
@@ -929,16 +965,27 @@ function configureCommonPlugins(options, bundlerPlugins) {
|
|
|
929
965
|
}
|
|
930
966
|
plugins.push(createMomentTimezoneDataPlugin(config.momentTz));
|
|
931
967
|
if (config.moduleFederation) {
|
|
932
|
-
const { name, version, publicPath, remotes, originalRemotes, remotesRuntimeVersioning, runtimePlugins, ...restOptions } = config.moduleFederation;
|
|
968
|
+
const { name, version, disableManifest, publicPath, remotes, originalRemotes, remotesRuntimeVersioning, runtimePlugins, ...restOptions } = config.moduleFederation;
|
|
933
969
|
let actualRemotes = originalRemotes;
|
|
934
970
|
if (remotes) {
|
|
971
|
+
let remoteFile;
|
|
972
|
+
if (disableManifest) {
|
|
973
|
+
if (remotesRuntimeVersioning) {
|
|
974
|
+
remoteFile = `entry-[version].js`;
|
|
975
|
+
}
|
|
976
|
+
else {
|
|
977
|
+
remoteFile = 'entry.js';
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
else if (remotesRuntimeVersioning) {
|
|
981
|
+
remoteFile = `mf-manifest-[version].json`;
|
|
982
|
+
}
|
|
983
|
+
else {
|
|
984
|
+
remoteFile = 'mf-manifest.json';
|
|
985
|
+
}
|
|
935
986
|
actualRemotes = remotes.reduce((acc, remoteName) => {
|
|
936
|
-
const remoteFilename = remotesRuntimeVersioning
|
|
937
|
-
? 'entry-[version].js'
|
|
938
|
-
: 'entry.js';
|
|
939
987
|
// eslint-disable-next-line no-param-reassign
|
|
940
|
-
acc[remoteName] =
|
|
941
|
-
`${remoteName}@${publicPath}${remoteName}/${remoteFilename}`;
|
|
988
|
+
acc[remoteName] = `${remoteName}@${publicPath}${remoteName}/${remoteFile}`;
|
|
942
989
|
return acc;
|
|
943
990
|
}, {});
|
|
944
991
|
}
|
|
@@ -949,6 +996,13 @@ function configureCommonPlugins(options, bundlerPlugins) {
|
|
|
949
996
|
plugins.push(new bundlerPlugins.ModuleFederationPlugin({
|
|
950
997
|
name,
|
|
951
998
|
filename: version ? `entry-${version}.js` : 'entry.js',
|
|
999
|
+
manifest: disableManifest
|
|
1000
|
+
? undefined
|
|
1001
|
+
: {
|
|
1002
|
+
fileName: version
|
|
1003
|
+
? `mf-manifest-${version}.json`
|
|
1004
|
+
: 'mf-manifest.json',
|
|
1005
|
+
},
|
|
952
1006
|
remotes: actualRemotes,
|
|
953
1007
|
runtimePlugins: actualRuntimePlugins,
|
|
954
1008
|
...restOptions,
|
|
@@ -957,7 +1011,7 @@ function configureCommonPlugins(options, bundlerPlugins) {
|
|
|
957
1011
|
}
|
|
958
1012
|
if (isEnvProduction) {
|
|
959
1013
|
if (config.analyzeBundle === 'true') {
|
|
960
|
-
plugins.push(new BundleAnalyzerPlugin({
|
|
1014
|
+
plugins.push(new webpack_bundle_analyzer_1.BundleAnalyzerPlugin({
|
|
961
1015
|
openAnalyzer: false,
|
|
962
1016
|
analyzerMode: 'static',
|
|
963
1017
|
reportFilename: 'stats.html',
|
|
@@ -965,7 +1019,7 @@ function configureCommonPlugins(options, bundlerPlugins) {
|
|
|
965
1019
|
}
|
|
966
1020
|
if (config.analyzeBundle === 'statoscope') {
|
|
967
1021
|
const customStatoscopeConfig = config.statoscopeConfig || {};
|
|
968
|
-
plugins.push(new
|
|
1022
|
+
plugins.push(new webpack_plugin_1.default({
|
|
969
1023
|
saveReportTo: path.resolve(options.buildDirectory, 'report.html'),
|
|
970
1024
|
saveStatsTo: path.resolve(options.buildDirectory, 'stats.json'),
|
|
971
1025
|
open: false,
|
|
@@ -986,7 +1040,7 @@ function configureCommonPlugins(options, bundlerPlugins) {
|
|
|
986
1040
|
}
|
|
987
1041
|
}
|
|
988
1042
|
if (config.cdn) {
|
|
989
|
-
plugins.push(...createS3UploadPlugins(config, options.logger));
|
|
1043
|
+
plugins.push(...(0, s3_upload_1.createS3UploadPlugins)(config, options.logger));
|
|
990
1044
|
}
|
|
991
1045
|
return plugins;
|
|
992
1046
|
}
|
|
@@ -996,17 +1050,17 @@ function configureWebpackPlugins(options) {
|
|
|
996
1050
|
DefinePlugin: webpack.DefinePlugin,
|
|
997
1051
|
ContextReplacementPlugin: webpack.ContextReplacementPlugin,
|
|
998
1052
|
ProvidePlugin: webpack.ProvidePlugin,
|
|
999
|
-
ProgressPlugin: createProgressPlugin(webpack.ProgressPlugin),
|
|
1000
|
-
ManifestPlugin: WebpackManifestPlugin,
|
|
1001
|
-
TsCheckerPlugin:
|
|
1002
|
-
CSSExtractPlugin:
|
|
1053
|
+
ProgressPlugin: (0, progress_plugin_1.createProgressPlugin)(webpack.ProgressPlugin),
|
|
1054
|
+
ManifestPlugin: webpack_manifest_plugin_1.WebpackManifestPlugin,
|
|
1055
|
+
TsCheckerPlugin: fork_ts_checker_webpack_plugin_1.default,
|
|
1056
|
+
CSSExtractPlugin: mini_css_extract_plugin_1.default,
|
|
1003
1057
|
RSDoctorPlugin: require('@rsdoctor/webpack-plugin').RsdoctorWebpackPlugin,
|
|
1004
1058
|
ModuleFederationPlugin: require('@module-federation/enhanced/webpack')
|
|
1005
1059
|
.ModuleFederationPlugin,
|
|
1006
1060
|
};
|
|
1007
1061
|
const webpackPlugins = [
|
|
1008
1062
|
...configureCommonPlugins(options, plugins),
|
|
1009
|
-
new
|
|
1063
|
+
new webpack_assets_manifest_1.default(isEnvProduction
|
|
1010
1064
|
? {
|
|
1011
1065
|
entrypoints: true,
|
|
1012
1066
|
output: config.assetsManifestFile,
|
|
@@ -1024,34 +1078,34 @@ function configureWebpackPlugins(options) {
|
|
|
1024
1078
|
overlay: { sockPath: webSocketPath },
|
|
1025
1079
|
exclude: [/node_modules/, /\.worker\.[jt]sx?$/],
|
|
1026
1080
|
});
|
|
1027
|
-
webpackPlugins.push(new
|
|
1081
|
+
webpackPlugins.push(new react_refresh_webpack_plugin_1.default(reactRefreshConfig));
|
|
1028
1082
|
}
|
|
1029
1083
|
return webpackPlugins;
|
|
1030
1084
|
}
|
|
1031
1085
|
function configureRspackPlugins(options) {
|
|
1032
1086
|
const { isEnvDevelopment, isEnvProduction, config, isSsr } = options;
|
|
1033
1087
|
const plugins = {
|
|
1034
|
-
DefinePlugin: rspack.DefinePlugin,
|
|
1035
|
-
ContextReplacementPlugin: rspack.ContextReplacementPlugin,
|
|
1036
|
-
ProvidePlugin: rspack.ProvidePlugin,
|
|
1037
|
-
ProgressPlugin: createProgressPlugin(rspack.ProgressPlugin),
|
|
1038
|
-
ManifestPlugin: RspackManifestPlugin,
|
|
1039
|
-
TsCheckerPlugin: TsCheckerRspackPlugin,
|
|
1040
|
-
CSSExtractPlugin: rspack.CssExtractRspackPlugin,
|
|
1088
|
+
DefinePlugin: core_1.rspack.DefinePlugin,
|
|
1089
|
+
ContextReplacementPlugin: core_1.rspack.ContextReplacementPlugin,
|
|
1090
|
+
ProvidePlugin: core_1.rspack.ProvidePlugin,
|
|
1091
|
+
ProgressPlugin: (0, progress_plugin_1.createProgressPlugin)(core_1.rspack.ProgressPlugin),
|
|
1092
|
+
ManifestPlugin: rspack_manifest_plugin_1.RspackManifestPlugin,
|
|
1093
|
+
TsCheckerPlugin: ts_checker_rspack_plugin_1.TsCheckerRspackPlugin,
|
|
1094
|
+
CSSExtractPlugin: core_1.rspack.CssExtractRspackPlugin,
|
|
1041
1095
|
RSDoctorPlugin: require('@rsdoctor/rspack-plugin').RsdoctorRspackPlugin,
|
|
1042
1096
|
ModuleFederationPlugin: require('@module-federation/enhanced/rspack')
|
|
1043
1097
|
.ModuleFederationPlugin,
|
|
1044
1098
|
};
|
|
1045
1099
|
const rspackPlugins = [
|
|
1046
1100
|
...configureCommonPlugins(options, plugins),
|
|
1047
|
-
new RspackManifestPlugin({
|
|
1101
|
+
new rspack_manifest_plugin_1.RspackManifestPlugin({
|
|
1048
1102
|
fileName: isEnvProduction
|
|
1049
1103
|
? config.assetsManifestFile
|
|
1050
1104
|
: path.resolve(options.buildDirectory, config.assetsManifestFile),
|
|
1051
1105
|
writeToFileEmit: true,
|
|
1052
1106
|
useLegacyEmit: true,
|
|
1053
1107
|
publicPath: '',
|
|
1054
|
-
generate: generateAssetsManifest,
|
|
1108
|
+
generate: rspack_1.generateAssetsManifest,
|
|
1055
1109
|
}),
|
|
1056
1110
|
];
|
|
1057
1111
|
if (!isSsr && isEnvDevelopment && config.reactRefresh !== false) {
|
|
@@ -1060,7 +1114,7 @@ function configureRspackPlugins(options) {
|
|
|
1060
1114
|
overlay: { sockPath: webSocketPath },
|
|
1061
1115
|
exclude: [/node_modules/, /\.worker\.[jt]sx?$/],
|
|
1062
1116
|
});
|
|
1063
|
-
rspackPlugins.push(new
|
|
1117
|
+
rspackPlugins.push(new plugin_react_refresh_1.default({
|
|
1064
1118
|
...reactRefreshConfig,
|
|
1065
1119
|
overlay: typeof overlay === 'object'
|
|
1066
1120
|
? {
|
|
@@ -1121,14 +1175,14 @@ function getOptimizationSplitChunks({ config }) {
|
|
|
1121
1175
|
},
|
|
1122
1176
|
};
|
|
1123
1177
|
}
|
|
1124
|
-
|
|
1178
|
+
function configureOptimization(helperOptions) {
|
|
1125
1179
|
const { config, isSsr } = helperOptions;
|
|
1126
1180
|
if (isSsr) {
|
|
1127
1181
|
return {};
|
|
1128
1182
|
}
|
|
1129
1183
|
const optimization = {
|
|
1130
1184
|
splitChunks: getOptimizationSplitChunks(helperOptions),
|
|
1131
|
-
runtimeChunk: 'single',
|
|
1185
|
+
runtimeChunk: helperOptions.config.moduleFederation ? false : 'single',
|
|
1132
1186
|
minimizer: [
|
|
1133
1187
|
(compiler) => {
|
|
1134
1188
|
// CssMinimizerWebpackPlugin works with MiniCSSExtractPlugin, so only relevant for production builds.
|
|
@@ -1201,7 +1255,7 @@ function configureRspackOptimization(helperOptions) {
|
|
|
1201
1255
|
if (typeof lightningCssMinimizerOptions === 'function') {
|
|
1202
1256
|
lightningCssMinifyOptions = lightningCssMinimizerOptions(lightningCssMinifyOptions);
|
|
1203
1257
|
}
|
|
1204
|
-
cssMinimizer = new rspack.LightningCssMinimizerRspackPlugin(lightningCssMinifyOptions);
|
|
1258
|
+
cssMinimizer = new core_1.rspack.LightningCssMinimizerRspackPlugin(lightningCssMinifyOptions);
|
|
1205
1259
|
}
|
|
1206
1260
|
else {
|
|
1207
1261
|
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
|
@@ -1234,7 +1288,7 @@ function configureRspackOptimization(helperOptions) {
|
|
|
1234
1288
|
const optimization = {
|
|
1235
1289
|
splitChunks: getOptimizationSplitChunks(helperOptions),
|
|
1236
1290
|
runtimeChunk: helperOptions.config.moduleFederation ? false : 'single',
|
|
1237
|
-
minimizer: [new rspack.SwcJsMinimizerRspackPlugin(swcMinifyOptions), cssMinimizer],
|
|
1291
|
+
minimizer: [new core_1.rspack.SwcJsMinimizerRspackPlugin(swcMinifyOptions), cssMinimizer],
|
|
1238
1292
|
};
|
|
1239
1293
|
return optimization;
|
|
1240
1294
|
}
|
|
@@ -1,10 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.nodeExternals = nodeExternals;
|
|
30
|
+
const fs = __importStar(require("node:fs"));
|
|
31
|
+
const path = __importStar(require("node:path"));
|
|
32
|
+
const paths_1 = __importDefault(require("../paths"));
|
|
4
33
|
const webpackInternal = /^webpack\/container\/reference\//;
|
|
5
|
-
|
|
34
|
+
function nodeExternals({ noExternal = [], module }) {
|
|
6
35
|
const noExternals = Array().concat(webpackInternal).concat(noExternal);
|
|
7
|
-
const nodeModules = readPackagesNames(
|
|
36
|
+
const nodeModules = readPackagesNames(paths_1.default.appNodeModules);
|
|
8
37
|
return async (data) => {
|
|
9
38
|
const { request, dependencyType } = data;
|
|
10
39
|
if (!request) {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createProgressPlugin = createProgressPlugin;
|
|
4
|
+
const pretty_time_1 = require("../logger/pretty-time");
|
|
5
|
+
function createProgressPlugin(BaseClass) {
|
|
3
6
|
return class ProgressPlugin extends BaseClass {
|
|
4
7
|
logger;
|
|
5
8
|
state = {};
|
|
@@ -27,7 +30,7 @@ export function createProgressPlugin(BaseClass) {
|
|
|
27
30
|
this.logger.verbose(`Invalidate file: ${fileName} at ${changeTime}`);
|
|
28
31
|
});
|
|
29
32
|
hook(compiler, 'done', (stats) => {
|
|
30
|
-
const time = this.state.start ? ' in ' + elapsedTime(this.state.start) : '';
|
|
33
|
+
const time = this.state.start ? ' in ' + (0, pretty_time_1.elapsedTime)(this.state.start) : '';
|
|
31
34
|
const hasErrors = stats.hasErrors();
|
|
32
35
|
if (hasErrors) {
|
|
33
36
|
this.logger.error('Compiled with some errors' + time);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateAssetsManifest = void 0;
|
|
4
|
+
const generateAssetsManifest = (seed, files, entries) => {
|
|
2
5
|
const manifestFiles = files.reduce((manifest, file) => {
|
|
3
6
|
manifest[file.name] = file.path;
|
|
4
7
|
return manifest;
|
|
@@ -19,3 +22,4 @@ export const generateAssetsManifest = (seed, files, entries) => {
|
|
|
19
22
|
entrypoints,
|
|
20
23
|
};
|
|
21
24
|
};
|
|
25
|
+
exports.generateAssetsManifest = generateAssetsManifest;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/* global window */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
4
|
const RuntimeVersioningPlugin = () => {
|
|
3
5
|
return {
|
|
4
6
|
name: 'runtime-versioning-plugin',
|
|
@@ -17,4 +19,4 @@ const RuntimeVersioningPlugin = () => {
|
|
|
17
19
|
},
|
|
18
20
|
};
|
|
19
21
|
};
|
|
20
|
-
|
|
22
|
+
exports.default = RuntimeVersioningPlugin;
|