Skip to content

Commit

Permalink
fix(register): file path with query (#801)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed Jul 4, 2024
1 parent 1071d8d commit 9e53df0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions packages/integrate-module/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { baz } from './subdirectory/index.mjs'
import { Component } from './component.js'
import './js-module.mjs'

const { foo: fooWithQuery } = await import(`./foo.mjs?q=${Date.now()}`)

await test('file-type should work', () => {
assert.ok(supportedExtensions.has('jpg'))
})
Expand All @@ -33,6 +35,10 @@ await test('resolve paths', () => {
assert.equal(subBar(), 'bar')
})

await test('resolve with query', () => {
assert.equal(fooWithQuery(), 'foo')
})

await test('compiled js file with .d.ts', () => {
const instance = new CompiledClass()
assert.equal(instance.name, 'CompiledClass')
Expand Down
4 changes: 2 additions & 2 deletions packages/register/esm.mts
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,10 @@ export const resolve: ResolveHook = async (specifier, context, nextResolve) => {
(process.platform === 'win32' && !path.includes('\\node_modules\\')))
) {
debug('resolved: typescript', specifier, path)

const url = new URL(join('file://', path))
return addShortCircuitSignal({
...context,
url: pathToFileURL(path).href,
url: url.href,
format: 'module',
})
}
Expand Down

0 comments on commit 9e53df0

Please sign in to comment.