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

feat(runtime): pass all loader hooks to the fetch and script functions #3174

Merged
merged 3 commits into from
Nov 5, 2024

Conversation

ScriptedAlchemy
Copy link
Member

@ScriptedAlchemy ScriptedAlchemy commented Nov 5, 2024

Description

The pull request introduces changes to the runtime and SDK modules to allow for the passing of all loader hooks to the fetch and script functions. This provides more flexibility and control over the remote loading process, enabling developers to customize the fetch and script creation behavior using the provided hooks.

The key changes include:

  • Updating the RemoteHandler class in the runtime module to accept a loaderHook parameter, which allows for passing all loader hooks to the fetch and script functions.
  • Modifying the loadEntryScript, loadEntryDom, and loadEntryNode functions in the runtime utilities to accept a loaderHook parameter, enabling the passing of all loader hooks to the fetch and script functions.
  • Adding a loaderHook parameter to the createScriptNode and loadScriptNode functions in the SDK module, allowing for customization of the fetch and script creation behavior using the provided hooks.
  • Introducing a new FetchHook type in the SDK types, which represents a function that can be used to intercept and customize the fetch request made by the SDK.

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

changeset-bot bot commented Nov 5, 2024

🦋 Changeset detected

Latest commit: aeda8cb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 25 packages
Name Type
@module-federation/runtime Major
@module-federation/sdk Major
@module-federation/devtools Major
@module-federation/data-prefetch Major
@module-federation/dts-plugin Major
@module-federation/nextjs-mf Patch
@module-federation/node Patch
@module-federation/retry-plugin Major
@module-federation/runtime-tools Major
@module-federation/webpack-bundler-runtime Major
@module-federation/enhanced Major
@module-federation/esbuild Patch
@module-federation/managers Major
@module-federation/manifest Major
@module-federation/modern-js Major
@module-federation/rsbuild-plugin Major
@module-federation/rspack Major
@module-federation/storybook-addon Patch
@module-federation/utilities Patch
@module-federation/bridge-react-webpack-plugin Major
@module-federation/bridge-react Major
@module-federation/bridge-vue3 Major
@module-federation/modernjsapp Patch
@module-federation/third-party-dts-extractor Major
@module-federation/bridge-shared Major

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

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 pull request introduces changes to the runtime and SDK modules to allow for the passing of all loader hooks to the fetch and script functions. This provides more flexibility and control over the remote loading process, enabling developers to customize the fetch and script creation behavior using the provided hooks.

The key changes include:

  • Updating the RemoteHandler class in the runtime module to accept a loaderHook parameter, which allows for passing all loader hooks to the fetch and script functions.
  • Modifying the loadEntryScript, loadEntryDom, and loadEntryNode functions in the runtime utilities to accept a loaderHook parameter, enabling the passing of all loader hooks to the fetch and script functions.
  • Adding a loaderHook parameter to the createScriptNode and loadScriptNode functions in the SDK module, allowing for customization of the fetch and script creation behavior using the provided hooks.
  • Introducing a new FetchHook type in the SDK types, which represents a function that can be used to intercept and customize the fetch request made by the SDK.

These changes enhance the flexibility and extensibility of the runtime and SDK modules, enabling developers to better integrate remote loading functionality with their existing codebase.

File Summaries
File Summary
packages/runtime/src/remote/index.ts The code changes introduce a new parameter to the loadEntry hook in the RemoteHandler class. The loaderHook parameter is now passed instead of the specific createScriptHook function, allowing for all loader hooks to be passed to the fetch and script functions. This change provides more flexibility and control over the remote loading process.
packages/runtime/src/utils/load.ts The code changes introduce a new parameter loaderHook to the loadEntryScript, loadEntryDom, and loadEntryNode functions, which is used to pass all loader hooks to the fetch and script functions. This allows for more flexibility and customization in the loading process of remote entries.
packages/sdk/src/node.ts The code changes introduce the ability to pass all loader hooks to the fetch and script functions in the runtime. This includes adding a new parameter loaderHook to the createScriptNode and loadScriptNode functions, which allows for customizing the fetch and script creation behavior using the provided hooks.
packages/sdk/src/types/hooks.ts The code changes introduce a new FetchHook type that represents a function that can be used to intercept and customize the fetch request made by the SDK. This allows for greater flexibility and control over the network requests performed by the application.

Copy link

netlify bot commented Nov 5, 2024

Deploy Preview for module-federation-docs ready!

Name Link
🔨 Latest commit b6195d1
🔍 Latest deploy log https://app.netlify.com/sites/module-federation-docs/deploys/672999cd619cba00089d873a
😎 Deploy Preview https://deploy-preview-3174--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.

Incremental Review

Comments posted: 7

Configuration

Squadron Mode: essential

Commits Reviewed

54bfd1cf730a842fd323d88d1b7c8ff72678f0ce...b6195d1a0789b42d98f6ad989773a4952be6bd7e

Files Reviewed
  • packages/sdk/src/node.ts
  • packages/sdk/src/types/hooks.ts
Files Ignored

These files were ignored due to the filter in the squadron.yaml file.

  • .changeset/lucky-buckets-add.md

@module-federation module-federation deleted a comment from squadronai bot Nov 5, 2024
@module-federation module-federation deleted a comment from squadronai bot Nov 5, 2024
@module-federation module-federation deleted a comment from squadronai bot Nov 5, 2024
@module-federation module-federation deleted a comment from squadronai bot Nov 5, 2024
@module-federation module-federation deleted a comment from squadronai bot Nov 5, 2024
@module-federation module-federation deleted a comment from squadronai bot Nov 5, 2024
@module-federation module-federation deleted a comment from squadronai bot Nov 5, 2024
@2heal1 2heal1 merged commit 879ad87 into main Nov 5, 2024
19 checks passed
@2heal1 2heal1 deleted the loaderhooks-proper branch November 5, 2024 08:55
@2heal1 2heal1 mentioned this pull request Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants