Skip to content

Commit

Permalink
revert: always provide importer when resolving id (#2777)
Browse files Browse the repository at this point in the history
* revert: always provide importer in

* test: remove test
  • Loading branch information
sheremet-va authored Feb 3, 2023
1 parent f03337a commit 8836fa0
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 13 deletions.
6 changes: 0 additions & 6 deletions packages/vite-node/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,6 @@ export class ViteNodeRunner {
if (importee && id.startsWith(VALID_ID_PREFIX))
importee = undefined
id = normalizeRequestId(id, this.options.base)
// should be checked after normalization
// provide importer only for relative and absolute paths
// paths like "src/user" are valid for transformRequest, but they will be resolved incorrectly,
// if importer is provided - because they will be treated as relative to the importer instead of root
if (!id.startsWith('/') && !id.startsWith('./') && !id.startsWith('../'))
importee = undefined
if (!this.shouldResolveId(id))
return [id, id]
const { path, exists } = toFilePath(id, this.root)
Expand Down
7 changes: 0 additions & 7 deletions test/core/test/imports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,6 @@ test('dynamic absolute with extension mport works', async () => {
expect(stringTimeoutMod).toBe(variableTimeoutMod)
})

test('dynamic baseUrl import works', async () => {
const staticMod = await import('./../src/timeout')
// @ts-expect-error there is no tsconfig in test/core to handle baseUrl
const dynamicMod = await import('src/timeout')
expect(staticMod).toBe(dynamicMod)
})

test('data with dynamic import works', async () => {
const dataUri = 'data:text/javascript;charset=utf-8,export default "hi"'
const { default: hi } = await import(dataUri)
Expand Down

0 comments on commit 8836fa0

Please sign in to comment.