-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
fix: support dynamic path with alias in new URL()
(fix #10597)
#10743
base: main
Are you sure you want to change the base?
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
I also encountered this problem, but I personally feel that this test is not stable enough, try several times may make more mistakes, may pass all... |
This comment was marked as outdated.
This comment was marked as outdated.
a2c2fae
to
07ff25c
Compare
07ff25c
to
e62d631
Compare
This comment was marked as outdated.
This comment was marked as outdated.
e62d631
to
497124b
Compare
497124b
to
9248c3d
Compare
78926cb
to
1330e69
Compare
1330e69
to
8400ecb
Compare
8400ecb
to
e4888cd
Compare
@@ -28,6 +28,7 @@ import { preloadHelperId } from './importAnalysisBuild' | |||
export function assetImportMetaUrlPlugin(config: ResolvedConfig): Plugin { | |||
const normalizedPublicDir = normalizePath(config.publicDir) | |||
let assetResolver: ResolveFn | |||
let aliaResolver: ResolveFn |
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.
aliasResolver
let aliaResolver: ResolveFn | |
let aliasResolver: ResolveFn |
aliaResolver ??= config.createResolver() | ||
const resolvedUrl = await aliaResolver( |
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.
aliaResolver ??= config.createResolver() | |
const resolvedUrl = await aliaResolver( | |
aliasResolver ??= config.createResolver() | |
const resolvedUrl = await aliasResolver( |
if (!newUrl.startsWith('.')) { | ||
newUrl = `/${newUrl}` | ||
} | ||
newUrl = '`' + newUrl |
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.
why are you making this assignment?
Description
If the path in
new URL()
includes both variables and alias, Vite will not resolve the alias and cause an error during runtime.This PR resolves the alias appear in
new URL()
in assetImportMetaUrlPlugin.fixes #10597
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).