Skip to content

Commit 7e1fe22

Browse files
fix(esm): resolve implicit extension in package subpath
fixes #585
1 parent fb247eb commit 7e1fe22

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/esm/hook/resolve.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ export const resolve: resolve = async (
277277
}
278278

279279
// If not bare specifier
280-
if (acceptsQuery) {
280+
if (!isBarePackageName.test(specifier)) {
281281
try {
282282
return await tryExtensions(specifier, context, nextResolve);
283283
} catch {}

tests/specs/smoke.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ export default testSuite(async ({ describe }, { tsx, supports, version }: NodeAp
3535
import * as pkgCommonjs from 'pkg-commonjs';
3636
3737
// Named exports from CommonJS
38-
import { cjsJs } from 'pkg-commonjs/cjs.js';
38+
import { cjsJs } from 'pkg-commonjs/cjs';
3939
4040
import * as pkgModule from 'pkg-module';
41+
import 'pkg-module/index';
4142
import 'pkg-module/empty-export'; // implicit directory & extension
4243
4344
// .js in esm syntax
@@ -189,13 +190,14 @@ export default testSuite(async ({ describe }, { tsx, supports, version }: NodeAp
189190
// Dependencies
190191
import * as pkgCommonjs from 'pkg-commonjs';
191192
import * as pkgModule from 'pkg-module';
193+
import 'pkg-module/index';
192194
193195
// Resolving TS files in dependencies (e.g. implicit extensions & export maps)
194196
import 'pkg-commonjs/ts.js';
195197
import 'pkg-module/ts.js';
196198
197199
// Named exports from CommonJS
198-
import { cjsJs } from 'pkg-commonjs/cjs.js';
200+
import { cjsJs } from 'pkg-commonjs/cjs';
199201
200202
// .js in esm syntax
201203
import * as js from './js/index.js';

0 commit comments

Comments
 (0)