ts-node
ts-node copied to clipboard
Pass jsxImportSource to swc
As you can probably guess, like so many open-source projects we do not rely on local testing, so that is insufficient. Will need proper automated tests if it is to be merged.
Hi @cspotcode, I'm happy to take over this and help write the test.
Since this PR passes through an SWC option (namely importSource), I tried to find a test for the one already forwarded (like jsxFactory) for inspiration, but they are not covered either. Am I right to think this is where it should go: https://github.com/TypeStrong/ts-node/blob/main/src/test/transpilers.spec.ts?
When you confirm it I'll write that test and hopefully, we can merge this PR. 🙏
@jraoult thanks for taking a look. I think you're correct, that is the file to put tests. It looks like we have two kinds of tests:
a) tests that createSwcConfig() is generating the correct SWC configuration based on a TypeScript tsconfig
b) tests that compile() is transforming a snippet of input TS into the correct output JS
Adding one of each should be good.
Hey there! 👋🏻
I'd like to take ownership of this PR/issue.
Currently, ts-node doesn't play nicely with swc when altering the jsxImportSource setting in a tsconfig.json file. I've managed to get it working by monkey-patching the module with the provided changes from @alecmev.
Regarding tests, adding them seems straightforward. However, on two of my machines (macOS and Windows), the test suites fail even without any changes. This makes it difficult to guarantee the code's functionality cleanly.
Note that I don't believe it's necessary to include a test for this PR merge. Many existing features, such as the current jsxFactory and jsxFragmentFactory options, are also untested.