Skip to content

Commit

Permalink
perf(esm): only try extensions if file path
Browse files Browse the repository at this point in the history
  • Loading branch information
privatenumber committed Jun 4, 2024
1 parent a33c96a commit 72d0896
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/esm/hook/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ export const resolve: resolve = async (
}

const parentNamespace = context.parentURL && getNamespace(context.parentURL);
if (requestAcceptsQuery(specifier)) {
const acceptsQuery = requestAcceptsQuery(specifier);
if (acceptsQuery) {
// Inherit namespace from parent
let requestNamespace = getNamespace(specifier);
if (parentNamespace && !requestNamespace) {
Expand Down Expand Up @@ -159,8 +160,11 @@ export const resolve: resolve = async (
// If `allowJs` is set in `tsconfig.json`, then we'll apply the same resolution logic
// to files without a TypeScript extension.
if (
tsExtensionsPattern.test(context.parentURL!)
|| allowJs
acceptsQuery // file path
&& (
tsExtensionsPattern.test(context.parentURL!)
|| allowJs
)
) {
const tsPaths = resolveTsPath(specifier);
if (tsPaths) {
Expand Down

0 comments on commit 72d0896

Please sign in to comment.