Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass jsxImportSource to swc #1852

Closed
wants to merge 1 commit into from

Conversation

alecmev
Copy link

@alecmev alecmev commented Jul 28, 2022

I'm using it for hastscript. Tested locally.

@cspotcode
Copy link
Collaborator

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.

@jraoult
Copy link

jraoult commented May 9, 2023

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. 🙏

@cspotcode
Copy link
Collaborator

@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.

@RomainLanz
Copy link

RomainLanz commented Sep 7, 2023

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.

@cspotcode cspotcode mentioned this pull request Sep 14, 2023
@alecmev alecmev deleted the swc-jsx-import-source branch September 18, 2023 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants