core icon indicating copy to clipboard operation
core copied to clipboard

Introduce resolveChunk() hook and loadChunk() api in runtime

Open MadaraUchiha-314 opened this issue 11 months ago • 2 comments

Currently node federation is implemented as a runtimePlugin, but relies on webpack APIs to hook into chunk loading. This makes Node federation tightly coupled with webpack.

Suggested solution

Introducing new APIs and runtime hooks to tap into chunk loading makes Node federation completely free of webpack.

API and Hooks for chunk loading

  1. loadChunk()
    • loadChunk API will be used to load any chunk exposed by a remote.
    • loadChunk will use the appropriate loader to load the chunk
      • import for ESM
      • require for CJS
      • require (from requirejs) for AMD
      • System.import for SystemJS
      • NOTE: Using the appropriate loader to handle chunk loading is already taken care by the bundler during output generation phase
  2. resolveChunk()
    • Allows for manual resolution of chunk load requests.
    • This runtime hook will be called before a chunk is resolved
    • Similar to resolveShare, one can provide an explicit resolver which resolves to a module

Alternative

No response

Additional context

No response

Validations

  • [X] Read the Contributing Guidelines.
  • [X] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

MadaraUchiha-314 avatar Nov 20 '24 16:11 MadaraUchiha-314