nx icon indicating copy to clipboard operation
nx copied to clipboard

nx serve doesn't respect "buildLibsFromSource" (reopen)

Open ziacik opened this issue 3 years ago • 3 comments

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

  1. create a workspace with a @nrwl/web:application and a buildable non-strict @nrwl/node:library.
  2. make the app strict in its tsconfig.
  3. add a code to the library that does something that wouldn't build in strict mode.
  4. use the library in the app
  5. set the "buildLibsFromSource" to false in app's project.json
  6. 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:

ziacik avatar Feb 18 '22 18:02 ziacik

Thank you for providing the reproduction. We'll take a look.

FrozenPandaz avatar Mar 14 '22 20:03 FrozenPandaz

I fixed it in this PR: https://github.com/nrwl/nx/pull/9326

ms-tng avatar Mar 21 '22 09:03 ms-tng

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

github-actions[bot] avatar Sep 18 '22 00:09 github-actions[bot]

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[bot] avatar Mar 21 '23 19:03 github-actions[bot]