Open andreidmt opened 2 years ago
Thanks for reporting. An esm loader is needed to be implemented. I'll fix this later.
After taking another look, I'm not quite sure about how this should be implemented.
ts-node
has given a good example https://github.com/TypeStrong/ts-node/blob/3a2848c9968f03f7b05e57e833ca256b52ab4e18/src/esm.ts but it involves many experimental features and immature specs. https://github.com/TypeStrong/ts-node/issues/1007
We should expect TypeScript supporting ESM first then consider what we should follow. This should be covered in TypeScript 4.6 (ideally). https://github.com/microsoft/TypeScript/issues/46452
If anyone has a better solution please let me know :)
node -r swc-register src/**/*.test.ts
works as expected if"type": "module"
is not present inpackage.json
, otherwise the script fails with:Adding
--experimental-specifier-resolution=node
fixes it but the fails with:Using node
v14.17.0
,.swcrc
: