externalDependencies not working as expected during serve with Vite #28028
Labels
area: @angular/build
devkit/build-angular:dev-server
freq1: low
Only reported by a handful of users who observe it rarely
severity3: broken
type: bug/fix
Command
serve
Is this a regression?
The previous version in which this bug was not present was
No response
Description
When marking certain dependencies as external via option
externalDependencies
we get runtime errors during dev mode with the Vite server because Vite will prefix the import specifiers with/@id/
(during import-analysis).For example:
This breaks expected behavior, for example when we want to use an importmap to resolve external dependencies at runtime.
I realize that this is an issue with Vite itself, more then Angular: open issues exist on Vite since quite some time already:
However, I do believe that we can work around this issue by adding a small Vite plugin in vite-server.ts to remove this
/@id/
prefix for explicit externalDependencies. I would be more than willing to submit a PR after discussion.Minimal Reproduction
Here's a StackBlitz link with a simple repro case:
https://stackblitz.com/edit/stackblitz-starters-rbro7s?file=angular.json
rxjs
andrxjs/operators
are declared asexternalDependencies
Exception or Error
Your Environment
Anything else relevant?
No response
The text was updated successfully, but these errors were encountered: