Skip to content

Conversation

@ScriptedAlchemy
Copy link
Member

@ScriptedAlchemy ScriptedAlchemy commented Jan 22, 2024

Description

This pull request adds the initRawContainer method to allow sideloading or conversion of containers into wrapped modules, which can be injected into the cache. The method improves runtime and debugging.

For server use cases or dynamic scenarios, like webpack built in script loading, its possible for the container to be loaded another way or injected into the module cache by other means.

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.

node_remote: 'node_remote@http://localhost:3002/remoteEntry.js',
// node_local_remote: '__webpack_require__.federation.instance.moduleCache.get("node_local_remote")',
node_remote:
'__webpack_require__.federation.instance.moduleCache.get("node_remote")@http://localhost:3002/remoteEntry.js',
Copy link
Member Author

Choose a reason for hiding this comment

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

When using script global external modules in Webpack, it searches for containers in the internal module cache, as if it were a global variable.
image

container: RemoteEntryExports,
): Module {
const remoteInfo = getRemoteInfo({ name, entry: url });
const module = new Module({ host: this, remoteInfo });
Copy link
Member Author

Choose a reason for hiding this comment

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

@2heal1, could you give me your input on this solution? I believe there are relevant use cases for when a user may sideload a container, and we need a way to convert it to a module instance.

Copy link
Member

Choose a reason for hiding this comment

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

Not encounter the case , but I think this solution is okay :D

@ScriptedAlchemy ScriptedAlchemy changed the title chore: debugging, init container manually to cache feat: initRawContainer method Jan 23, 2024
@ScriptedAlchemy ScriptedAlchemy merged commit 215cccc into feat/use-runtime-script-load Jan 23, 2024
@ScriptedAlchemy ScriptedAlchemy deleted the debugging-container-init branch January 23, 2024 07:17
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.

3 participants