@capillarytech/blaze-ui 2.8.0 → 2.9.0
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/CapImportMFEComponent/CapImportMFEComponent.d.ts +5 -0
- package/dist/CapImportMFEComponent/CapImportMFEComponent.d.ts.map +1 -0
- package/dist/CapImportMFEComponent/CapImportMFEComponent.interfaces.d.ts +12 -0
- package/dist/CapImportMFEComponent/CapImportMFEComponent.interfaces.d.ts.map +1 -0
- package/dist/CapImportMFEComponent/README.md +121 -0
- package/dist/CapImportMFEComponent/index.d.ts +3 -0
- package/dist/CapImportMFEComponent/index.d.ts.map +1 -0
- package/dist/CapImportMFEComponent/index.js +2425 -0
- package/dist/CapImportMFEComponent/index.js.map +1 -0
- package/dist/CapImportMFEComponent/messages.d.ts +16 -0
- package/dist/CapImportMFEComponent/messages.d.ts.map +1 -0
- package/dist/CapImportMFEComponent/tests/CapImportMFEComponent.mockData.d.ts +11 -0
- package/dist/CapImportMFEComponent/tests/CapImportMFEComponent.mockData.d.ts.map +1 -0
- package/dist/CapImportMFEComponent/tests/CapImportMFEComponent.test.d.ts +2 -0
- package/dist/CapImportMFEComponent/tests/CapImportMFEComponent.test.d.ts.map +1 -0
- package/dist/CapSomethingWentWrong/CapSomethingWentWrong.interfaces.d.ts +4 -3
- package/dist/CapSomethingWentWrong/CapSomethingWentWrong.interfaces.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +800 -1
- package/dist/index.js.map +1 -1
- package/package.json +7 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CapImportMFEComponentProps } from './CapImportMFEComponent.interfaces';
|
|
3
|
+
declare const CapImportMFEComponent: React.FC<CapImportMFEComponentProps>;
|
|
4
|
+
export default CapImportMFEComponent;
|
|
5
|
+
//# sourceMappingURL=CapImportMFEComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CapImportMFEComponent.d.ts","sourceRoot":"","sources":["../../components/CapImportMFEComponent/CapImportMFEComponent.tsx"],"names":[],"mappings":"AACA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAMvC,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAIhF,QAAA,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CA2C/D,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface CapImportMFESystem {
|
|
3
|
+
url: string | (() => Promise<string>);
|
|
4
|
+
scope: string;
|
|
5
|
+
module: string;
|
|
6
|
+
}
|
|
7
|
+
export interface CapImportMFEComponentProps {
|
|
8
|
+
system?: CapImportMFESystem;
|
|
9
|
+
loadingFallback?: React.ReactElement | string;
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=CapImportMFEComponent.interfaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CapImportMFEComponent.interfaces.d.ts","sourceRoot":"","sources":["../../components/CapImportMFEComponent/CapImportMFEComponent.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,GAAG,CAAC,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,0BAA0B;IACzC,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,eAAe,CAAC,EAAE,KAAK,CAAC,YAAY,GAAG,MAAM,CAAC;IAC9C,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# CapImportMFEComponent
|
|
2
|
+
|
|
3
|
+
A React component for dynamically importing and rendering remote components using Module Federation (MFE). This component requires Webpack 5 and Module Federation support.
|
|
4
|
+
|
|
5
|
+
## Migration from cap-ui-library to blaze-ui
|
|
6
|
+
|
|
7
|
+
### Summary of Changes
|
|
8
|
+
|
|
9
|
+
- **Styled-components → SCSS Modules**: Converted from styled-components to SCSS modules for better performance and maintainability
|
|
10
|
+
- **TypeScript**: Added full TypeScript support with proper type definitions
|
|
11
|
+
- **Functional Component**: Already a functional component, maintained with React hooks
|
|
12
|
+
- **Prop Types**: Replaced PropTypes with TypeScript interfaces
|
|
13
|
+
- **Error Display**: Uses original `CapSomethingWentWrong` component from cap-ui-library
|
|
14
|
+
- **Translation**: Updated translation scope from `components.CapImportMFECOmponent` to `blaze.components.CapImportMFEComponent`
|
|
15
|
+
|
|
16
|
+
### Props
|
|
17
|
+
|
|
18
|
+
| Prop | Type | Required | Description |
|
|
19
|
+
|------|------|----------|-------------|
|
|
20
|
+
| `system` | `CapImportMFESystem` | Yes | Configuration object for the remote module |
|
|
21
|
+
| `system.url` | `string \| (() => Promise<string>)` | Yes | URL of the remote module (can be a string or async function) |
|
|
22
|
+
| `system.scope` | `string` | Yes | Module Federation scope name |
|
|
23
|
+
| `system.module` | `string` | Yes | Module name to import from the remote |
|
|
24
|
+
| `loadingFallback` | `React.ReactElement \| string` | No | Custom loading fallback component or string |
|
|
25
|
+
| `...rest` | `unknown` | No | Additional props passed to the imported component |
|
|
26
|
+
|
|
27
|
+
### Breaking Changes
|
|
28
|
+
|
|
29
|
+
**No breaking changes from cap-ui-library v8.x**
|
|
30
|
+
|
|
31
|
+
All existing props and behaviors are maintained. The API remains identical.
|
|
32
|
+
|
|
33
|
+
### Behavioral Changes
|
|
34
|
+
|
|
35
|
+
- Error display uses original `CapSomethingWentWrong` component from cap-ui-library
|
|
36
|
+
- Styles are now defined using SCSS modules with variables for consistency
|
|
37
|
+
- Translation scope updated to follow blaze-ui naming conventions
|
|
38
|
+
|
|
39
|
+
### Usage
|
|
40
|
+
|
|
41
|
+
#### Basic Usage
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
import { CapImportMFEComponent } from '@capillarytech/blaze-ui';
|
|
45
|
+
|
|
46
|
+
<CapImportMFEComponent
|
|
47
|
+
system={{
|
|
48
|
+
url: 'https://remote-app.example.com/remoteEntry.js',
|
|
49
|
+
scope: 'remoteApp',
|
|
50
|
+
module: './Component',
|
|
51
|
+
}}
|
|
52
|
+
/>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
#### With Custom Loading Fallback
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
<CapImportMFEComponent
|
|
59
|
+
system={{
|
|
60
|
+
url: 'https://remote-app.example.com/remoteEntry.js',
|
|
61
|
+
scope: 'remoteApp',
|
|
62
|
+
module: './Component',
|
|
63
|
+
}}
|
|
64
|
+
loadingFallback={<div>Custom loading...</div>}
|
|
65
|
+
/>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
#### With Dynamic URL Function
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
<CapImportMFEComponent
|
|
72
|
+
system={{
|
|
73
|
+
url: async () => {
|
|
74
|
+
const config = await fetch('/api/config').then(r => r.json());
|
|
75
|
+
return config.remoteUrl;
|
|
76
|
+
},
|
|
77
|
+
scope: 'remoteApp',
|
|
78
|
+
module: './Component',
|
|
79
|
+
}}
|
|
80
|
+
/>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
#### Passing Props to Remote Component
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
<CapImportMFEComponent
|
|
87
|
+
system={{
|
|
88
|
+
url: 'https://remote-app.example.com/remoteEntry.js',
|
|
89
|
+
scope: 'remoteApp',
|
|
90
|
+
module: './Component',
|
|
91
|
+
}}
|
|
92
|
+
customProp="value"
|
|
93
|
+
onClick={handleClick}
|
|
94
|
+
/>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Import Examples
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
// Named import (recommended)
|
|
101
|
+
import { CapImportMFEComponent } from '@capillarytech/blaze-ui';
|
|
102
|
+
|
|
103
|
+
// With types
|
|
104
|
+
import type { CapImportMFEComponentProps, CapImportMFESystem } from '@capillarytech/blaze-ui';
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Requirements
|
|
108
|
+
|
|
109
|
+
- **Webpack 5**: This component requires Webpack 5 with Module Federation plugin
|
|
110
|
+
- **Module Federation**: The remote application must be configured with Module Federation
|
|
111
|
+
- **@module-federation/utilities**: The `importRemote` utility from `@module-federation/utilities` is required
|
|
112
|
+
|
|
113
|
+
### Error Handling
|
|
114
|
+
|
|
115
|
+
If the `system` prop is missing required fields (`url`, `scope`, or `module`), the component will display an error message using `CapError` and `CapHeading` components.
|
|
116
|
+
|
|
117
|
+
### Notes
|
|
118
|
+
|
|
119
|
+
- This component uses `React.lazy` and `React.Suspense` for code splitting
|
|
120
|
+
- The remote component is memoized based on `url`, `scope`, and `module` values
|
|
121
|
+
- All additional props passed to `CapImportMFEComponent` are forwarded to the imported remote component
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../components/CapImportMFEComponent/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,YAAY,EACV,0BAA0B,EAC1B,kBAAkB,GACnB,MAAM,oCAAoC,CAAC"}
|