diff --git a/src/utils/normalizeModuleFederationOptions.ts b/src/utils/normalizeModuleFederationOptions.ts index 2bed5f8..5e827ad 100644 --- a/src/utils/normalizeModuleFederationOptions.ts +++ b/src/utils/normalizeModuleFederationOptions.ts @@ -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 { @@ -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 {}; @@ -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; @@ -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', }); } diff --git a/src/virtualModules/virtualRemoteEntry.ts b/src/virtualModules/virtualRemoteEntry.ts index bfcee9e..af7bc25 100644 --- a/src/virtualModules/virtualRemoteEntry.ts +++ b/src/virtualModules/virtualRemoteEntry.ts @@ -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)}, @@ -81,13 +81,13 @@ 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)}, @@ -95,8 +95,8 @@ export function generateLocalSharedImportMap() { entry: ${JSON.stringify(remote.entry)}, } `; - }) - .join(',')} + }) + .join(',')} ] export { usedShared,