Skip to content

Commit

Permalink
fix(esm): resolve implicit extension in package subpath
Browse files Browse the repository at this point in the history
fixes #585
  • Loading branch information
privatenumber authored Jun 10, 2024
1 parent fb247eb commit 7e1fe22
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/esm/hook/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export const resolve: resolve = async (
}

// If not bare specifier
if (acceptsQuery) {
if (!isBarePackageName.test(specifier)) {
try {
return await tryExtensions(specifier, context, nextResolve);
} catch {}
Expand Down
6 changes: 4 additions & 2 deletions tests/specs/smoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ export default testSuite(async ({ describe }, { tsx, supports, version }: NodeAp
import * as pkgCommonjs from 'pkg-commonjs';
// Named exports from CommonJS
import { cjsJs } from 'pkg-commonjs/cjs.js';
import { cjsJs } from 'pkg-commonjs/cjs';
import * as pkgModule from 'pkg-module';
import 'pkg-module/index';
import 'pkg-module/empty-export'; // implicit directory & extension
// .js in esm syntax
Expand Down Expand Up @@ -189,13 +190,14 @@ export default testSuite(async ({ describe }, { tsx, supports, version }: NodeAp
// Dependencies
import * as pkgCommonjs from 'pkg-commonjs';
import * as pkgModule from 'pkg-module';
import 'pkg-module/index';
// Resolving TS files in dependencies (e.g. implicit extensions & export maps)
import 'pkg-commonjs/ts.js';
import 'pkg-module/ts.js';
// Named exports from CommonJS
import { cjsJs } from 'pkg-commonjs/cjs.js';
import { cjsJs } from 'pkg-commonjs/cjs';
// .js in esm syntax
import * as js from './js/index.js';
Expand Down

0 comments on commit 7e1fe22

Please sign in to comment.