Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: rewrite how vite-node resolves id (#2463)
* feat!: rewrite how vite-node resolves id * chore: try to fix global setup test * fix: remove /@fs/ from filepath * chore: cleanup * fix: normalize id for callstack * fix: don't append "/" before disk drive on windows * chore: cleanup * chore: add test that windows drive is not repeated * fix: dirname uses \\, update windows paths tests * refactor: rename variables * fix: don't provide importer only for /@id/ * chore: remove null byte placeholder as part of unwrapRef * chore: cleanup * chore: variables renaming * fix: don't hang on circular mock * test: update c8 snapshot * chore: add compatibility layer for users who don't provide resolveId * test: fix url handling in web worker * test: fix file tests on windows * chore: remove unnecessary normalizations in mocker * chore: use /@fs/ when fetching module, if possible
- Loading branch information
1 parent
0967b24
commit 58ee8e9
Showing
25 changed files
with
313 additions
and
277 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { funcB } from './B' | ||
|
||
export function funcA() { | ||
return funcB | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { funcA } from './A' | ||
|
||
export function funcB() { | ||
return funcA | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { funcA } from './A' | ||
|
||
export function main() { | ||
return funcA() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { expect, test, vi } from 'vitest' | ||
import { main } from '../src/main.js' | ||
|
||
vi.mock('../src/A', async () => ({ | ||
...(await vi.importActual<any>('../src/A')), | ||
funcA: () => 'mockedA', | ||
})) | ||
|
||
test('main', () => { | ||
expect(main()).toBe('mockedA') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.