Skip to content
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

url now returns the href of a url object #698

Merged
merged 1 commit into from
Apr 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/register/esm.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { promises as fs, constants as FSConstants } from 'fs'
import { join, parse, isAbsolute } from 'path'
import { constants as FSConstants, promises as fs } from 'fs'
import { isAbsolute, join, parse } from 'path'
import { fileURLToPath, pathToFileURL } from 'url'

import ts from 'typescript'
Expand Down Expand Up @@ -53,7 +53,7 @@ async function checkRequestURL(parentURL: string, requestURL: string) {
export const resolve: ResolveFn = async (specifier, context, nextResolve) => {
const rawUrl = TRANSFORM_MAP.get(specifier)
if (rawUrl) {
return { url: rawUrl, format: 'module', shortCircuit: true }
return { url: new URL(rawUrl).href, format: 'module', shortCircuit: true }
}
const { parentURL } = context ?? {}
if (parentURL && TRANSFORM_MAP.has(parentURL) && specifier.startsWith('.')) {
Expand All @@ -62,7 +62,7 @@ export const resolve: ResolveFn = async (specifier, context, nextResolve) => {
const url = `${existedURL}.mjs`
TRANSFORM_MAP.set(url, existedURL)
return {
url,
url: new URL(url).href,
shortCircuit: true,
format: 'module',
}
Expand All @@ -73,7 +73,7 @@ export const resolve: ResolveFn = async (specifier, context, nextResolve) => {
TRANSFORM_MAP.set(newUrl, fileURLToPath(specifier))
return {
shortCircuit: true,
url: newUrl,
url: new URL(newUrl).href,
format: 'module',
}
}
Expand Down