Skip to content

SSR: Native Federation and Node.js Remote Loading #622

Open
@klerick

Description

@klerick

Hi @manfredsteyer

Currently, Native Federation does not support remote loading from Node.js directly. This limitation exists because Node.js does not allow the use of import('http://www.some.url/some-module.js').

However, we can work around this limitation by using the --loader flag and a custom loader for remote scripts. Native Federation can already create importmap.json and build projects to work with this import map. Additionally, it modifies the default Angular builder.

To enable Node.js to handle remote modules similarly to how it's done in the browser, we need to:

  1. Add external options for esbuild for the Node platform, similar to the browser platform.
  2. Set the minifyIdentifiers option to false.
  3. Apply all the configurations and changes currently done for the browser to the Node platform.
  4. Create a custom resolver and add an additional entry point.

By following these steps, we can launch SSR (Server-Side Rendering) after running the build command. However, understanding how the Angular development server works in this context can be challenging. I understand that this approach is a bit of a hack, but it can enable us to use SSR.

While I can create a custom resolver and modify Native Federation, I am having trouble understanding how to correctly change the Angular development server.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions