nx
nx copied to clipboard
nx serve doesn't respect "buildLibsFromSource" (reopen)
Since the original issue #8942 got closed, I've got some new info and I don't think my comment will be noticed there, I'm filing a new issue. Apologies if this is not the correct approach.
The original issue got closed with an advice to use @nrwl/web:file-server, but I think this should work with dev-server too.
Looking at the code here https://github.com/nrwl/nx/blob/b1e52b67f279c3e772eaf6e553f7f444a19ad34b/packages/web/src/executors/dev-server/dev-server.impl.ts#L82
it looks like the dev-server actually tries to handle this situation by generating a temporary tsconfig with paths remapped. But the generated tsconfig doesn't seem to be actually used later on and that - I think - is why the serve fails.
As for the @nrwl/web:file-server executor, I tried to use it, but ran into some other problems. Because of defaultConfiguration=production, the serve target builds production configuration, though I need a development one during serve. I can overcome that by introducing explicit development configuration, but then also NODE_ENV is set to production by webpack plugin, so I have to explicitly set it before calling nx serve. Not quite developer-friendly.
Current Behavior
I have an app with strict:true setting, which uses a lib which is non-strict. To be able to build the app, I've set "buildLibsFromSource": false in the app config. That allows me to run nx build app without an error. But nx serve app still shows errors as if the lib was built during the serve - in strict mode.
Expected Behavior
nx serve app should use the independently built lib sources and finish without error, just like nx build app does.
Steps to Reproduce
- create a workspace with a @nrwl/web:application and a buildable non-strict @nrwl/node:library.
- make the app strict in its tsconfig.
- add a code to the library that does something that wouldn't build in strict mode.
- use the library in the app
- set the "buildLibsFromSource" to false in app's project.json
- run nx serve app
Repro repo: https://github.com/ziacik/nx-bug-2
Environment
> NX Report complete - copy this into the issue template
Node : 14.17.6
OS : linux x64
npm : 6.14.15
nx : undefined
@nrwl/angular : undefined
@nrwl/cli : 13.8.1
@nrwl/cypress : 13.8.1
@nrwl/detox : undefined
@nrwl/devkit : 13.8.1
@nrwl/eslint-plugin-nx : 13.8.1
@nrwl/express : undefined
@nrwl/jest : 13.8.1
@nrwl/js : 13.8.1
@nrwl/linter : 13.8.1
@nrwl/nest : undefined
@nrwl/next : undefined
@nrwl/node : 13.8.1
@nrwl/nx-cloud : undefined
@nrwl/react : undefined
@nrwl/react-native : undefined
@nrwl/schematics : undefined
@nrwl/storybook : undefined
@nrwl/tao : 13.8.1
@nrwl/web : 13.8.1
@nrwl/workspace : 13.8.1
typescript : 4.5.5
rxjs : 6.6.7
---------------------------------------
Community plugins:
Thank you for providing the reproduction. We'll take a look.
I fixed it in this PR: https://github.com/nrwl/nx/pull/9326
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏
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.