Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support consume manifest #1964

Closed
2 tasks done
2heal1 opened this issue Jan 15, 2024 · 0 comments
Closed
2 tasks done

Support consume manifest #1964

2heal1 opened this issue Jan 15, 2024 · 0 comments
Assignees
Labels
✨ enhancement New feature or request

Comments

@2heal1
Copy link
Member

2heal1 commented Jan 15, 2024

Clear and concise description of the problem

Now module federation just support consume url , and we can not get more info from url .

This prevents us from doing some performance optimization and function expansion, such as prefetch, type hints and so on .

If we can get more info like data assets, we can do more features .

Suggested solution

We can support consume manifest url . The manifest can recored data assets/version/type files . And we can load manifest to get these infos , and then do some features as we need .

Basic Usage

  • generate manifest

set options.manifest as true to enable generate manifest

import { ModuleFederationPlugin } from '@moduel-federation/universe';

new ModuleFederationPlugin({
  manifest: true
});
  • consume manifest

set remote value url as manifest url :

import { ModuleFederationPlugin } from '@moduel-federation/universe';

new ModuleFederationPlugin({
    remotes: {
      remote1: 'webpack_provider@http://localhost:3009/mf-manifest.json',
      'manifest-provider':
        'rspack_manifest_provider@http://localhost:3011/mf-manifest.json',
      'js-entry-provider':
        'rspack_js_entry_provider@http://localhost:3012/remoteEntry.js',
    },
});

Detail Design

The manifest has mainly four parts : metaDataremotesexposesshared .

  • metaData: record provider self info like publicPathremoteEntry and so on
  • exposes: record expose file asstesrequires(shared) and so on
  • shared: record shared assetsusedIn(exposes) and so on
  • remotes: record remote entryuesdIn and so on
What can we do with this data?
  1. Optimize performance

We can preload the remote assets though manifest.expose/shared.assets in these scens:

  • loadRemote: When users call loadRemote or just import remote , we can auto preload assets in runtime hooks
  • Idle time: Users can manually call preloadRemote in idle time.
  • framework router: Now modern framework almost have loaders which can help to preload current route mf module assets .
  1. Analyze reference relationships between modules

Because manifest has remotes and exposes fields , so we can easily know the relationship , and we can use it to draw a complete reference diagram.

  1. Cooperate with the deployment platform for data distribution to improve performance

If users have PageServer , they can use manifest to deliver complete dependencies , and with this it can also make version/tag for MF modules.

Alternative

No response

Additional context

No response

Validations

  • Read the Contributing Guidelines.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
@2heal1 2heal1 self-assigned this Jan 15, 2024
@2heal1 2heal1 added the ✨ enhancement New feature or request label Jan 15, 2024
@2heal1 2heal1 closed this as completed Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant