-
Notifications
You must be signed in to change notification settings - Fork 12k
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
Vite dev server failure referencing local libraries #28980
Comments
I've found a solution to this error - these 2 options work:
These 2 options do not work:
Results in same error as before.
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"buildTarget": "app:build"
},
"configurations": {
"development": {
"prebundle": {
"exclude": [
"@acme/model",
"@acme/util",
"@acme/ui-components",
"@acme/ui-tracking",
"@acme/search"
]
}
}
}
}, Unfortunately wildcards can't be used for exclusion, so they each have to be explicitly added (most of our apps have a longer list of internal dependencies - this is a test app); and when I exclude a lib from pre-bundling I get a long list of yellow warnings on startup, one line for each module, eg:
Followed by these errors when a page is requested:
Before this issue, I wasn't familiar with pre-bundling, but here's some info for anyone else: I do have workarounds, but I also think there is some room for improvement. I still don't know why my repro works and my real code is having these errors. I'm willing to continue on the repro case if you can give me any direction on why I seem to not be triggering pre-bundling in my repro case. Other questions:
|
These errors are quite unusual. The fact that Vite is unable to resolve some of these libraries suggests there may be an issue with the project layout, structure, configuration or potentially a bug. Unfortunately, we will need a reproduction of the issue in order to investigate it further.
While we could potentially support globbing for exclusions, this could slow down the build process. Each non-relative import would need to be matched against a list of globs, making it a more expensive operation. This would no longer be a constant-time operation, which could negatively impact build performance.
If the libraries are in a different workspace, you'll need to use
|
Thank you for the information @alan-agius4. I'm currently in the process of debugging the vite pre-bundling process to figure out why I'm seeing this problem in my real-world project, and not in my repro app. I'll follow up with a repro case once I figure it out.
The imports that are causing these errors are in the same workspace, and we are using TypeScript path mappings like normal. They're working correctly for the build, just not for prebundling.
Right now it looks like the |
Update on my debugging process (still trying to create a repro case, but to do that I need to figure out what is breaking in my real world project).
So, my next step is to figure out why my real world project is identifying internal imports as external ones. |
Command
serve
Is this a regression?
The previous version in which this bug was not present was
browser builder
Description
I'm trying to migrate to the new builders ( browser -> application or browser -> esbuild-browser), and building works fine, however trying to use the dev server
ng serve
I receive errors like the following:This occurs for all projects. Our file organization is:
All of the failing references with
initDepsOptimizer
at the bottom of the call stack are our internal libraries, which are built into./dist/node_modules
.As I said above - build works fine, it's only the vite dev server where I'm seeing this problem.
Minimal Reproduction
I have tried creating a new project that is organized similarly to provide a minimal repro case, but so far the dev server works in that project. It doesn't appear to be triggering
initDepsOptimizer()
- any idea how I can force that to be triggered? Or is there a way to provide a vite config to skip optimizing our internal libs?Exception or Error
Your Environment
Anything else relevant?
No response
The text was updated successfully, but these errors were encountered: