alangpierce/sucrase

How to use sucrase/register/ts with gulpfile.ts?

tiancaixiaobaozi opened this issue · 1 comments

I installed sucrase,but when i run gulp -f build/gulpfile.ts command, it always use ts-node/register:
1


I want it use Requiring external module sucrase/register/ts; like this:

2

Hi! Gulp has its own special support for recognizing and transpiling a gulp config file written in TypeScript gulpfile.ts. From the docs https://gulpjs.com/docs/en/getting-started/javascript-and-gulpfiles#transpilation , it looks like Gulp only supports ts-node is the way to transform the config file. You can still use Sucrase to transpile your codebase, but the config file itself will go through ts-node.

Note that you can still configure ts-node always to use Sucrase by adding a ts-node section and transpiler line to your tsconfig: https://github.com/TypeStrong/ts-node#third-party-plugins . Sucrase's ts-node plugin is called sucrase/ts-node-plugin.

Hope that helps! I don't think there's anything to do here on the Sucrase side, so I'll close this issue.