Skip to content

Pass jsxImportSource to swc#1852

Closed
alecmev wants to merge 1 commit into
TypeStrong:mainfrom
alecmev:swc-jsx-import-source
Closed

Pass jsxImportSource to swc#1852
alecmev wants to merge 1 commit into
TypeStrong:mainfrom
alecmev:swc-jsx-import-source

Conversation

@alecmev

@alecmev alecmev commented Jul 28, 2022

Copy link
Copy Markdown

I'm using it for hastscript. Tested locally.

@cspotcode

Copy link
Copy Markdown
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

jraoult commented May 9, 2023

Copy link
Copy Markdown

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
Copy Markdown
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

RomainLanz commented Sep 7, 2023

Copy link
Copy Markdown

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