kmagiera / babel-watch

Reload your babel-node app on JS source file changes. And do it fast.
MIT License
529 stars 70 forks source link

Typescript Support? #111

Closed Berkays closed 3 years ago

Berkays commented 4 years ago

Is it also possible to watch for typescript src folder followed by normal operation? When i change a typescript file it does not compile thus no restart

IMalyugin commented 4 years ago

I know it's a little bit too late, but yes, it is possible.

babel-watch uses babel (obviously) underneath. For typescript to work with babel, you need to add @babel/typescript preset to babel config.

After doing so, you're still left with some errors such as "Cannot use import statement outside a module", or any messages indicating babel does not parse the typescript files.

To fix that you need to run the binary with --extensions flag as follows: babel-watch path-to-entry/index.ts --extensions .ts

STRML commented 3 years ago

Closing as there is a viable solution here.

arvigeus commented 3 years ago

Just to a quick note that costed me half an hour to solve: remove type: "module" from package.json