Skip to content

Commit

Permalink
fix(esm): resolve .ts extension in imports map
Browse files Browse the repository at this point in the history
fixes #579
  • Loading branch information
privatenumber authored Jun 8, 2024
1 parent 87a7683 commit 89621bf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/esm/hook/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,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 (
// Ignore if it's a bare package name and there's no subpath
!isBarePackageName.test(specifier)
(
specifier.startsWith('#')
// Ignore if it's a bare package name and there's no subpath
|| !isBarePackageName.test(specifier)
)
&& (
tsExtensionsPattern.test(context.parentURL!)
|| allowJs
Expand Down
6 changes: 5 additions & 1 deletion tests/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,14 @@ export const files = {
'package.json': createPackageJson({
type: 'module',
main: './index.js',
imports: {
'#*': './*',
},
}),
'index.js': `${syntaxLowering}\nexport * from "./empty-export"`,
'ts.ts': syntaxLowering,
'empty-export/index.js': 'export {}',
'ts.ts': `${syntaxLowering}\nexport * from "#empty.js"`,
'empty.ts': 'export {}',
},
},
};

0 comments on commit 89621bf

Please sign in to comment.