Skip to content

require imports javascript if exist instead of typescript #529

Description

@cuarti

When you import/require a module from the typescript file called from ts-node, it imports typescript if javascript doesn't exist, otherwise execute javascript instead of typescript.

In my case, I have a webpage in typescript and compiled to javascript to execute it in development and production, because is faster instead of execute typescript directly. I have some typescript scripts to test actions and modify some data of database.
The problem is that this scripts use modules from webpage, that have its javascript compiled files, so when I execute scripts from ts-node this imported files are old versions and to use the new ones I need to have a tsc --watch executed, but with watcher I don't need ts-node because I can execute javascript versions of scripts.
I don't want to execute the watcher to not have another process executed with a lot of inotify watching files.

I don't know if someone of you has had this problem. I've tried to solve it in a fork, but when I create a new object with extensions instead of add the new ones to original object, I have an error when ts-node tries to execute the typescript file target, not the imports. The error is basicaly that don't use the typescript register or it doesn't compile well.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions