-
-
Notifications
You must be signed in to change notification settings - Fork 256
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(nextjs-mf): enable JSON manifest for NextJS #2726
feat(nextjs-mf): enable JSON manifest for NextJS #2726
Conversation
🦋 Changeset detectedLatest commit: 02fdeb3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
✅ Deploy Preview for module-federation-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Stale pull request message |
@ScriptedAlchemy I was looking forward on having that added to support MF2.0 |
Since support is ending, adding a new feature to the plugin is not something I particularly want to do, as any problems it may contain will open more issues on the repository that I will not support or fix. JSON protocol means HMR, Chrome tools, and TypeScript will work. If there are any issues with Next, users will open issues and create noise. Without a lead maintainer, it will most likely create more problems than it's worth. Since Federation barely works already with Next, this would probably open the floodgates versus locking users out of the majority of features for their own good. Contacting vercel is the best approach |
When I started building Module Federation was an webpack5 feature, so I had the impression it would be maintained by them. We started the app using regular React + Webpack + Module federation with almost 100 exposed components. I understand dropping support, you are not obligated to maintain anything. but having the newer versions of the lib just not working and seeing those PR's that could have been merged and fixed by the community not going forward is sad... You can disconsider my rant, just venting a little. Maybe just update the deprecation notice if possible. |
You can rebase the PR if you really want it. I can merge it. Only the next plugin is maintained by a small team (me). The rest of the ecosystem has a pretty large pool, and v2 is backed by Bytedance, a 400 billion dollar tech company. If you don't think you need federation, then you probably don't. That said, I've used every other flavor - federation remains the industry standard for a reason. Understand the venting, especially on next.js, how you feel now has been 4 years of my life lol. All good On a side note. Vercel apparently is now actively testing Federation v2 as a first class supported tech in next. Nothing actionable as of yet, but it looks encouraging |
Thanks for your support man, I really appreciate! Unfortunately, that was not enough to make nextjs work with manifest file. when implementing modernjs SSR you guys added an empty default snapshot information and since nextjs manifest does not contain this "new" I've tried to open a PR but I'm having trouble make the unit tests run locally (it seems like clean clone + the guide on the Contribute page is not enough) Maybe you could help me out? Also, I think a better permanent solution would be to have the manifest to be generated with the new format (maybe a single one for both ssr and non-ssr) |
test can be run by looking at the .github workflows for E2E or test cases in build-and-test, otherwise just push to CI and let CI do the test runs. Combining SSR and non SSR isnt easy, since there can be many builds - for example RSC will be 6 independent builds - best approach is 2 manifest and have server/client pick and choose the corresponding manifest for its environment since all the data is different as well etc. You could use a runtimePlugin and rewrite the snapshot on the fly as needed? |
Thanks @ScriptedAlchemy |
Sorry just got caught up. Yes, this change is a bit outdated, and I have an additional change in my runtime plugin to set the loadRemoteSnapshot(args) {
// ... all the changes from this PR...
if (!options.inBrowser) {
remoteSnapshot.ssrRemoteEntry = remoteSnapshot.remoteEntry
remoteSnapshot.ssrRemoteEntryType = remoteSnapshot.remoteEntryType
}
return args
} I don't think there is any downside to setting it on the client side, but it won't point to the correct URL (not that it will be used on the client anyway). The way you set it up in your PR @ciandt-crodrigues is much more robust though, thank you! @ScriptedAlchemy thank you for all the time and effort you put into this plugin. It's definitely a disappointment that support is being dropped, but it's understandable considering the lack of collaboration from Vercel. I'm not sure I have the time to volunteer to maintain the plugin right now, but my company is still using it for a large project so I'll keep working on it as things come up. |
This change broke loading of non nextjs remotes. Fix is #3323 |
Description
The NextJS plugins are not working with the MF 2.0 manifest because the publicPath is not properly generated on either the server or client. Additionally, adding
getPublicPath
causes the NextJS build to fail and I haven't been able to track down the root cause yet. These changes enhance the runtime plugin included with the NextJS MF plugin to reassign the publicPath to ensure that requests made after the initial manifest fetch are correctly resolved.Changing the manifest filePath in NextJS MF plugin results in the manifest file being output in the wrong location, and the manifest itself is generated based on relative paths to the output. So modifying it in the runtimePlugin is the simplest (though maybe not the most robust) approach. These changes don't cause existing remoteEntry.js configures to break.
Since there are no tests for the runtimePlugin, I didn't add any new ones. Happy to write some if someone can let me know where. I created a new example in the module-federation-examples repo to demo this: module-federation/module-federation-examples#4231
Please let me know what you think and if you would prefer a different approach.
Related Issue
#2673
Types of changes
Checklist