Skip to content

Support .js.ts conversion in local export map #59

Description

@remcohaszing

Feature request

Using tsx it’s possible to write import … from './index.js'. It’s ok if index.js doesn’t exist, but only index.ts. It will just resolve to that.

If package.json contains an exports field, it’s valid to import the package by name instead of by a path reference.

For example, after compilation of https://github.com/remcohaszing/remark-mdx-frontmatter, it’s valid to rewrite the compiled test to use import remarkMdxFrontmatter from 'remark-mdx-frontmatter' in test.ts. This won’t work without compiling first.

I suggest to make tsx use the same logic for aliasing .js.ts after resolving package.json exports as it does for relative imports.

Why?

  1. When testing the public interface, tests closer match how a user would use a package.
  2. This allows to use tsx for importing other local packages inside a mono repo.

Alternatives

N/A

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions