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 Dynamic Module Federation SSR error after add @nx/nest #22476

Closed
1 of 4 tasks
johnitvn opened this issue Mar 24, 2024 · 4 comments · Fixed by #23264
Closed
1 of 4 tasks

Angular Dynamic Module Federation SSR error after add @nx/nest #22476

johnitvn opened this issue Mar 24, 2024 · 4 comments · Fixed by #23264
Assignees
Labels
outdated scope: angular Issues related to Angular support in Nx scope: module federation Issues related to module federation support type: bug

Comments

@johnitvn
Copy link

Current Behavior

I created a project then added an angular app using dynamic remote module federation with ssr. The target serve, serve ssr (including adding devRemotes) work well with angular host app

But after I tried to add an app using nestjs. The target serve, serve ssr (including devRemotes) of the angular host app cannot load remote modules

Expected Behavior

It should have worked fine like before I added nestjs app

GitHub Repo

No response

Steps to Reproduce

The first i have create project with bellow steps

npx create-nx-workspace --name=project --preset=apps --nxCloud=skip --packageManager=pnpm && cd project 
npx nx add @nx/angular
npx nx g @nx/angular:host apps/host --dynamic --ssr --standalone --style=scss --addTailwind --e2eTestRunner=playwright --projectNameAndRootFormat=as-provided --prefix=host
npx nx g @nx/angular:remote apps/remote-a --host=host --ssr --standalone --style=scss --addTailwind --e2eTestRunner=playwright --projectNameAndRootFormat=as-provided --prefix=remote-a
npx nx g @nx/angular:remote apps/remote-b --host=host --ssr --standalone --style=scss --addTailwind --e2eTestRunner=playwright --projectNameAndRootFormat=as-provided --prefix=remote-b
npx nx serve host --devRemotes=remote-a,remote-b

For now it's still work as expected. But after add @nx/nest it's ocure error

npx nx add @nx/nest
npx nx g @nx/nest:application server/gateways/api-gateway  --projectNameAndRootFormat=as-provided 
npx nx serve host --devRemotes=remote-a,remote-b

Here is browser console log error
Capture

Nx Report

Node   : 20.11.1
OS     : linux-x64
pnpm   : 8.15.5

nx (global)        : 18.1.2
nx                 : 18.1.2
@nx/js             : 18.1.2
@nx/jest           : 18.1.2
@nx/eslint         : 18.1.2
@nx/workspace      : 18.1.2
@nx/angular        : 18.1.2
@nx/devkit         : 18.1.2
@nx/eslint-plugin  : 18.1.2
@nx/nest           : 18.1.2
@nx/node           : 18.1.2
@nx/playwright     : 18.1.2
@nx/web            : 18.1.2
@nx/webpack        : 18.1.2
typescript         : 5.3.3

Failure Logs

No response

Package Manager Version

pnpm 8.15.5

Operating System

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

Additional Information

No response

@johnitvn johnitvn changed the title Angular Dynamic Module Federation SSR error after add @nx/webpack Angular Dynamic Module Federation SSR error after add @nx/nest Mar 24, 2024
@johnitvn
Copy link
Author

It's back to work after i remove plugin @nx/webpack/plugin in nx.json. But nestjs app can't serve

> nx run api-gateway:serve:development


 NX   Cannot find build target api-gateway:build:development for project api-gateway


Error: Cannot find build target api-gateway:build:development for project api-gateway
    at nodeExecutor (/home/johnitvn/project/node_modules/.pnpm/@nx+js@18.1.2_@swc-node+register@1.8.0_@swc+core@1.3.107_@types+node@18.16.9_nx@18.1.2_typescript@5.3.3/node_modules/@nx/js/src/executors/node/node.impl.js:28:15)
    at nodeExecutor.next (<anonymous>)
    at getLastValueFromAsyncIterableIterator (/home/johnitvn/project/node_modules/.pnpm/nx@18.1.2_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/utils/async-iterator.js:13:27)
    at iteratorToProcessStatusCode (/home/johnitvn/project/node_modules/.pnpm/nx@18.1.2_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/command-line/run/run.js:43:94)
    at /home/johnitvn/project/node_modules/.pnpm/nx@18.1.2_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/command-line/run/run.js:179:16
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async handleErrors (/home/johnitvn/project/node_modules/.pnpm/nx@18.1.2_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/utils/params.js:9:16)
    at async process.<anonymous> (/home/johnitvn/project/node_modules/.pnpm/nx@18.1.2_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/bin/run-executor.js:59:28)
```
Maybe this plugin is conflict...

@johnitvn
Copy link
Author

remove plugin @nx/webpack/plugin in __nx.json __ add manual add build target to api-gateway app. So all of it work perfect.

"build": {
      "executor": "@nx/webpack:webpack",
      "options": {
        "outputPath": "dist/server/gateways/api-gateway",
        "main": "server/gateways/api-gateway/src/main.ts",
        "tsConfig": "server/gateways/api-gateway/tsconfig.app.json",
        "assets": ["server/gateways/api-gateway/src/assets"],
        "target": "node",
        "compiler": "tsc",
        "scripts": [],
        "webpackConfig": "server/gateways/api-gateway/webpack.config.js"
      },
      "configurations": {
        "production": {
          "optimization": true
        },
        "development": {
          "buildOptimizer": false,
          "optimization": false,
          "vendorChunk": true,
          "extractLicenses": false,
          "sourceMap": true,
          "namedChunks": true
        }
      },
      "defaultConfiguration": "production"
    },

This seems like a workaround to fix the error temporarily

@FrozenPandaz FrozenPandaz added scope: angular Issues related to Angular support in Nx scope: module federation Issues related to module federation support labels Mar 27, 2024
@Coly010
Copy link
Contributor

Coly010 commented May 8, 2024

This is fixed in latest however, another unrelated issue will end up resulting in hitting an error when adding the api app.

If you run your commands prefixed with NX_ADD_PLUGINS=false, you'll get a working setup! 🙂

@Coly010 Coly010 closed this as completed May 8, 2024
Coly010 added a commit that referenced this issue May 13, 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 -->
Calculating conflicts in target names does not consider if the
project.json defined targets will actually be impacted by the plugin
that wants to be added creating false negatives

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
Calculating conflicts should be more accurate

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

Fixes #22476
FrozenPandaz pushed a commit that referenced this issue May 13, 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 -->
Calculating conflicts in target names does not consider if the
project.json defined targets will actually be impacted by the plugin
that wants to be added creating false negatives

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
Calculating conflicts should be more accurate

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

Fixes #22476

(cherry picked from commit 85c8916)
Copy link

github-actions bot commented Jun 8, 2024

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 Jun 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: angular Issues related to Angular support in Nx scope: module federation Issues related to module federation support type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants