Creating Widget from Existing Widget
This guide covers how to fork or adapt an existing widget to create a new one.
Overview
While creating widgets from the template is the recommended approach, you may sometimes want to create a new widget based on an existing one. This is useful when:
- You need to create a variant of an existing widget
- You want to fork a widget for customization
- You're migrating a widget to a new repository
Recommended: Use Template Instead
For most use cases, we recommend using the widget template:
Creating Widget from Template - Complete step-by-step guide
The template provides:
- Latest platform dependencies
- Correct configuration structure
- Pre-configured build system
- Example code and tests
When to Fork an Existing Widget
Fork an existing widget when you need to:
-
Create a Variant
- Similar functionality with different data source
- Same UI with different configuration
- Customized version for specific use case
-
Vendor Customization
- Fork a core widget for vendor-specific changes
- Maintain separate version with custom features
-
Migration
- Move widget to new repository
- Transfer ownership to different team
Forking Process
1. Fork the Repository
In GitLab:
- Navigate to the source widget repository
- Click Fork button
- Select your vendor's subgroup (
widgets-vendorName) - Update repository name:
widgets-vendorName-newWidgetName
2. Update Configuration
Update the following files with new widget identity:
widget-config.json
{
"widgetDetails": {
"name": "VendorNewWidgetName",
"id": "new-widget-id",
"port": 5XXX, // Use new GitLab Project ID
"widgetType": 1,
...
}
}
Important: Update name, id, and port to match the new widget.
package.json
{
"name": "@invent/widgets-vendor-new-widget-name",
"scripts": {
"start_federation": "webpack serve --port 5XXX ..."
}
}
Update package name and port.
build-vars.js
PORT: process.env.PORT || 5XXX
Match port to GitLab Project ID.