-
-
Notifications
You must be signed in to change notification settings - Fork 257
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
chore: split runtime as core and entry #3154
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for module-federation-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary
Here is a concise summary of the pull request:
The core changes in this pull request involve splitting the runtime module into two parts: runtime-core
and entry
. The runtime-core
is designed to have no side effects, while the entry
part has side effects and will cache the federationInstance
. This separation aims to improve the modularity and maintainability of the runtime component.
The key changes include:
- Externalization of the
runtime-core
module, allowing it to be provided independently from theentry
module. - Addition of new configuration options to support the split runtime, including
externalRuntime
andprovideExternalRuntime
. - Refactoring of various utility functions, hooks, and handlers to accommodate the split runtime structure.
- Improvements to the overall structure and organization of the runtime-related code, with a focus on separation of concerns and modularity.
These changes are expected to enhance the integration of the runtime module with the existing codebase, providing more flexibility and better maintainability in the long run.
File Summaries
File | Summary |
---|---|
packages/enhanced/src/lib/container/ModuleFederationPlugin.ts | The code changes introduce a split of the runtime into two parts: runtime-core and entry. The runtime-core is designed to have no side effects, while the entry part has side effects and will cache the federationInstance. Additionally, the runtime-core is now externalized, and the code adds support for providing an external runtime core plugin and an external runtime configuration. |
packages/enhanced/src/schemas/container/ContainerPlugin.check.ts | The changes in this file split the runtime into two parts: runtime-core and entry. The runtime-core has no side effects, while the entry part has side effects and will cache the federationInstance. This change aims to externalize the runtime-core for better modularity and maintainability. |
packages/enhanced/src/schemas/container/ContainerPlugin.ts | The code changes introduce a new configuration option called "externalRuntime" to the ContainerPlugin schema. This option allows the runtime to be split into two parts: "runtime-core" and "entry". The "runtime-core" part has no side effects, while the "entry" part has side effects and will cache the federationInstance. |
packages/rspack/src/ModuleFederationPlugin.ts | The code changes introduce a split of the runtime into two parts: runtime-core and entry. The runtime-core is now external and has no side effects, while the entry part has side effects and caches the federation instance. Additionally, the changes introduce an option to provide an external runtime-core and externalize it from the bundle. |
packages/runtime-core/src/constant.ts | The changes in this file involve splitting the runtime into two parts: runtime-core and entry. The runtime-core module has no side effects, while the entry module has side effects and will cache the federationInstance. This separation aims to improve the overall structure and maintainability of the codebase. |
packages/runtime-core/src/core.ts | The code changes introduce a split of the runtime into two parts: runtime-core and entry . The runtime-core has no side effects, while the entry part has side effects and will cache the federationInstance . Additionally, the runtime-core is now externalized. The changes also include the addition of various hooks and handlers, such as SnapshotHandler , SharedHandler , and RemoteHandler , which handle different aspects of the runtime functionality. |
packages/runtime-core/src/global.ts | The code changes introduce a split of the runtime into two parts: runtime-core and entry . The runtime-core has no side effects, while the entry part has side effects and will cache the federationInstance . Additionally, the runtime-core is now externalized. |
packages/runtime-core/src/helpers.ts | The code changes introduce a new module that exports two utility objects: GlobalUtils and ShareUtils . The GlobalUtils object provides a collection of functions related to managing global state and information, such as setting and retrieving global federation instances, snapshots, and preloaded data. The ShareUtils object provides functions for managing shared module registrations and scopes. |
packages/runtime-core/src/index.ts | This code change splits the runtime into two parts: runtime-core and entry . The runtime-core has no side effects, while the entry part has side effects and will cache the federationInstance . The changes also externalize the runtime-core and update the exports to include various utility functions, types, and modules related to the federation runtime. |
packages/runtime-core/src/module/index.ts | The changes in this file involve splitting the runtime into two separate parts: runtime-core and entry. The runtime-core module is designed to have no side effects, while the entry module will handle caching the federation instance. This separation of concerns aims to improve the overall structure and maintainability of the codebase. |
packages/runtime-core/src/plugins/generate-preload-assets.ts | The changes in this file split the runtime into two parts: runtime-core and entry. The runtime-core module has no side effects, while the entry module has side effects and caches the federation instance. This separation allows for better modularity and flexibility in the codebase. |
packages/runtime-core/src/plugins/snapshot/SnapshotHandler.ts | The changes in this file split the runtime into two parts: runtime-core and entry. The runtime-core module has no side effects, while the entry module has side effects and caches the federation instance. This separation of concerns aims to improve the overall structure and maintainability of the codebase. |
packages/runtime-core/src/plugins/snapshot/index.ts | The code changes introduce a split of the runtime into two parts: runtime-core and entry. The runtime-core module has no side effects, while the entry module has side effects and will cache the federationInstance. |
packages/runtime-core/src/remote/index.ts | The changes in this file involve splitting the runtime into two separate parts: runtime-core and entry. The runtime-core module is designed to have no side effects, while the entry module will handle caching the federation instance. This separation of concerns aims to improve the overall structure and maintainability of the codebase. |
packages/runtime-core/src/shared/index.ts | The changes in this file involve splitting the runtime into two parts: runtime-core and entry. The runtime-core module is designed to have no side effects, while the entry module has side effects and will cache the federationInstance. |
packages/runtime-core/src/type/config.ts | The changes in this file involve splitting the runtime into two parts: runtime-core and entry. The runtime-core module is designed to have no side effects, while the entry module has side effects and will cache the federationInstance. This separation of concerns aims to improve the overall structure and maintainability of the codebase. |
packages/runtime-core/src/type/index.ts | This change separates the runtime into two parts: runtime-core and entry . The runtime-core module has no side effects, while the entry module has side effects and caches the federation instance. This refactoring aims to externalize the runtime-core module, potentially improving modularity and flexibility. |
packages/runtime-core/src/type/plugin.ts | The code changes introduce a split of the runtime into two parts: runtime-core and entry. The runtime-core is now externalized and has no side effects, while the entry part has side effects and will cache the federationInstance. |
packages/runtime-core/src/type/preload.ts | The changes in this file split the runtime into two parts: runtime-core and entry. The runtime-core module has no side effects, while the entry module has side effects and caches the federation instance. This separation of concerns improves the overall structure and maintainability of the codebase. |
packages/runtime-core/src/types.ts | The changes in this file involve the addition of a new export statement that re-exports all the types from the './type' module. This change likely aims to simplify the API and make it easier to access the necessary types from a single entry point. |
packages/runtime-core/src/utils/env.ts | The code changes introduce a split of the runtime into two parts: runtime-core and entry. The runtime-core is now externalized and has no side effects, while the entry part has side effects and will cache the federationInstance. |
packages/runtime-core/src/utils/hooks/asyncHook.ts | The changes in this file involve splitting the runtime into two parts: runtime-core and entry. The runtime-core module is designed to have no side effects, while the entry module has side effects and will cache the federationInstance. This separation aims to improve the overall structure and maintainability of the codebase. |
packages/runtime-core/src/utils/hooks/asyncWaterfallHooks.ts | The changes in this file split the runtime into two parts: runtime-core and entry. The runtime-core module has no side effects, while the entry module has side effects and caches the federation instance. This separation of concerns improves the overall structure and maintainability of the codebase. |
packages/runtime-core/src/utils/hooks/index.ts | The changes in this file involve splitting the runtime into two parts: runtime-core and entry. The runtime-core module is designed to have no side effects, while the entry module has side effects and will cache the federationInstance. |
packages/runtime-core/src/utils/hooks/pluginSystem.ts | The code changes introduce a split in the runtime module, separating it into a core part and an entry part. The core part has no side effects, while the entry part caches the federation instance. This change aims to improve the modularity and maintainability of the runtime component. |
packages/runtime-core/src/utils/hooks/syncHook.ts | The changes in this file split the runtime into two parts: runtime-core and entry. The runtime-core module has no side effects, while the entry module has side effects and caches the federation instance. This separation of concerns aims to improve the overall structure and maintainability of the codebase. |
packages/runtime-core/src/utils/hooks/syncWaterfallHook.ts | The code changes introduce a split of the runtime into two parts: runtime-core and entry. The runtime-core is now externalized and has no side effects, while the entry part has side effects and will cache the federationInstance. |
packages/runtime-core/src/utils/index.ts | The changes in this file involve splitting the runtime into two parts: runtime-core and entry. The runtime-core module is designed to have no side effects, while the entry module has side effects and will cache the federationInstance. This separation aims to improve the overall structure and maintainability of the codebase. |
packages/runtime-core/src/utils/load.ts | The changes in this file involve splitting the runtime into two parts: runtime-core and entry. The runtime-core module is designed to have no side effects, while the entry module has side effects and will cache the federationInstance. This separation aims to improve the overall structure and maintainability of the codebase. |
packages/runtime-core/src/utils/logger.ts | The changes in this file split the runtime into two separate parts: runtime-core and entry. The runtime-core module is designed to have no side effects, while the entry module has side effects and will cache the federation instance. |
packages/runtime-core/src/utils/manifest.ts | The changes in this file involve splitting the runtime into two parts: runtime-core and entry. The runtime-core module has no side effects, while the entry module has side effects and caches the federation instance. This separation aims to improve the overall structure and maintainability of the codebase. |
packages/runtime-core/src/utils/plugin.ts | The changes in this file involve splitting the runtime into two parts: runtime-core and entry. The runtime-core module has no side effects, while the entry module has side effects and caches the federation instance. This separation aims to improve the overall structure and maintainability of the codebase. |
packages/runtime-core/src/utils/preload.ts | The changes in this file involve splitting the runtime into two parts: runtime-core and entry. The runtime-core module has no side effects, while the entry module has side effects and caches the federation instance. This separation aims to improve the overall structure and maintainability of the codebase. |
packages/runtime-core/src/utils/semver/compare.ts | The code changes introduce a split of the runtime into two parts: runtime-core and entry. The runtime-core is now externalized and has no side effects, while the entry part has side effects and will cache the federationInstance. |
packages/runtime-core/src/utils/semver/constants.ts | The changes in this file involve splitting the runtime into two separate parts: runtime-core and entry. The runtime-core module is designed to have no side effects, while the entry module will handle caching of the federation instance. This separation of concerns aims to improve the overall structure and maintainability of the codebase. |
packages/runtime-core/src/utils/semver/index.ts | The code changes split the runtime into two separate parts: runtime-core and entry . The runtime-core module is now externalized and has no side effects, while the entry module handles caching of the federation instance and has side effects. |
packages/runtime-core/src/utils/semver/parser.ts | The changes in this file involve splitting the runtime into two parts: runtime-core and entry. The runtime-core is designed to have no side effects, while the entry part has side effects and will cache the federationInstance. This separation aims to externalize the runtime-core for improved modularity and flexibility. |
packages/runtime-core/src/utils/semver/utils.ts | The changes in this file involve splitting the runtime into two parts: runtime-core and entry. The runtime-core module is designed to have no side effects, while the entry module will cache the federation instance. This separation aims to improve the overall structure and maintainability of the codebase. |
packages/runtime-core/src/utils/share.ts | The changes in this file involve splitting the runtime into two separate parts: runtime-core and entry. The runtime-core module is designed to have no side effects, while the entry module will handle caching the federation instance. This separation of concerns aims to improve the overall structure and maintainability of the codebase. |
packages/runtime-core/src/utils/tool.ts | The code changes introduce a split of the runtime into two parts: runtime-core and entry. The runtime-core is now external and has no side effects, while the entry part has side effects and will cache the federationInstance. |
packages/runtime-plugins/inject-external-runtime-core-plugin/src/index.ts | This code change introduces a plugin that injects the external runtime-core module into the global scope, ensuring that there is only one instance of the runtime-core being used across the application. The plugin checks if there is an existing runtime-core instance and warns the user if there is a mismatch in the version or the name of the provider. This change is likely part of a larger effort to split the runtime into a core and an entry module, where the core module has no side effects and the entry module handles the caching of the federation instance. |
packages/runtime-tools/src/runtime-core.ts | The changes in this file involve exporting all the functionality from the @module-federation/runtime/core module, effectively making the current file an entry point for the runtime-core functionality. |
packages/runtime/src/core.ts | The code changes split the runtime into two parts: runtime-core and entry . The runtime-core has no side effects, while the entry part has side effects and will cache the federationInstance . Additionally, the runtime-core has been externalized. |
packages/runtime/src/helpers.ts | The code changes split the runtime into two parts: runtime-core and entry. The runtime-core module has no side effects, while the entry module has side effects and caches the federation instance. The changes also externalize the runtime-core module and provide a helper object that exposes the necessary global utilities and share-related functions. |
packages/runtime/src/index.ts | The code changes in this file are focused on splitting the runtime into two parts: runtime-core and entry . The runtime-core module is designed to have no side effects, while the entry module will cache the FederationInstance . The changes also involve externalizing the runtime-core module and updating the imports and exports accordingly. |
packages/runtime/src/types.ts | The code changes split the runtime module into two parts: runtime-core and entry . The runtime-core module is now externalized and has no side effects, while the entry module has side effects and caches the federation instance. |
packages/runtime/src/utils.ts | The code changes introduce a new utility function getGlobalFederationInstance that retrieves a specific instance of the FederationHost based on the provided name and version. Additionally, a helper function getBuilderId is added to fetch the build identifier, which is used to identify the correct FederationHost instance when multiple instances exist. |
packages/sdk/src/types/plugins/ModuleFederationPlugin.ts | The changes in this file introduce two new configuration options for the ModuleFederationPluginOptions interface: "externalRuntime" and "provideExternalRuntime". These options allow for the runtime to be split into two parts - "runtime-core" and "entry" - where "runtime-core" has no side effects and "entry" caches the federation instance. |
it('verify resources when URL specifies protocol (http)', () => { | ||
const url = 'http://a.b.c'; | ||
const scriptElement = document.createElement('script'); | ||
scriptElement.src = url; |
Check warning
Code scanning / CodeQL
Inclusion of functionality from an untrusted source Medium test
🦋 Changeset detectedLatest commit: 2f5bc75 The changes in this PR will be included in the next version bump. This PR includes changesets to release 29 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
67a6235
to
d56d6fa
Compare
# Conflicts: # pnpm-lock.yaml
# Conflicts: # pnpm-lock.yaml
# Conflicts: # pnpm-lock.yaml
# Conflicts: # pnpm-lock.yaml
# Conflicts: # pnpm-lock.yaml
f7479be
to
8e13a48
Compare
processing this pr now |
@ScriptedAlchemy hey , i add |
@2heal1 i like it! I can review more tomorrow. |
It needs to be tested in byte repo , but not longer , next Monday can be ready . |
Also i add some info for Plans to make @module-federation/runtime-core to become @module-federation/runtime , because currently the runtime package has sideEffects which can no be extends easily , like external it by cdn etc. So , it's necessary to change it . We can only export init to users , users should store the instance by theirselves . This will make a break change ,so it's just a plan , we can do it on 1.0.0 version . WDYT @ScriptedAlchemy @zhoushaw |
Description
externalRuntime
andprovideExternalRuntime
field to help optimize assets sizeAbout next major version
Plans to make
@module-federation/runtime-core
to become@module-federation/runtime
, because currently the runtime package has sideEffects which can no be extends easily , like external it by cdn etc.So , it's necessary to change it . We can only export
init
to users , users should store the instance by theirselves .This will make a break change ,so it's just a plan , we can do it on
1.0.0
version . cc @ScriptedAlchemy @zhoushawRelated Issue
Types of changes
Checklist