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

chore: split runtime as core and entry #3154

Open
wants to merge 27 commits into
base: main
Choose a base branch
from

Conversation

2heal1
Copy link
Member

@2heal1 2heal1 commented Nov 1, 2024

Description

  1. split runtime into two parts : runtime-core entry
  • runtime-core: no sideEffect
  • entry: has sideEffect , it will cache federationInstance
  1. external runtime-core

Related Issue

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have updated the documentation.

Copy link

netlify bot commented Nov 1, 2024

Deploy Preview for module-federation-docs ready!

Name Link
🔨 Latest commit 8e13a48
🔍 Latest deploy log https://app.netlify.com/sites/module-federation-docs/deploys/674f95f4fefbb60008ddd6fb
😎 Deploy Preview https://deploy-preview-3154--module-federation-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@squadronai squadronai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

The core changes in this pull request involve splitting the runtime module into two separate parts: runtime-core and entry. The key goals of this change are:

  • Separation of Concerns: The runtime-core module is designed to have no side effects, while the entry module will handle caching the federation instance and have side effects. This separation of concerns aims to improve the overall structure and maintainability of the codebase.

  • Externalization of runtime-core: The runtime-core module is now externalized, allowing for better modularity and flexibility in the project's dependencies. This change also enables the consolidation of various utility functions, types, and the FederationHost component into a single, centralized export.

  • Improved Caching: The entry module will now cache the federation instance, ensuring that the same instance is used across the application and improving performance and consistency.

The changes touch a wide range of files, primarily within the packages/runtime-core directory, but also in the packages/runtime directory. The updates involve modifying imports and exports, introducing new utility functions and types, and ensuring a seamless integration of the new runtime-core and entry modules with the existing codebase.

Overall, this pull request aims to enhance the structure, maintainability, and performance of the runtime module by separating its concerns and externalizing the core functionality.

File Summaries
File Summary
packages/runtime-core/src/constant.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 cache the federation instance. This separation of concerns aims to improve the overall structure and maintainability of the codebase.
packages/runtime-core/src/core.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 cache the federation instance. This separation of concerns aims to improve the overall structure and maintainability of the codebase.
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 modules and their global scope.
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 the FederationHost component.
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 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/plugins/generate-preload-assets.ts The changes in this file split 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/plugins/snapshot/SnapshotHandler.ts This change splits the runtime 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 will cache the federationInstance. This separation of concerns helps improve the overall structure and maintainability of the codebase.
packages/runtime-core/src/plugins/snapshot/index.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 separation allows for better modularity and flexibility in the codebase.
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 part has no side effects, while the entry part has side effects and will cache the federationInstance. This change aims to externalize the runtime-core functionality.
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 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/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 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/type/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/type/preload.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 separation of concerns aims to improve the overall structure and maintainability of the codebase.
packages/runtime-core/src/types.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 federationInstance. This separation of concerns aims to improve the overall structure and maintainability of the codebase.
packages/runtime-core/src/utils/env.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/asyncHook.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.
packages/runtime-core/src/utils/hooks/asyncWaterfallHooks.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/index.ts The changes in this file involve splitting 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/runtime-core/src/utils/hooks/pluginSystem.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. This change aims to externalize the runtime-core module for better modularity and flexibility.
packages/runtime-core/src/utils/hooks/syncHook.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/hooks/syncWaterfallHook.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 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 has 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 maintainability.
packages/runtime-core/src/utils/load.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. Additionally, the runtime-core module is now externalized, allowing for more flexibility in the project's dependencies.
packages/runtime-core/src/utils/logger.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/utils/manifest.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/plugin.ts The changes in this file 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 the federation instance and has side effects.
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 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/semver/compare.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 change aims to externalize the runtime-core module for better modularity and maintainability.
packages/runtime-core/src/utils/semver/constants.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 federation instance. This separation aims to improve the overall structure and maintainability of the codebase.
packages/runtime-core/src/utils/semver/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 cache the federation instance. This separation of concerns aims to improve the overall structure and maintainability of the codebase.
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 module is designed to have no side effects, while the entry module will cache the federationInstance. This separation aims to improve the overall structure and maintainability of the codebase.
packages/runtime-core/src/utils/semver/utils.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. This change aims to externalize the runtime-core for better modularity and maintainability.
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 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 separation allows for better modularity and flexibility in the codebase.
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 consolidated export for the global and share utilities.
packages/runtime/src/index.ts This code change splits the runtime 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. The changes also externalize the runtime-core module and update 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 handles caching of the federation instance and has side effects.
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.

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

Script loaded using unencrypted connection.
Copy link

changeset-bot bot commented Nov 9, 2024

⚠️ No Changeset found

Latest commit: 8e13a48

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ScriptedAlchemy ScriptedAlchemy force-pushed the chore/external-runtime-core branch from 67a6235 to d56d6fa Compare November 9, 2024 02:38
@ScriptedAlchemy ScriptedAlchemy changed the title WIP: chore: split runtime as core and entry chore: split runtime as core and entry Nov 22, 2024
@ScriptedAlchemy ScriptedAlchemy mentioned this pull request Dec 3, 2024
5 tasks
@ScriptedAlchemy ScriptedAlchemy force-pushed the chore/external-runtime-core branch from f7479be to 8e13a48 Compare December 3, 2024 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants