Skip to content

Commit 9e53df0

Browse files
authored
fix(register): file path with query (#801)
1 parent 1071d8d commit 9e53df0

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/integrate-module/src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import { baz } from './subdirectory/index.mjs'
1313
import { Component } from './component.js'
1414
import './js-module.mjs'
1515

16+
const { foo: fooWithQuery } = await import(`./foo.mjs?q=${Date.now()}`)
17+
1618
await test('file-type should work', () => {
1719
assert.ok(supportedExtensions.has('jpg'))
1820
})
@@ -33,6 +35,10 @@ await test('resolve paths', () => {
3335
assert.equal(subBar(), 'bar')
3436
})
3537

38+
await test('resolve with query', () => {
39+
assert.equal(fooWithQuery(), 'foo')
40+
})
41+
3642
await test('compiled js file with .d.ts', () => {
3743
const instance = new CompiledClass()
3844
assert.equal(instance.name, 'CompiledClass')

packages/register/esm.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,10 @@ export const resolve: ResolveHook = async (specifier, context, nextResolve) => {
202202
(process.platform === 'win32' && !path.includes('\\node_modules\\')))
203203
) {
204204
debug('resolved: typescript', specifier, path)
205-
205+
const url = new URL(join('file://', path))
206206
return addShortCircuitSignal({
207207
...context,
208-
url: pathToFileURL(path).href,
208+
url: url.href,
209209
format: 'module',
210210
})
211211
}

0 commit comments

Comments
 (0)