ts-fly is a simple wrapper around Node.js that registers Sucrase hooks,
making it possible to run TypeScript files in addition to JavaScript files
transparently. The difference with Sucrase is that it would let you import
ESM-only libraries, as well as .ts files.
TypeScript and JavaScript files can also import each other.
Do not use this on production: Sucrase devs already recommend you not to run their code on production, the code we're adding in this repo is even more unsafe and tailored to Transloadit needs. If you do, you are on your own.
yarn add --dev @transloadit/ts-flyUse the ts-fly command the same as you would use node. Any CLI arguments are
passed along.
yarn ts-fly myFile.tsYou can use it with --require CLI flag:
node -r @transloadit/ts-fly myFile.tsYou can also require it from JS:
'use strict';
require('@transloadit/ts-fly').defaultHooks();
require('./myFile.ts'); // works- You can't import
.tsfiles from ESM. If you want to use ESM syntax, you have convert the file to TS and use.tsfile extension, or usecreateRequire. - By default, we only support
.jsand.tsfile extensions. - Windows would only support the
node -r @transloadit/ts-fly …form, as the executable is a POSIX shell script. - Only literal specifiers which start with
./and do not contain any'or"char are fully supported. Support for dynamic imports with dynamic specifiers is limited.
corepack yarn
corepack yarn test