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

Angular module federation broke #28408

Closed
1 of 4 tasks
m-l-e-n opened this issue Oct 11, 2024 · 4 comments
Closed
1 of 4 tasks

Angular module federation broke #28408

m-l-e-n opened this issue Oct 11, 2024 · 4 comments
Assignees
Labels
outdated scope: module federation Issues related to module federation support type: bug

Comments

@m-l-e-n
Copy link

m-l-e-n commented Oct 11, 2024

Current Behavior

Since @nx/angular@20.0.0 the names of dynamically federated modules are sanitized by replacing all "-" with "_". This leads to an error when starting the dev-server since the sanitized name is not a valid project name. In this example, the remote's name is "remotes-foo":

Error: Cannot find project "remotes_foo". Check that the name is correct in module-federation.config.js
    at getModuleFederationConfig (/workspace/keba/node_modules/@nx/angular/src/utils/mf/utils.js:70:15)
    at withModuleFederation (/workspace/keba/node_modules/@nx/angular/src/utils/mf/with-module-federation.js:10:112)
    at Object.<anonymous> (/workspace/keba/apps/remotes/io-monitor/webpack.config.js:4:18)
    at Module._compile (node:internal/modules/cjs/loader:1469:14)
    at Module._compile (/workspace/keba/node_modules/pirates/lib/index.js:117:24)
    at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
    at Object.newLoader (/workspace/keba/node_modules/pirates/lib/index.js:121:7)
    at Module.load (node:internal/modules/cjs/loader:1288:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1104:12)
    at Module.require (node:internal/modules/cjs/loader:1311:19)

The bug was introduced with this commit: 95d26c6

Expected Behavior

I can use remote projects with dashes ("-") in their name.

GitHub Repo

No response

Steps to Reproduce

Nx Report

Node : 20.18.0
OS : linux-x64
Native Target : x86_64-linux
npm : 10.8.2

nx : 20.0.0
@nx/js : 20.0.0
@nx/jest : 20.0.0
@nx/eslint : 20.0.0
@nx/workspace : 20.0.0
@nx/angular : 20.0.0
@nx/cypress : 20.0.0
@nx/devkit : 20.0.0
@nx/eslint-plugin : 20.0.0
@nx/playwright : 20.0.0
@nx/storybook : 20.0.0
@nx/vite : 20.0.0
@nx/web : 20.0.0
@nx/webpack : 20.0.0
typescript : 5.5.4

Community plugins:
@storybook/angular : 8.3.5
ng2-charts : 6.0.1

Failure Logs

No response

Package Manager Version

No response

Operating System

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

Additional Information

No response

@its-ratikant
Copy link

its-ratikant commented Oct 11, 2024

I am also getting this issue! Not able to run host application when there is one or more remote applications.

@jaysoo jaysoo added the scope: module federation Issues related to module federation support label Oct 14, 2024
@Coly010
Copy link
Contributor

Coly010 commented Oct 14, 2024

Will be fixed by: #28401

jaysoo added a commit that referenced this issue Oct 14, 2024
… schema (#28401)

<!-- 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` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->
We previously had a schema restriction on the characters allowed for
remote names. It was to prevent names that violated the JS spec for a
variable declaration.


## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
Ensure invalid project names fail error allowing the user to fix it at
generation


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

Fixes #28354, #28408

---------

Co-authored-by: Jack Hsu <jack.hsu@gmail.com>
jaysoo added a commit that referenced this issue Oct 14, 2024
… schema (#28401)

<!-- 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` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->
We previously had a schema restriction on the characters allowed for
remote names. It was to prevent names that violated the JS spec for a
variable declaration.


## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
Ensure invalid project names fail error allowing the user to fix it at
generation


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

Fixes #28354, #28408

---------

Co-authored-by: Jack Hsu <jack.hsu@gmail.com>
@Coly010 Coly010 closed this as completed Oct 15, 2024
@m-l-e-n
Copy link
Author

m-l-e-n commented Oct 17, 2024

@Coly010 & @jaysoo
THANK YOU VERY MUCH for the quick fix! Our project now works without any modifications to the remotes. 👍

Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: module federation Issues related to module federation support type: bug
Projects
None yet
Development

No branches or pull requests

4 participants