-
-
Notifications
You must be signed in to change notification settings - Fork 7k
fix: resolve @/ scoped package subpath imports in deepImportRE regex #20521
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: sapphi-red <49056869+sapphi-red@users.noreply.github.com>
Co-authored-by: sapphi-red <49056869+sapphi-red@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocking: #19292 (comment)
The Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Fixes package exports resolution for scoped packages with empty scope names like
@/lib/schemas
.Problem
Vite's
deepImportRE
regex was failing to match scoped package names that start with@/
when importing subpaths. This caused build failures with errors like:The issue occurred because the regex pattern
@[^/]+
required at least one character after@
, but@/lib
has zero characters between@
and/
.Root Cause
The
deepImportRE
regex/^([^@][^/]*)\/|^(@[^/]+\/[^/]+)\//
has two alternation branches:([^@][^/]*)\/
- matches regular packages likemy-lib/schemas
(@[^/]+\/[^/]+)\/
- matches scoped packages like@vitejs/plugin-vue/dist
The second branch uses
@[^/]+
which requires at least one character after@
. This fails for@/lib/schemas
because there are zero characters between@
and/
.Solution
Changed
@[^/]+
to@[^/]*
to allow zero or more characters after@
:Testing
@/pkg/foo
not resolved locally #19292 -@/lib/schemas
imports now resolve correctlymy-lib/schemas
@vitejs/plugin-vue/dist
@/lib/schemas
(the main fix)The change is minimal and surgical - it only affects the specific case of scoped packages with empty scope names while preserving all existing behavior.
Fixes #19292
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.