Skip to content

feat(lightspeed): expose dedicated NFS module federation entry points for FAB and translations#3512

Closed
its-mitesh-kumar wants to merge 3 commits into
redhat-developer:mainfrom
its-mitesh-kumar:app-defaults/new-app-defaults-module
Closed

feat(lightspeed): expose dedicated NFS module federation entry points for FAB and translations#3512
its-mitesh-kumar wants to merge 3 commits into
redhat-developer:mainfrom
its-mitesh-kumar:app-defaults/new-app-defaults-module

Conversation

@its-mitesh-kumar

Copy link
Copy Markdown
Member

Description

This PR adds dedicated Module Federation entry points for the Lightspeed FAB (Floating Action Button) module and the Translations module, and fixes a React Context duplication bug that occurs across MF chunk boundaries in the New Frontend System (NFS).

These changes are required because dynamicFrontendFeaturesLoader() in Backstage NFS only loads default exports from each exposed module. The existing lightspeedFABModule and lightspeedTranslationsModule are named exports from ./src/alpha/index.tsx, which means they cannot be discovered and loaded by the NFS dynamic plugin loader without a dedicated entry point that re-exports them as default.

Gaps / Reasons for Each Change

File Gap / Reason
src/alpha/lightspeedFABModuleExport.ts NFS loader only loads default exports. The lightspeedFABModule (which provides the AppRootWrapperBlueprint for the FAB button) was a named export and therefore invisible to dynamicFrontendFeaturesLoader. This file re-exports it as default.
src/alpha/lightspeedTranslationsModuleExport.ts Same gap for translations. The lightspeedTranslationsModule (which registers TranslationBlueprint resources for multi-language support) was also only a named export. This file provides the required default export.
package.json (exports, typesVersions, scalprum) Module Federation container registration. Without entries in scalprum.exposedModules, the RHDH CLI cannot build these files as separate MF containers. Without exports/typesVersions, TypeScript consumers cannot import the subpath modules.
src/components/LightspeedDrawerContext.tsx React Context duplication across MF boundaries. In Module Federation, each remote chunk gets its own module scope, causing createContext() to create duplicate Context instances. The "Dock to Window" display mode failed with useLightspeedDrawerContext must be used within a LightspeedDrawerProvider because the provider and consumer used different Context objects. The globalThis singleton pattern ensures a single shared Context instance across all MF chunks.

How to enable in NFS mode

After deploying the rebuilt dynamic plugin, add to app-config.yaml:

app:
  extensions:
    - app-root-wrapper:app/drawer
    - app-root-wrapper:app/lightspeed-fab
    - translation:app/lightspeed-translations
    - api:app/app-language:
        config:
          availableLanguages: ['en', 'de', 'es', 'fr', 'it', 'ja']
          defaultLanguage: 'en'

Fixed

  • TODO (no Jira ticket provided)

✔️ Checklist

  • A changeset describing the change and affected packages. (more info)
  • Added or Updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)

Made with Cursor

christoph-jerolimov and others added 3 commits June 18, 2026 09:29
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Christoph Jerolimov <jerolimov+git@redhat.com>
Move ApplicationDrawer and DrawerPanel components into app-defaults and
re-export appDrawerExtensions from the new module. The app-react package
now only exposes the public API surface (hooks, blueprints, data refs,
types) while app-defaults owns the concrete extension wiring.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Christoph Jerolimov <jerolimov+git@redhat.com>
… for FAB and translations

- Add lightspeedFABModuleExport.ts and lightspeedTranslationsModuleExport.ts
  as dedicated default-export entry points required by dynamicFrontendFeaturesLoader
- Update package.json exports, typesVersions, and scalprum.exposedModules to
  register both modules as separate Module Federation containers
- Fix React Context duplication across MF boundaries using globalThis singleton
  pattern in LightspeedDrawerContext, resolving "useLightspeedDrawerContext must
  be used within a LightspeedDrawerProvider" error in Dock-to-Window mode

Signed-off-by: its-mitesh-kumar <itsmiteshkumar98@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

Copy link
Copy Markdown
Contributor

This pull request adds a new top-level directory under workspaces/. Please follow Submitting a Pull Request for a New Workspace in CONTRIBUTING.md.

@rhdh-gh-app

rhdh-gh-app Bot commented Jun 20, 2026

Copy link
Copy Markdown

Important

This PR includes changes that affect public-facing API. Please ensure you are adding/updating documentation for new features or behavior.

Missing Changesets

The following package(s) are changed by this PR but do not have a changeset:

  • @red-hat-developer-hub/backstage-plugin-app-defaults
  • @red-hat-developer-hub/backstage-plugin-app-react

See CONTRIBUTING.md for more information about how to add changesets.

Changed Packages

Package Name Package Path Changeset Bump Current Version
app workspaces/app-defaults/packages/app none v0.0.0
@red-hat-developer-hub/backstage-plugin-app-defaults workspaces/app-defaults/plugins/app-defaults none v0.0.0
@red-hat-developer-hub/backstage-plugin-app-react workspaces/app-defaults/plugins/app-react none v0.0.5
@red-hat-developer-hub/backstage-plugin-lightspeed workspaces/lightspeed/plugins/lightspeed minor v2.9.1

@codecov

codecov Bot commented Jun 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 54.02%. Comparing base (efb4c4f) to head (7658e52).
⚠️ Report is 63 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3512      +/-   ##
==========================================
- Coverage   54.02%   54.02%   -0.01%     
==========================================
  Files        2409     2410       +1     
  Lines       87733    87777      +44     
  Branches    24306    24303       -3     
==========================================
+ Hits        47400    47418      +18     
- Misses      38812    38838      +26     
  Partials     1521     1521              
Flag Coverage Δ *Carryforward flag
adoption-insights 83.58% <ø> (ø) Carriedforward from efb4c4f
ai-integrations 70.03% <ø> (ø) Carriedforward from efb4c4f
app-defaults 69.33% <ø> (-0.28%) ⬇️ Carriedforward from efb4c4f
augment 46.39% <ø> (ø) Carriedforward from efb4c4f
bulk-import 72.69% <ø> (ø) Carriedforward from efb4c4f
cost-management 17.48% <ø> (ø) Carriedforward from efb4c4f
dcm 60.27% <ø> (ø) Carriedforward from efb4c4f
extensions 62.17% <ø> (ø) Carriedforward from efb4c4f
global-floating-action-button 74.30% <ø> (ø) Carriedforward from efb4c4f
global-header 61.63% <ø> (ø) Carriedforward from efb4c4f
homepage 52.60% <ø> (ø) Carriedforward from efb4c4f
install-dynamic-plugins 56.23% <ø> (ø) Carriedforward from efb4c4f
konflux 91.01% <ø> (ø) Carriedforward from efb4c4f
lightspeed 68.42% <90.00%> (-0.21%) ⬇️
mcp-integrations 85.46% <ø> (ø) Carriedforward from efb4c4f
orchestrator 37.33% <ø> (ø) Carriedforward from efb4c4f
quickstart 62.09% <ø> (ø) Carriedforward from efb4c4f
sandbox 79.56% <ø> (ø) Carriedforward from efb4c4f
scorecard 83.93% <ø> (ø) Carriedforward from efb4c4f
theme 64.44% <ø> (ø) Carriedforward from efb4c4f
translations 8.49% <ø> (ø) Carriedforward from efb4c4f
x2a 78.79% <ø> (ø) Carriedforward from efb4c4f

*This pull request uses carry forward flags. Click here to find out more.


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update efb4c4f...7658e52. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@its-mitesh-kumar

Copy link
Copy Markdown
Member Author

Closing in favor of #3513

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants