Skip to content

Webpack 5 support (module federation) #9510

Open
@bradydowling

Description

@bradydowling

Is your proposal related to a problem?

It would be great to be able to use federated modules in Webpack with a CRA application.

Describe the solution you'd like

Provide support for Webpack 5 by upgrading the default Webpack version to 5. This was previously requested (#6081) but closed because Webpack 5 wasn't in beta at the time. It is now in beta and has had several releases.

Describe alternatives you've considered

You could also allow an opt-in to using Webpack 5 (just like Next.js does) when users initially run CRA from the command-line.

Activity

bradydowling

bradydowling commented on Sep 24, 2020

@bradydowling
Author

For those following this issue, @petetnt mentioned in #9678 that "Webpack 5 is probably landing in CRA@4.1. if all the bugs and issues are fixed before that." Not sure what the typical release schedule is for CRA, I'm guessing there's info about that somewhere that I just haven't found yet.

raix

raix commented on Oct 9, 2020

@raix
Contributor

4.1 was mentioned but it's not assigned to the milestone yet - but I guess the big question would be how to configure the modules for module federation in CRA?

shospodarets

shospodarets commented on Oct 10, 2020

@shospodarets
malcolm-kee

malcolm-kee commented on Oct 25, 2020

@malcolm-kee

To provide more context to the discussion (since module federation is new, so I believe not everyone know what it means), I think module federation support can be further broken down into two parts:

  • consuming federated modules
  • exposing modules to be consumed remotely

Having both would be ideal, but support for only one is better than none.

malcolm-kee

malcolm-kee commented on Oct 25, 2020

@malcolm-kee

Also, I'm not very optimistic module federation will be supported by CRA, because CRA guiding principle has been "rather sacrifice functionality than introducing configuration". Due to the fact that module federation requires configuration (there is no sensible default) and no existing configuration files (e.g. jsconfig.json / tsconfig.json) supports it yet, I can't see anyway module federation can land in CRA in near future.

A more probable direction will be CRA supports webpack 5, and those of us need module federation will fork it and introducing our own configuration convention.

dantman

dantman commented on Oct 25, 2020

@dantman

Due to the fact that module federation requires configuration (there is no sensible default) and no existing configuration files (e.g. jsconfig.json / tsconfig.json) supports it yet, I can't see anyway module federation can land in CRA in near future.

I could see it being possible but in a limited way. Not every part of CRA uses a standard config file, e.g. the "proxy" and src/setupProxy.js are wholly a CRA thing.

Federated module consumption would probably require federated modules to conform to a CRA specified convention. So only a minimal amount of "configuration" is necessary, e.g. a simple declaration in package.json of what federated module libraries there are to import.

As for exposing federated modules. If module federation is heavy CRA might not offer it; but if it's light a new CRA version (probably 5+ not 4) might just always expose its build in a way that can be consumed according to CRA's conventions.

Also if the other issue(s) asking for a way to have multiple entrypoints are accepted I could also see CRA internally using module federation.

malcolm-kee

malcolm-kee commented on Oct 25, 2020

@malcolm-kee

I could see it being possible but in a limited way. Not every part of CRA uses a standard config file, e.g. the "proxy" and src/setupProxy.js are wholly a CRA thing.

Good point 👍

Also if the other issue(s) asking for a way to have multiple entrypoints are accepted I could also see CRA internally using module federation.

Do you mean this issue? That's a long thread, but sorry I can't find any conclusion on that thread that states multiple entrypoints will be supported.


To clarify I will be happy if CRA supports module federation out-out-the-box, but based on my personal observations, CRA has been fairly reserved about new features except when those are officially recommended tools by React (e.g. Fast Refresh, JSX Transform etc.) Also since module federation is new and other more customizable tools (e.g. NextJS) are not supporting module federation yet, I'm not optimistic with CRA supporting this soon.

Anyway, I hope I am wrong 😆

raix

raix commented on Nov 20, 2020

@raix
Contributor

Atm. we are testing our own "CRA" compatible build (written in typescript using wp5) adding the ability to configure using an mfconfig.json or for advanced usage mfconfig.js - it's basically just providing the FederatedModuleOptions for now.
Because other systems should also provide typings and an "offline" version / fallback we are considering if part of the configuration could be shipped as part of the provider package.

... but not sure if we could have a mfconfig-experimental.js config file in CRA to get started gathering feedback to figure out where this will take us?

66 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @dantman@kumarldh@trystan2k@shospodarets@raix

      Issue actions

        Webpack 5 support (module federation) · Issue #9510 · facebook/create-react-app