Skip to content

Commit

Permalink
fix(resolver): handle importing ".."
Browse files Browse the repository at this point in the history
fixes #626
  • Loading branch information
privatenumber committed Aug 1, 2024
1 parent ca4bf11 commit 3cf0b6a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export const createImplicitResolver = (
): SimpleResolve => (
request,
) => {
if (request === '.') {
request = './';
if (request === '.' || request === '..') {
request += '/';
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/esm/hook/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ const resolveDirectory: ResolveHook = async (
context,
nextResolve,
) => {
if (specifier === '.') {
specifier = './';
if (specifier === '.' || specifier === '..') {
specifier += '/';
}

if (isDirectoryPattern.test(specifier)) {
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")',
},
Expand Down
1 change: 1 addition & 0 deletions tests/specs/smoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 3cf0b6a

Please sign in to comment.