-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
After replacing vite-tsconfig-paths
by @nx/vite/plugins/nx-tsconfig-paths.plugin
=> app:serve
target throws errors
#18623
Comments
@barbados-clemens probably you could remember some context after this PR #17844 |
vite-tsconfig-paths
by @nx/vite/plugins/nx-tsconfig-paths.plugin
app:serve
target throws errorsvite-tsconfig-paths
by @nx/vite/plugins/nx-tsconfig-paths.plugin
=> app:serve
target throws errors
@k-paxian do you have a repo I can test with? But unaware of this issue specifically. But it shouldn't actually matter since those deps aren't other nx projects but in the node_modules which vite itself should be able to understand? Also unsure why the angular deps are trying to be brought in as you're project doesn't look to be using angular from the |
I'll try to mock it up on stackbliz later this week. My wild guess is that the node process which is executing vite.config.ts pulls in too much stuff via that new plugin import. But we'll see 🙈 |
the plugin only resolved values within the tsconfig.base.json at the root of the repo so I would be surprised, but honestly I've seen wilder stuff happen so it's possible some case I didn't consider when writing. |
ok, sorry folks, that's might be not the nx fault at all. 🤦 I did a bit deeper dive into that, and it appears that And because the default option is to optimize All in all, after importing new plugin, this auto dependency discovery thingy discovered some absolutely unrelated And for my case I'd go with that vite config for now, which is looks and feels much better than listing all the random packages to exclude 😄 optimizeDeps: {
disabled: true
}, until they will fix that experimental 💀 auto optimization process Thank you for a great NX stuff ❤️ , sorry for borrowing your attention w/o real need |
no worries, this is helpful information that I didn't know either. Appreciate you digging into it and finding that stuff out! |
Unfortunately optimizeDeps: {
disabled: true
}, was not a viable option, so I ended up with those ugly list of ever growing excludes 😞 and optimizeDeps: {
disabled: 'build',
exclude: [
'@swc-node/register',
'@angular-devkit',
'webpack',
'@nx/nx-win32-x64-msvc',
'@nx/nx-darwin-arm64',
],
},
Looks like plenty of edge cases for
|
@k-paxian does this happen if you switch back to vite-tsconfig-paths plugin? |
No, it doesn't happen with the old plugin |
Then it must be something specific to how we are handling things. I'll have to dig into the vite-tsconfig-paths plugin to see what we are missing. Explains why that plugin is more complex than I expected when first looking at it. 😅 |
But those extra dependencies from the exclude list are clear false positives and imho should be handled by vite directly or indirectly by providing a way to pass some custom logic in vite.config or by plugin interface allowing to alter the list of targets for optimization. |
Hey I was looking into this and still unsure what is happening. do you have a repo I can look? I'm trying to get the same errors but not able to. |
@barbados-clemens |
Finally, here is the minimal reproduction <script setup lang="ts">
// This import is causing vite to fail serve in dev mode
import { DependencyType, type ProjectGraph, type ProjectGraphProcessorContext, type ProjectsConfigurations } from '@nx/devkit'
//
</script> It has nothing to do with the plugin In an essence, whatever you'd try to import from It makes a little sense maybe to import stuff from |
@k-paxian What is the use case for importing from |
It doesn't appear to be an Nx issue, can we close this? |
Well, @jaysoo it actually doesn't specific to simple const import is affected as well import { jsdomVersion } from '@nx/vite' in other words we are not able to import any npm package which has Despite that, I agree it's more of vite issue than nx |
Yes, it applies to all Is there an use-case where you want to import those plugins in production code? |
In our use-case we have an npm package which contains our own nx plugins + some typescript types to be used in the production code. And we are not able to have them both in one package, we are forced to split those onto separate packages to avoid such issue 🤷 Also we need to have those types to be imported by the (e.g. vite.config.ts, next.config.js, jest.config.ts, etc.), AND production code simultaneously. Having separate npm package to share few types across configs and production app sounds like overkill to me 😞 |
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. |
Current Behavior
After replacing
vite-tsconfig-paths
by@nx/vite/plugins/nx-tsconfig-paths.plugin
app:serve
target throws errorsAs a workaround I have to include this piece of config to the
vite.config.ts
of the app, which is feels and looks bad to me 🤷NB:
build:prod
target works flawlessly, onlyserve
target is throwing errorsExpected Behavior
There should be no errors in console, just like it was before drop-in replacement of the
vite-tsconfig-paths
by@nx/vite/plugins/nx-tsconfig-paths.plugin
GitHub Repo
No response
Steps to Reproduce
vite-tsconfig-paths
by@nx/vite/plugins/nx-tsconfig-paths.plugin
invite.config.ts
nx run app:serve:development
throws a lot of errors and fails to serve the appnx run app:build:production
works fine and produces app artifacts w/o errorsNx Report
Failure Logs
Operating System
Additional Information
No response
The text was updated successfully, but these errors were encountered: