Skip to content

Commit

Permalink
fix: hotfix important bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangHongEn committed Oct 12, 2024
1 parent c624f2d commit 1e8ed04
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 47 deletions.
66 changes: 33 additions & 33 deletions src/utils/normalizeModuleFederationOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ function normalizeShareItem(
shareItem:
| string
| {
name: string;
version?: string;
shareScope?: string;
singleton?: boolean;
requiredVersion?: string;
strictVersion?: boolean;
}
name: string;
version?: string;
shareScope?: string;
singleton?: boolean;
requiredVersion?: string;
strictVersion?: boolean;
}
): ShareItem {
let version: string | undefined;
try {
Expand Down Expand Up @@ -165,17 +165,17 @@ function normalizeShared(
shared:
| string[]
| Record<
string,
| string
| {
name?: string;
version?: string;
shareScope?: string;
singleton?: boolean;
requiredVersion?: string;
strictVersion?: boolean;
}
>
string,
| string
| {
name?: string;
version?: string;
shareScope?: string;
singleton?: boolean;
requiredVersion?: string;
strictVersion?: boolean;
}
>
| undefined
): NormalizedShared {
if (!shared) return {};
Expand Down Expand Up @@ -229,20 +229,20 @@ export type ModuleFederationOptions = {
runtime?: any;
shareScope?: string;
shared?:
| string[]
| Record<
string,
| string
| {
name?: string;
version?: string;
shareScope?: string;
singleton?: boolean;
requiredVersion?: string;
strictVersion?: boolean;
}
>
| undefined;
| string[]
| Record<
string,
| string
| {
name?: string;
version?: string;
shareScope?: string;
singleton?: boolean;
requiredVersion?: string;
strictVersion?: boolean;
}
>
| undefined;
runtimePlugins?: string[];
getPublicPath?: string;
implementation?: any;
Expand Down Expand Up @@ -343,6 +343,6 @@ export function normalizeModuleFederationOptions(
dev: options.dev,
dts: options.dts,
getPublicPath: options.getPublicPath,
shareStrategy: options.shareStrategy || "version-first",
shareStrategy: options.shareStrategy || 'version-first',
});
}
28 changes: 14 additions & 14 deletions src/virtualModules/virtualRemoteEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,21 @@ export function generateLocalSharedImportMap() {
return `
const importMap = {
${Array.from(getUsedShares())
.map(
(pkg) => `
.map(
(pkg) => `
${JSON.stringify(pkg)}: async () => {
let pkg = await import("${getPreBuildLibImportId(pkg)}")
return pkg
}
`
)
.join(',')}
)
.join(',')}
}
const usedShared = {
${Array.from(getUsedShares())
.map((key) => {
const shareItem = getNormalizeShareItem(key);
return `
.map((key) => {
const shareItem = getNormalizeShareItem(key);
return `
${JSON.stringify(key)}: {
name: ${JSON.stringify(key)},
version: ${JSON.stringify(shareItem.version)},
Expand All @@ -81,22 +81,22 @@ export function generateLocalSharedImportMap() {
}
}
`;
})
.join(',')}
})
.join(',')}
}
const usedRemotes = [${Object.keys(getUsedRemotesMap())
.map((key) => {
const remote = options.remotes[key];
return `
.map((key) => {
const remote = options.remotes[key];
return `
{
entryGlobalName: ${JSON.stringify(remote.entryGlobalName)},
name: ${JSON.stringify(remote.name)},
type: ${JSON.stringify(remote.type)},
entry: ${JSON.stringify(remote.entry)},
}
`;
})
.join(',')}
})
.join(',')}
]
export {
usedShared,
Expand Down

0 comments on commit 1e8ed04

Please sign in to comment.