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

Build failure with native federation in Angular 18 #683

Open
1 of 2 tasks
sajay-g opened this issue Nov 5, 2024 · 4 comments
Open
1 of 2 tasks

Build failure with native federation in Angular 18 #683

sajay-g opened this issue Nov 5, 2024 · 4 comments

Comments

@sajay-g
Copy link

sajay-g commented Nov 5, 2024

With what library do you have an issue?

native-federation

Reproduction of the bug/regression with instructions

StckBlitz

npm run start

Expected behavior

Build successfully by ignoring the packages mentioned in skip section of federated-config.js

Versions of Native/Module Federation, Angular, Node, Browser, and operating system

Native Federation: 18.2.2
Angular: 18.2.0
Node: >18.9
Browser: Chrome
OS: Mac 14.5 (23F79) Sonoma

Other information

Previously Reported Similar Issue

Console Log

> ng serve
 INFO  Building federation artefacts
 INFO  Preparing shared npm packages
 NOTE  This only needs to be done once, as results are cached
 NOTE  Skip packages you don't want to share in your federation config
✘ [ERROR] Could not resolve "@graphql-tools/schema"

    node_modules/@apollo/client/testing/experimental/createTestSchema.js:2:37:
      2 │ import { addResolversToSchema } from "@graphql-tools/schema";
        ╵                                      ~~~~~~~~~~~~~~~~~~~~~~~

  You can mark the path "@graphql-tools/schema" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle.

1 of 14 errors shown (disable the message limit with --log-limit=0)
 ERR!  Error bundling shared npm package 
 ERR!  Build failed with 14 errors:
 ERR!  node_modules/@apollo/client/react/ssr/getDataFromTree.js:5:37: ERROR: Could not resolve "react-dom/server"
 ERR!  node_modules/@apollo/client/react/ssr/renderToStringWithData.js:2:31: ERROR: Could not resolve "react-dom/server"
 ERR!  node_modules/@apollo/client/testing/experimental/createTestSchema.js:2:37: ERROR: Could not resolve "@graphql-tools/schema"
 ERR!  node_modules/@apollo/client/testing/experimental/createTestSchema.js:3:31: ERROR: Could not resolve "@graphql-tools/merge"
 ERR!  node_modules/@apollo/client/testing/experimental/graphql-tools/utils.js:4:56: ERROR: Could not resolve "@graphql-tools/utils"
 ERR!  ...
 ERR!  For more information, run in verbose mode
 NOTE  
 NOTE  
 NOTE  ** Important Information: ***
 NOTE  The error message above shows an issue with bundling a node_module.
 NOTE  In most cases this is because you (indirectly) shared a Node.js package,
 NOTE  while Native Federation builds for the browser.
 NOTE  You can move such packages into devDependencies or skip them in your federation.config.js.
 NOTE  
 NOTE  More Details: https://bit.ly/nf-issue
 NOTE  
 NOTE  

I would be willing to submit a PR to fix this issue

  • Yes
  • No
@sajay-g sajay-g changed the title Build failure with native federation Build failure with native federation in Angular 18 Nov 6, 2024
@sajay-g
Copy link
Author

sajay-g commented Dec 13, 2024

@manfredsteyer An update on this issue would be greatly appreciated.

@manfredsteyer
Copy link
Contributor

Can you please try to skip @apollo/client/testing in your federation.config.js?

@sajay-g
Copy link
Author

sajay-g commented Dec 20, 2024

@manfredsteyer I tried all possibility including regex /^graphql-tools/ or '@apollo/client/testing',, none worked.

@manfredsteyer
Copy link
Contributor

Can you please try with the latest version again. It's now more tolerant when it sees nodejs code (that is not used in the browser).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants