Skip to content

Commit 0eee35e

Browse files
authored
Merge pull request #63 from ClayPulse/hotfix
Hotfix mfversion is undefined
2 parents 10b035e + 363be09 commit 0eee35e

File tree

4 files changed

+22
-15
lines changed

4 files changed

+22
-15
lines changed

web/components/extension/extension-preview.tsx

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ export default function ExtensionPreview({
5656

5757
const [isShowInfo, setIsShowInfo] = useState(false);
5858

59-
const [hostMFVersion, setHostMFVersion] = useState<string>("unknown");
59+
const [hostMFVersion, setHostMFVersion] = useState<string | undefined>(
60+
undefined,
61+
);
6062
const [showMFVersionInfo, setShowMFVersionInfo] = useState(false);
6163

6264
useEffect(() => {
@@ -75,8 +77,6 @@ export default function ExtensionPreview({
7577
);
7678
setIsInstalled(foundExt !== undefined);
7779
setIsEnabled(foundExt?.isEnabled ?? false);
78-
79-
console.log("Extension preview loaded", extension);
8080
}, [extension]);
8181

8282
function toggleExtension() {
@@ -122,7 +122,9 @@ export default function ExtensionPreview({
122122
<EnableCheckBox isActive={isEnabled} onPress={toggleExtension} />
123123
)}
124124

125-
{extension.mfVersion === "unknown" ? (
125+
{hostMFVersion === undefined ||
126+
extension.mfVersion === undefined ||
127+
extension.mfVersion === "unknown" ? (
126128
<Popover
127129
isOpen={showMFVersionInfo}
128130
onOpenChange={setShowMFVersionInfo}
@@ -182,10 +184,9 @@ export default function ExtensionPreview({
182184
<div className="max-w-xs">
183185
<p>
184186
This app's module federation version (
185-
{extension.mfVersion}) does not match the host
186-
version ({hostMFVersion}). This may cause issues when
187-
using the app. Please update the app to the latest
188-
version.
187+
{extension.mfVersion}) does not match the host version (
188+
{hostMFVersion}). This may cause issues when using the
189+
app. Please update the app to the latest version.
189190
</p>
190191
</div>
191192
</PopoverContent>
@@ -271,9 +272,13 @@ export default function ExtensionPreview({
271272
{isShowInfo && (
272273
<div className="absolute bottom-0.5 left-1/2 flex w-full -translate-x-1/2 justify-center gap-x-0.5">
273274
{isShowUseButton && (
274-
<Button color="primary" size="sm" onPress={() => {
275-
onPress?.(extension);
276-
}}>
275+
<Button
276+
color="primary"
277+
size="sm"
278+
onPress={() => {
279+
onPress?.(extension);
280+
}}
281+
>
277282
Use
278283
</Button>
279284
)}

web/lib/hooks/use-extension-manager.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ export default function useExtensionManager() {
2929

3030
const hostMFVersion = await getHostMFVersion();
3131

32-
if (compare(remoteMFVersion, hostMFVersion) !== 0) {
32+
if (!remoteMFVersion) {
33+
throw new Error("Remote MF version is undefined");
34+
} else if (compare(remoteMFVersion, hostMFVersion) !== 0) {
3335
throw new Error(
3436
`Extension MF version ${remoteMFVersion} is not compatible with host MF version ${hostMFVersion}`,
3537
);

web/lib/module-federation/version.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export async function getRemoteMFVersion(
99
remoteOrigin: string,
1010
id: string,
1111
version: string,
12-
): Promise<string> {
12+
): Promise<string | undefined> {
1313
try {
1414
const mfManifest = await fetch(
1515
`${getRemoteClientBaseURL(remoteOrigin, id, version)}/mf-manifest.json`,
@@ -18,6 +18,6 @@ export async function getRemoteMFVersion(
1818
return mfManifestJson.metaData.pluginVersion;
1919
} catch (error) {
2020
console.warn("Error fetching remote MF version:", error);
21-
return "unknown";
21+
return undefined;
2222
}
2323
}

web/lib/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ export type Extension = {
302302
config: ExtensionConfig;
303303
isEnabled: boolean;
304304
remoteOrigin: string;
305-
mfVersion: string;
305+
mfVersion?: string;
306306

307307
// These are commands that can be used without initializing an app.
308308
// These commands are always available once the extension is loaded and enabled.

0 commit comments

Comments
 (0)