Skip to content

Commit 89621bf

Browse files
authoredJun 8, 2024
fix(esm): resolve .ts extension in imports map
fixes #579
1 parent 87a7683 commit 89621bf

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed
 

‎src/esm/hook/resolve.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,11 @@ export const resolve: resolve = async (
161161
// If `allowJs` is set in `tsconfig.json`, then we'll apply the same resolution logic
162162
// to files without a TypeScript extension.
163163
if (
164-
// Ignore if it's a bare package name and there's no subpath
165-
!isBarePackageName.test(specifier)
164+
(
165+
specifier.startsWith('#')
166+
// Ignore if it's a bare package name and there's no subpath
167+
|| !isBarePackageName.test(specifier)
168+
)
166169
&& (
167170
tsExtensionsPattern.test(context.parentURL!)
168171
|| allowJs

‎tests/fixtures.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,14 @@ export const files = {
272272
'package.json': createPackageJson({
273273
type: 'module',
274274
main: './index.js',
275+
imports: {
276+
'#*': './*',
277+
},
275278
}),
276279
'index.js': `${syntaxLowering}\nexport * from "./empty-export"`,
277-
'ts.ts': syntaxLowering,
278280
'empty-export/index.js': 'export {}',
281+
'ts.ts': `${syntaxLowering}\nexport * from "#empty.js"`,
282+
'empty.ts': 'export {}',
279283
},
280284
},
281285
};

0 commit comments

Comments
 (0)
Please sign in to comment.