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: resolve dynamicly imported modules to be the same as statically #911
Conversation
✔️ Deploy Preview for vitest-dev ready! 🔨 Explore the source changes: 44b2e4d 🔍 Inspect the deploy log: https://app.netlify.com/sites/vitest-dev/deploys/622850286555850008d86da2 😎 Browse the preview: https://deploy-preview-911--vitest-dev.netlify.app |
@@ -57,7 +57,7 @@ export class ViteNodeRunner { | |||
// and wasn't transformed by Vite | |||
if (this.shouldResolveId(dep)) { | |||
const resolvedDep = await this.options.resolveId(dep, id) | |||
dep = resolvedDep?.id || dep | |||
dep = resolvedDep?.id?.replace(this.root, '') || dep |
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.
May not contain root, and I didn't want to make another if
for .slice(this.root.length)
@@ -1,30 +1,30 @@ | |||
import { expect, test } from 'vitest' | |||
|
|||
test('dynamic relative import works', async() => { | |||
const { timeout } = await import('./../src/timeout') |
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.
Isn't it a named export? I am not sure if I understand why we can do this - or are you checking the module reference to be the same?
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.
yes, this exactly what i am doing
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.
how about name the variables module
so it could be less confusing? like
literalImportedMod
and stringImportedMod
- but you call it :)
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.
Done
Co-authored-by: Jelf <haichao.liang@parameters.cn> Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
Fixes #813