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

Sharing buildable libs won't build #7252

Closed
TomONeill opened this issue Oct 5, 2021 · 3 comments
Closed

Sharing buildable libs won't build #7252

TomONeill opened this issue Oct 5, 2021 · 3 comments

Comments

@TomONeill
Copy link

TomONeill commented Oct 5, 2021

Current Behavior

I added a library with the --buildable flag and then shared it with two apps using sharedMappings in the webpack.config.js files. Then I added a service which is being used in the aforementioned apps.

App dashboard sets a variable in the created service, then after clicking on the Login button, the login app logs the variable's value.

Serving the application works fine. Unfortunately, building the application fails (see Failure Logs) using the following command:
nx run-many --target=build --all

Expected Behavior

That it builds fine.
Strangely enough, doing this without the --buildable flag, it works fine.

Steps to Reproduce

I forked the following repo: https://github.com/Coly010/ng-mfe-example and did what has been described in the Current Behavior: https://github.com/TomONeill/ng-mfe-example/commit/f62aeb9702ee7fa97dd85948991253a8ba1c713c

Failure Logs

./libs/awesomelib/libname/src/index.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Error: C:\Workspace\nx\ng-mfe-example\libs\awesomelib\libname\src\index.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
    at C:\Workspace\nx\ng-mfe-example\node_modules\@ngtools\webpack\src\ivy\loader.js:59:26
@bart-vandervliet
Copy link

I'm a team member of @TomONeill and narrowed it down to this: we're registering the buildable library using the @angular-architects/module-federation-plugin and it resolves the lib through the tsconfig.base.json by name to the path where the sources of the lib are.

This works for a serve target, but when using the build target Nx builds the lib (because it's buildable) and won't use the lib sources anymore. Instead, it passes the build output at /dist/libs/awesomelib/libname through the typescript compiler.

This conflicts with the resolved location of the libs sources because webpack won't be able to find the source file in the typescript buildable files array and the build fails.

How are you addressing this issue? We really like the buildable libraries because it speeds up building when no changes are in the lib (Nx build caching), but I can't seem to think of a possible solution for this issue.

@leosvelperez
Copy link
Member

Thanks for reporting this!

This is a duplicate of #6923. Please follow that one for updates regarding this issue.

@github-actions
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 Mar 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants