Is it possible to use ts-node and a custom loader? In the docs I only see a way to enable esm compatibility.
ts-node --esm my-file.ts
I am trying to use a custom loader for testing an ESM module but I don't want to use node to compile each time since this is for a test suite. The way to use (multiple) loaders in node is like so
node --loader=esm --loader=testdouble my-file.js
Sure: Just use ts-node/esm as the loader value. This is documented as an environment variable in ts-node's README:
Or, if you require native ESM support:
NODE_OPTIONS="--loader ts-node/esm"This tells any node processes which receive this environment variable to install ts-node's hooks before executing other code.
Be sure to understand: