Skip to content

Commit db36e79

Browse files
authored
more robust / perf sensitive approach
1 parent 89c723c commit db36e79

File tree

1 file changed

+4
-1
lines changed
  • packages/repl/src/lib/workers

1 file changed

+4
-1
lines changed

packages/repl/src/lib/workers/npm.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,10 @@ export function resolve_subpath(pkg: Package, subpath: string): string {
199199
}
200200

201201
export function normalize_path(pkg: Package, path: string, importee: string, importer: string) {
202-
for (const suffix of ['', '.js', '.mjs', '.cjs', '/index.js', '/index.mjs', '/index.cjs']) {
202+
const suffixes = path.endsWith('/')
203+
? ['index.js', 'index.mjs', 'index.cjs']
204+
: ['', '.js', '.mjs', '.cjs', '/index.js', '/index.mjs', '/index.cjs'];
205+
for (const suffix of suffixes) {
203206
let with_suffix = (path + suffix).replace(/\/+/g, '/');
204207

205208
if (pkg.meta.browser) {

0 commit comments

Comments
 (0)