core icon indicating copy to clipboard operation
core copied to clipboard

change @module-federation/runtime to Other in dts

Open ckken opened this issue 3 weeks ago • 1 comments

Clear and concise description of the problem

import type { PackageType as PackageType_0,RemoteKeys as RemoteKeys_0 } from './rtProvider/apis.d.ts';
    declare module "@module-federation/runtime" {
      type RemoteKeys = RemoteKeys_0;
      type PackageType<T, Y=any> = T extends RemoteKeys_0 ? PackageType_0<T> :
Y ;
      export function loadRemote<T extends RemoteKeys,Y>(packageName: T): Promise<PackageType<T, Y>>;
      export function loadRemote<T extends string,Y>(packageName: T): Promise<PackageType<T, Y>>;
    }
declare module "@module-federation/enhanced/runtime" {
      type RemoteKeys = RemoteKeys_0;
      type PackageType<T, Y=any> = T extends RemoteKeys_0 ? PackageType_0<T> :
Y ;
      export function loadRemote<T extends RemoteKeys,Y>(packageName: T): Promise<PackageType<T, Y>>;
      export function loadRemote<T extends string,Y>(packageName: T): Promise<PackageType<T, Y>>;
    }
declare module "@module-federation/runtime-tools" {
      type RemoteKeys = RemoteKeys_0;
      type PackageType<T, Y=any> = T extends RemoteKeys_0 ? PackageType_0<T> :
Y ;
      export function loadRemote<T extends RemoteKeys,Y>(packageName: T): Promise<PackageType<T, Y>>;
      export function loadRemote<T extends string,Y>(packageName: T): Promise<PackageType<T, Y>>;
    }
    

Suggested solution

import type { PackageType as PackageType_0,RemoteKeys as RemoteKeys_0 } from './rtProvider/apis.d.ts';
    declare module "@my-plugin-name/runtime" {
      type RemoteKeys = RemoteKeys_0;
      type PackageType<T, Y=any> = T extends RemoteKeys_0 ? PackageType_0<T> :
Y ;
      export function loadRemote<T extends RemoteKeys,Y>(packageName: T): Promise<PackageType<T, Y>>;
      export function loadRemote<T extends string,Y>(packageName: T): Promise<PackageType<T, Y>>;
    }
declare module "@my-plugin-name/enhanced/runtime" {
      type RemoteKeys = RemoteKeys_0;
      type PackageType<T, Y=any> = T extends RemoteKeys_0 ? PackageType_0<T> :
Y ;
      export function loadRemote<T extends RemoteKeys,Y>(packageName: T): Promise<PackageType<T, Y>>;
      export function loadRemote<T extends string,Y>(packageName: T): Promise<PackageType<T, Y>>;
    }
declare module "@my-plugin-name/runtime-tools" {
      type RemoteKeys = RemoteKeys_0;
      type PackageType<T, Y=any> = T extends RemoteKeys_0 ? PackageType_0<T> :
Y ;
      export function loadRemote<T extends RemoteKeys,Y>(packageName: T): Promise<PackageType<T, Y>>;
      export function loadRemote<T extends string,Y>(packageName: T): Promise<PackageType<T, Y>>;
    }
    

Alternative

Because of workflow requirements, the entire plugin has already been encapsulated in the CLI, eliminating the need for repeated installations and providing excellent version management. The current requirement is to enable DTS customization within the plugin, allowing for DTS customization without modifying the source code:

import {getInstance,loadRemote} from '@my-plugin-name/runtime'
loadRemote('component/app') <- work

and

mf = createInstance()
mf.loadRemote('component/app') <- no work

Additional context

No response

Validations

  • [x] Read the Contributing Guidelines.
  • [x] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

ckken avatar Dec 26 '25 11:12 ckken