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 7dac3b6ec..8b9b20fdd 100644 --- a/src/cjs/api/module-resolve-filename/resolve-implicit-extensions.ts +++ b/src/cjs/api/module-resolve-filename/resolve-implicit-extensions.ts @@ -15,8 +15,8 @@ export const createImplicitResolver = ( ): SimpleResolve => ( request, ) => { - if (request === '.') { - request = './'; + if (request === '.' || request === '..') { + request += '/'; } /** diff --git a/src/esm/hook/resolve.ts b/src/esm/hook/resolve.ts index 7ea351dc2..67ef263a3 100644 --- a/src/esm/hook/resolve.ts +++ b/src/esm/hook/resolve.ts @@ -141,8 +141,8 @@ const resolveDirectory: ResolveHook = async ( context, nextResolve, ) => { - if (specifier === '.') { - specifier = './'; + if (specifier === '.' || specifier === '..') { + specifier += '/'; } if (isDirectoryPattern.test(specifier)) { diff --git a/tests/fixtures.ts b/tests/fixtures.ts index aa9ce82f9..f76f413fc 100644 --- a/tests/fixtures.ts +++ b/tests/fixtures.ts @@ -212,6 +212,7 @@ export const files = { `, 'period.in.name.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 9a5a8e358..0bd1fd9d7 100644 --- a/tests/specs/smoke.ts +++ b/tests/specs/smoke.ts @@ -283,6 +283,7 @@ export default testSuite(async ({ describe }, { tsx, supports, version }: NodeAp import '@/ts/'; import './ts/period.in.name'; import '@/ts/period.in.name'; + import './ts/dotdot'; // .jsx import * as jsx from './jsx/index.jsx';