Skip to content

Replace preferTsExts by a smart ordering #868

Description

@theKashey

continuation of #837, #529, #648

ts-node has one quite confusing, but quite explainable issue - it adds .ts to the resolve.extensions. However - adds to the end, which breaks code user expectations about how file resolving should work.

So - how it should work

  • js should be preferred over ts when preferTsExts is not set.
  • ts should be preferred over js when preferTsExtsis set.
  • 😅ts and js should be preferred over css and less.

How it works

However - the current logic adds ts or after everything, or before everything.

While - should do it relative to js position - just after jsx?, or just before.

The problem

preferTsExts is still not documented, and, honestly, should not be documented. It shall work out of the box. 5 months ago, when I run into the issue, I've resolved it by manually hoisting extensions, hopefully, it's now supported out of the box.

But the problem is not closed unless default behavior is broken.

What would you say about changing this moment? js and ts should be in one "group", so let's make it a bit more "smart".

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions