-
-
Notifications
You must be signed in to change notification settings - Fork 274
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
Error: Shared module react doesn't exist in shared scope default #1104
Comments
AFAIK, App dir isn’t supported yet. But I read it was planed after the release of v7. |
Great to hear there's a plan in place! Any chance you could ballpark when we might see a solution? Also, is there a quick fix we can use in the meantime? |
I’m not a maintainer so I cannot speak in their names. You may follow some issues that are already talking about this: #619 and #799 (comment) |
yes RSC will get support eventually. With v7 now done, if the community wants to help (i know a few were interested in trying a few things) - im happy for extra hands. First step i need is a PR of my repo using and breaking with app dir, then ill see what needs to be done to make it not error haha. |
Same issue, any solution here? |
I'm also getting same error as that @gdunix is facing. Did anyone found solution? @ScriptedAlchemy @yspychala @gpatatoukas |
@ScriptedAlchemy do you mean a PR creating a new example in this repo? |
@ScriptedAlchemy I was just working on this... you can use my repo, created a branch which shows the issue clearly : Inside the dir If I
|
@ScriptedAlchemy You still want some error examples related to app dir? I've been trying to import remotes within the app dir for a while now but without any success... I can hand you some examples |
Yes please, really the main blocker beyond getting v7 done and starting a new job, historically it was i didnt have the time to reproduce some cases to work against, so instead of diverting time from v7 to see what needed to be done, i delayed the efffort till later. If you have a repo thats nice and broken, thats about 50% of the effort :) |
@ScriptedAlchemy I created an example of this error happening in a fork of module-federation-examples. Steps :
... the same error occurs : [nextjs-mf]: automaticAsyncBoundary is deprecated
(node:34832) [DEP_WEBPACK_MODULE_ID] DeprecationWarning: Module.id: Use new ChunkGraph API
(Use `node --trace-deprecation ...` to show where the warning was created)
[nextjs-mf]: automaticAsyncBoundary is deprecated
- info Creating an optimized production build
- info Compiled successfully
- info Linting and checking validity of types
- info Collecting page data ..Error: Shared module react doesn't exist in shared scope default
at ensureExistence (/Users/nameof/projects/module-federation-examples/nextjs-ssr/home/.next/server/webpack-runtime.js:1263:68)
at Function.<anonymous> (/Users/nameof/projects/module-federation-examples/nextjs-ssr/home/.next/server/webpack-runtime.js:1341:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Promise.all (index 0)
at async Promise.all (index 1)
at async loadComponentsImpl (/Users/nameof/projects/module-federation-examples/nextjs-ssr/home/node_modules/next/dist/server/load-components.js:80:26)
at async /Users/nameof/projects/module-federation-examples/nextjs-ssr/home/node_modules/next/dist/build/utils.js:1006:32
at async Span.traceAsyncFn (/Users/nameof/projects/module-federation-examples/nextjs-ssr/home/node_modules/next/dist/trace/trace.js:103:20)
> Build error occurred
Error: Failed to collect page data for /
at /Users/nameof/projects/module-federation-examples/nextjs-ssr/home/node_modules/next/dist/build/utils.js:1156:15
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
type: 'Error'
}
- info Collecting page data .npm ERR! Lifecycle script `build` failed with error:
npm ERR! Error: command failed
npm ERR! in workspace: [email protected]
npm ERR! at location: /Users/nameof/projects/module-federation-examples/nextjs-ssr/home |
Hi @ScriptedAlchemy |
I try to run this project: https://github.com/Muskos/nextjs-mf-app-folder Have you tested it yourself?
|
Same issue here. As mentioned in this comment it will hopefully be fixed in v7.1. Here is the changelog. |
@arnoBruynseels @ScriptedAlchemy is there a beta version we could use for testing? |
facing same issue here
|
Same here Is there any update on this? I was migrating a whole project to the new "app" routing, but then started to face this error ='( |
+1 same here... |
+1 here. Has anybody found a workaround for the app router with nextjs 13.4 with module-federation |
|
any update friend ? please let me know, currently having same trouble. |
+1 |
https://github.com/module-federation/module-federation-examples/discussions/978 |
Open to PRs for this longstanding issue. Modern.js will support RSC before Next.js due to its open-source priority. It's easier to implement in Modern.js, which has an unparalleled Developer Experience (DX) for Micro Frontends (MFE). The focus is on releasing the internal version to the open-source community, offering a meta-framework for microfrontends and horizontal scaling—something unmatched in my consulting experience with other companies' in-house MFE or MFP efforts. Planning a fork of Module Federation to release an enhanced version with broad support for TypeScript (TS), Hot Module Replacement (HMR), Server-Side Rendering (SSR), dynamic loading, automatic route stitching, middleware, and more. For details, see issue #1170. Challenges with Next.js are significant; it's not designed for module federation. Enhancements are often complex or nearly impossible. For an in-depth understanding, refer to the InvertedContainerRuntimeModule on GitHub. "Container Inversion" involves a complete overhaul of webpack's JSONP and dependency management systems. Despite its complexity, it has solved other architectural issues, especially with circular or nested remotes. This will be integrated into V1.5 of the forked federation. RSPack.dev plans to implement V1.5 in Rust by Q1, offering native support for Module Federation. Concurrently, I'll work with the Modern.js team to reorganize their internal fork and decouple it from our internal deployment infrastructure. There's overlap between the needs of Modern.js and Next.js. Bytedance has solved many issues at scale, and my recent Next.js workarounds have led to beneficial patterns. These will be integrated into my module-federation ecosystem with web-infra-dev. I'm currently integrating the node federation specification for Modern.js as we perfect SSR and backend integrations. Plans are underway to use federation in CI, build management, and Infrastructure as Code, necessitating a memory-efficient server solution. Timeline predictions: RSC support in Next.js is at least 6 months away. If urgently needed, our consulting/pro services branch can fund it. Modern.js will likely have RSC Federation support 2-3 weeks after RSC itself is supported. Unless a breakthrough or business case allows for resource reallocation, the timeline remains uncertain. Expect more insights in 1-2 months. URLs:
|
I'm seeing this error and we're not using the app directory and are still on Next 12. It will take a bit of time to get a sample repo together, but I'll work on it shortly. In the meantime, We're using the following:
and loading the remote via "importRemote". What is super odd is that the S3-hosted remote works against my local Next instance in production mode, but when I run it on one our QA instances it throws this exception when attempting to load the remote (the remote returns 200 in both cases). We're only using client side rendering FWIW. My local box is compiling using OSX whereas our CI is Linux. The remote was compiled on my local instance before being uploaded to the S3 bucket. Does the OS have any effect on the webpack artifacts produced? I can't imagine it does, but I can't account for any other differences (other than my local running on http and the qa server running https). I'm not sure it's helpful, but when I was using |
Suspense swallows the error. You should try v7 or 8 and see how that works. 6 is old and quite |
We are still on React 17 and Next 12. Switching to nextjs-mf 7.x causes new and different issues, one being webpack trying to dynamically load a bunch of node modules (Critical dependency: the request of a dependency is an expression) and then ultimately blowing up during SSR (RangeError: Maximum call stack size exceeded at RegExp.exec () at retrieveSourceMapURL). |
Hello, I'm facing the same issue ** Server Error** I'm using Next.js 13, is there any solution available? |
use v8 prerelease. #1530 |
I'm using v ![]() |
use "canary" tags |
For me the solution was to wrap the NextFederationPlugin plugin in `if (!options.isServer) like in this example: and add the following aliases in the same if condition:
|
Which version did you use? @bkirova For my case the page blinks and it is empty even if with your solution. |
Something very important is that i am using the "pages" directory instead of the new "app" directory! This might be also part of why this setup is working. This is my entire next.config.js (I am also using experimental imports from Framer)
I hope this helps. @rahimimo |
Thanks a lot! @bkirova . I have already got it working with |
Does this configuration works with ssr? I mean when option.isServer true or when we need module federation with ssr? |
Getting this error when trying to use the new app router with @module-federation/nextjs-mf
Here is what I have in my next.config.js file
The text was updated successfully, but these errors were encountered: