mocha-examples
mocha-examples copied to clipboard
feat: added TypeScript + ts-node/esm and tsx/esm examples
I noticed there wasn't yet an example that shows TypeScript transpilation on-the-fly with ESM imports/loaders. https://github.com/mochajs/mocha/issues/5002 is a Mocha issue asking about support.
This adds two examples:
-
--import=tsx/esm: Newer--importflag for Node.js post-v18.19.0/v20.6.0 -
--loader=ts-node/esm: Older--loaderflag for Node.js
Fixes #75
tsx uses esbuild which doesn't support decorators. Whenever you have decorators in your code, don't use tsx/esbuild