@gravity-ui/app-builder 0.32.0 → 0.32.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 +21 -5
- package/dist/common/config.js +2 -2
- package/dist/common/webpack/config.js +4 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -407,12 +407,22 @@ Module Federation is a Webpack 5 feature that enables micro-frontend architectur
|
|
|
407
407
|
- Allows selective enabling/disabling of specific remotes during development
|
|
408
408
|
- Useful for debugging, testing individual micro-frontends, or working with partial system setups
|
|
409
409
|
- Helps reduce development startup time by loading only needed remotes
|
|
410
|
-
- Can be overridden via CLI flag: `--mf-remotes
|
|
410
|
+
- Can be overridden via CLI flag: `--mf-remotes header footer`
|
|
411
411
|
|
|
412
412
|
**Loading behavior:**
|
|
413
413
|
|
|
414
|
-
|
|
415
|
-
|
|
414
|
+
**When CDN is disabled:**
|
|
415
|
+
|
|
416
|
+
- **Enabled remotes**: Loaded from local development server with version-specific paths
|
|
417
|
+
- **Disabled remotes**: Loaded from `cdnPublicPath` (if configured), otherwise fallback to local paths
|
|
418
|
+
|
|
419
|
+
**When CDN is enabled:**
|
|
420
|
+
|
|
421
|
+
- **All remotes**: Use common public path, `enabledRemotes` selection has no effect on URLs
|
|
422
|
+
|
|
423
|
+
**In production builds:**
|
|
424
|
+
|
|
425
|
+
- This option is completely ignored, all configured remotes are included in the bundle
|
|
416
426
|
|
|
417
427
|
**Example:**
|
|
418
428
|
|
|
@@ -428,7 +438,7 @@ Module Federation is a Webpack 5 feature that enables micro-frontend architectur
|
|
|
428
438
|
|
|
429
439
|
```bash
|
|
430
440
|
# Override enabledRemotes from command line
|
|
431
|
-
npx app-builder dev --mf-remotes
|
|
441
|
+
npx app-builder dev --mf-remotes header navigation
|
|
432
442
|
```
|
|
433
443
|
|
|
434
444
|
**Note:** This option has no effect in production builds - all configured remotes will be included in the production bundle configuration.
|
|
@@ -475,6 +485,12 @@ Module Federation is a Webpack 5 feature that enables micro-frontend architectur
|
|
|
475
485
|
- **Rollback capability**: Can load specific versions of remotes
|
|
476
486
|
- **Deployment safety**: Gradual rollouts with version-specific remote loading
|
|
477
487
|
|
|
488
|
+
**Important considerations:**
|
|
489
|
+
|
|
490
|
+
- **Without CDN**: Version is inlined immediately during build time, as single build cannot contain multiple application versions
|
|
491
|
+
- **With CDN**: True runtime versioning is possible, versions are resolved dynamically at runtime
|
|
492
|
+
- **Recommendation**: Use `remotesRuntimeVersioning` together with CDN configuration for full dynamic versioning capabilities
|
|
493
|
+
|
|
478
494
|
**Example with versioning enabled:**
|
|
479
495
|
|
|
480
496
|
```ts
|
|
@@ -690,7 +706,7 @@ export default defineConfig({
|
|
|
690
706
|
npx app-builder dev
|
|
691
707
|
|
|
692
708
|
# Start host with only specific remotes (faster development)
|
|
693
|
-
npx app-builder dev --mf-remotes
|
|
709
|
+
npx app-builder dev --mf-remotes header sidebar
|
|
694
710
|
|
|
695
711
|
# The above is equivalent to setting enabledRemotes in config:
|
|
696
712
|
# enabledRemotes: ['header', 'sidebar']
|
package/dist/common/config.js
CHANGED
|
@@ -196,8 +196,8 @@ async function normalizeClientConfig(client, mode) {
|
|
|
196
196
|
let publicPath = client.publicPath || path.normalize(`${client.publicPathPrefix || ''}/build/`);
|
|
197
197
|
let browserPublicPath = (mode !== 'dev' && cdnConfig?.publicPath) || publicPath;
|
|
198
198
|
if (client.moduleFederation) {
|
|
199
|
-
publicPath =
|
|
200
|
-
browserPublicPath =
|
|
199
|
+
publicPath = `${publicPath}${client.moduleFederation.name}/`;
|
|
200
|
+
browserPublicPath = `${browserPublicPath}${client.moduleFederation.name}/`;
|
|
201
201
|
}
|
|
202
202
|
let transformCssWithLightningCss = Boolean(client.transformCssWithLightningCss);
|
|
203
203
|
if (client.moduleFederation?.isolateStyles && transformCssWithLightningCss) {
|
|
@@ -963,8 +963,9 @@ function configureCommonPlugins(options, bundlerPlugins) {
|
|
|
963
963
|
}
|
|
964
964
|
plugins.push(createMomentTimezoneDataPlugin(config.momentTz));
|
|
965
965
|
if (config.moduleFederation) {
|
|
966
|
-
const { name, version, disableManifest, remotes,
|
|
966
|
+
const { name, version, disableManifest, remotes, originalRemotes, remotesRuntimeVersioning, isolateStyles: _isolateStyles, // Omit isolateStyles from restOptions
|
|
967
967
|
runtimePlugins, ...restOptions } = config.moduleFederation;
|
|
968
|
+
const enabledRemotes = (isEnvDevelopment && config.moduleFederation.enabledRemotes) || remotes;
|
|
968
969
|
let actualRemotes = originalRemotes;
|
|
969
970
|
if (!actualRemotes && remotes && enabledRemotes) {
|
|
970
971
|
// Remove micro-frontend name from public path
|
|
@@ -986,7 +987,8 @@ function configureCommonPlugins(options, bundlerPlugins) {
|
|
|
986
987
|
}
|
|
987
988
|
actualRemotes = remotes.reduce((acc, remote) => {
|
|
988
989
|
let remotePath;
|
|
989
|
-
|
|
990
|
+
// Use local paths when CDN is disabled, regardless of environment
|
|
991
|
+
if (!config.cdn) {
|
|
990
992
|
if (enabledRemotes.includes(remote)) {
|
|
991
993
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
992
994
|
remotePath = `${commonPublicPath}${remote}/${remoteFile.replace('[version]', version)}`;
|