diff --git a/src/cjs/api/module-resolve-filename/resolve-implicit-extensions.ts b/src/cjs/api/module-resolve-filename/resolve-implicit-extensions.ts index 8b9b20fdd..48cd7540e 100644 --- a/src/cjs/api/module-resolve-filename/resolve-implicit-extensions.ts +++ b/src/cjs/api/module-resolve-filename/resolve-implicit-extensions.ts @@ -15,7 +15,7 @@ export const createImplicitResolver = ( ): SimpleResolve => ( request, ) => { - if (request === '.' || request === '..') { + if (request === '.' || request === '..' || request.endsWith('/..')) { request += '/'; } diff --git a/src/esm/hook/resolve.ts b/src/esm/hook/resolve.ts index 67ef263a3..0702ea8e2 100644 --- a/src/esm/hook/resolve.ts +++ b/src/esm/hook/resolve.ts @@ -141,7 +141,7 @@ const resolveDirectory: ResolveHook = async ( context, nextResolve, ) => { - if (specifier === '.' || specifier === '..') { + if (specifier === '.' || specifier === '..' || specifier.endsWith('/..')) { specifier += '/'; } diff --git a/tests/fixtures.ts b/tests/fixtures.ts index f76f413fc..cb048267f 100644 --- a/tests/fixtures.ts +++ b/tests/fixtures.ts @@ -212,7 +212,10 @@ export const files = { `, 'period.in.name.ts': 'export { a } from "."', - 'dotdot/index.ts': 'export { a } from ".."', + dotdot: { + 'index.ts': 'export { a } from ".."', + 'dotdot/index.ts': 'export { a } from "../.."', + }, 'index.js': 'throw new Error("should not be loaded")', }, diff --git a/tests/specs/smoke.ts b/tests/specs/smoke.ts index 0bd1fd9d7..4d437cfae 100644 --- a/tests/specs/smoke.ts +++ b/tests/specs/smoke.ts @@ -284,6 +284,7 @@ export default testSuite(async ({ describe }, { tsx, supports, version }: NodeAp import './ts/period.in.name'; import '@/ts/period.in.name'; import './ts/dotdot'; + import './ts/dotdot/dotdot'; // .jsx import * as jsx from './jsx/index.jsx';