Skip to content

Commit 72d0896

Browse files
committedJun 4, 2024
perf(esm): only try extensions if file path
1 parent a33c96a commit 72d0896

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed
 

‎src/esm/hook/resolve.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ export const resolve: resolve = async (
121121
}
122122

123123
const parentNamespace = context.parentURL && getNamespace(context.parentURL);
124-
if (requestAcceptsQuery(specifier)) {
124+
const acceptsQuery = requestAcceptsQuery(specifier);
125+
if (acceptsQuery) {
125126
// Inherit namespace from parent
126127
let requestNamespace = getNamespace(specifier);
127128
if (parentNamespace && !requestNamespace) {
@@ -159,8 +160,11 @@ export const resolve: resolve = async (
159160
// If `allowJs` is set in `tsconfig.json`, then we'll apply the same resolution logic
160161
// to files without a TypeScript extension.
161162
if (
162-
tsExtensionsPattern.test(context.parentURL!)
163-
|| allowJs
163+
acceptsQuery // file path
164+
&& (
165+
tsExtensionsPattern.test(context.parentURL!)
166+
|| allowJs
167+
)
164168
) {
165169
const tsPaths = resolveTsPath(specifier);
166170
if (tsPaths) {

0 commit comments

Comments
 (0)
Please sign in to comment.