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

skipRemotes option broken when a remote does not live in the same workspace as the host #23574

Closed
1 of 4 tasks
AnhTuan-AiT opened this issue May 20, 2024 · 2 comments · Fixed by #26443
Closed
1 of 4 tasks
Assignees
Labels
scope: module federation Issues related to module federation support type: bug

Comments

@AnhTuan-AiT
Copy link

Current Behavior

The documentation said that: "This option is useful for when the host application is using a remote that does not live in the same workspace as the host".

But when I run projects using the angular module-federation-dev-server, skipRemotes now only can detect projects that are in same workspace. If the projects are in a different repository and are not running (which is my use-case and is also other's use-case as well I'm sure), it won't be able to find them.

I found thí similar issue and this bug was marked as fixed from Nx 16.

Expected Behavior

Specifying projects in skipRemotes that are not in the same repository should work perfectly fine.

GitHub Repo

No response

Steps to Reproduce

  1. Generate a Dynamic Host application as instructed.
  2. Add a reference to the remote application by declaring in assets/module-federation.manifest.json file.
  3. Start the host without starting the remote, using the skipRemotes input with the remote's project name.

Nx Report

NX   Report complete - copy this into the issue template

Node   : 20.9.0
OS     : win32-x64
npm    : 10.1.0

nx (global)        : 19.0.3
nx                 : 19.0.4
@nx/js             : 19.0.4
@nx/jest           : 19.0.4
@nx/linter         : 19.0.4
@nx/eslint         : 19.0.4
@nx/workspace      : 19.0.4
@nx/angular        : 19.0.4
@nx/devkit         : 19.0.4
@nx/eslint-plugin  : 19.0.4
@nrwl/tao          : 19.0.4
@nx/web            : 19.0.4
@nx/webpack        : 19.0.4
typescript         : 5.4.5

Failure Logs

> nx run shell:serve:development --open

 NX  Starting module federation dev-server for shell with 2 remotes
 NX   Cannot read properties of undefined (reading 'data')
TypeError: Cannot read properties of undefined (reading 'data')
    at D:\poc\node_modules\@nx\webpack\src\utils\module-federation\get-remotes-for-host.js:61:112
    at Array.map (<anonymous>)
    at getRemotes (D:\poc\node_modules\@nx\webpack\src\utils\module-federation\get-remotes-for-host.js:61:71)
    at moduleFederationDevServerExecutor (D:\poc\node_modules\@nx\angular\src\executors\module-federation-dev-server\module-federation-dev-server.impl.js:55:56)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at getLastValueFromAsyncIterableIterator (D:\poc\node_modules\nx\src\utils\async-iterator.js:15:19)
    at iteratorToProcessStatusCode (D:\poc\node_modules\nx\src\command-line\run\run.js:44:29)
    at handleErrors (D:\poc\node_modules\nx\src\utils\params.js:10:16)
    at process.<anonymous> (D:\poc\node_modules\nx\bin\run-executor.js:59:28) 

 NX   Running target serve for project shell failed

Failed tasks:

- shell:serve:development

Hint: run the command with --verbose for more details.

Package Manager Version

10.1.0

Operating System

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

Additional Information

No response

@FrozenPandaz FrozenPandaz added the scope: module federation Issues related to module federation support label May 21, 2024
@Stusu
Copy link

Stusu commented Jun 4, 2024

I have the same issue. Here you can find sample code that gives exactly such results: https://github.com/Stusu/nx-dynamic-mf-issues/tree/issue-with-remote-outside-workspace
It does not work even if remote is running.

NX   Report complete - copy this into the issue template

Node   : 20.9.0
OS     : win32-x64
npm    : 10.1.0

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

@Coly010
Copy link
Contributor

Coly010 commented Jun 7, 2024

Hi! Thanks for calling this out.

The docs need updated.

The executor will now automatically skip remotes that are not listed in the workspace. The --skipRemotes option should now only be used to skip remotes that are in the workspace.

I'll update the docs to reflect this

Coly010 added a commit that referenced this issue Jun 7, 2024
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

## Current Behavior
<!-- This is the behavior we have today -->
Remotes not in the workspace are now skipped automatically. The
`--skipRemotes` option is now used to intentionally skip remotes in the
workspace that are served by other means

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

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

Successfully merging a pull request may close this issue.

4 participants