Skip to content
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

[Module-Federation] Can't find module sdk/dist/dist/index.cjs.js #27964

Open
1 of 4 tasks
KyorCode opened this issue Sep 17, 2024 · 1 comment
Open
1 of 4 tasks

[Module-Federation] Can't find module sdk/dist/dist/index.cjs.js #27964

KyorCode opened this issue Sep 17, 2024 · 1 comment
Assignees
Labels
blocked: third-party scope: module federation Issues related to module federation support type: bug

Comments

@KyorCode
Copy link

KyorCode commented Sep 17, 2024

Current Behavior

I followed the steps on https://nx.dev/recipes/react/module-federation-with-ssr to setup a basic SSR workspace. I removed the checkout remote and cleaned some stuff up. It was all working up until the point that I want to just render out the HTML provided by SSR, based upon a remote component.

If you run the nx run store:serve:development --verbose command and go to http://localhost:4200/v2 - you'll see that there is no output from the server. Just the error below. While I would just expect it the have the html output from the component wrapped in a <div id="root"></div>.

The normal http://localhost:4200 just works fine.

What I noticed in the error is that there is a double /dist/dist/ in there, which I presume to be a bug of some sorts.

Expected Behavior

Being able to output plain html from a SSR service.

GitHub Repo

https://github.com/KyorCode/nx-mf-test

Steps to Reproduce

  1. download / clone repo
  2. yarn / npm install
  3. run nx run store:serve:development --verbose

Nx Report

NX   Report complete - copy this into the issue template

Node           : 20.16.0
OS             : darwin-x64
Native Target  : x86_64-macos
npm            : 10.8.3

nx (global)        : 19.7.2
nx                 : 19.7.3
@nx/js             : 19.7.3
@nx/jest           : 19.7.3
@nx/linter         : 19.7.3
@nx/eslint         : 19.7.3
@nx/workspace      : 19.7.3
@nx/devkit         : 19.7.3
@nx/eslint-plugin  : 19.7.3
@nx/react          : 19.7.3
@nrwl/tao          : 19.7.3
@nx/web            : 19.7.3
@nx/webpack        : 19.7.3
typescript         : 5.5.4

Failure Logs

Error: Cannot find module '/Users/xxxx/Projects/xxx/my-test/node_modules/@module-federation/sdk/dist/dist/index.cjs.js'
    at createEsmNotFoundErr (node:internal/modules/cjs/loader:1182:15)
    at finalizeEsmResolution (node:internal/modules/cjs/loader:1170:15)
    at trySelf (node:internal/modules/cjs/loader:559:12)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1122:24)
    at Function.Module._load (node:internal/modules/cjs/loader:986:27)
    at Function.Module._load (/Users/xxx/Projects/xxx/my-test/node_modules/@nx/js/src/executors/node/node-with-require-overrides.js:18:31)
    at Module.require (node:internal/modules/cjs/loader:1233:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.29 (remoteEntry.js:480:18)
    at __webpack_require__ (remoteEntry.js:550:32) {
  code: 'MODULE_NOT_FOUND',
  path: '/Users/xxx/Projects/xxx/my-test/node_modules/@module-federation/sdk/dist/package.json'
}

Package Manager Version

4.5.0 ( yarn )

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

My end goal is to have module federated SSR service which just outputs the component HTML and returns it in a response. The reason is that this service is called by a CMS system and all the frontend/browser related stuff is handled there. Not in the SSR service.

@Coly010 Coly010 self-assigned this Sep 18, 2024
@Coly010 Coly010 added the scope: module federation Issues related to module federation support label Sep 18, 2024
@Coly010
Copy link
Contributor

Coly010 commented Sep 18, 2024

@KyorCode Thanks for raising this. I believe this is an issue on the Module Federation side. Good spot on the double dist/ in the string. I'll speak with Zack Jackson and take a look over on that repo to see if i can resolve this myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked: third-party scope: module federation Issues related to module federation support type: bug
Projects
None yet
Development

No branches or pull requests

2 participants