diff --git a/src/test/transpilers.spec.ts b/src/test/transpilers.spec.ts index b5256e5d8..e59753c00 100644 --- a/src/test/transpilers.spec.ts +++ b/src/test/transpilers.spec.ts @@ -262,6 +262,38 @@ test.suite('swc', (test) => { ); }); + test.suite('jsx and jsxImportSource', (test) => { + test( + 'jsx=react-jsx', + compileMacro, + { + jsx: 'react-jsx', + }, + outdent` +
+ `, + outdent` + /*#__PURE__*/ import { jsx as _jsx } from "react/jsx-runtime"; + _jsx("div", {}); + ` + ); + test( + 'jsx=react-jsx w/custom jsxImportSource', + compileMacro, + { + jsx: 'react-jsx', + jsxImportSource: 'foo', + }, + outdent` +
+ `, + outdent` + /*#__PURE__*/ import { jsx as _jsx } from "foo/jsx-runtime"; + _jsx("div", {}); + ` + ); + }); + test.suite( '#1996 regression: ts-node gracefully allows swc to not return a sourcemap for type-only files', (test) => { diff --git a/src/transpilers/swc.ts b/src/transpilers/swc.ts index 3c7f3070f..64f563237 100644 --- a/src/transpilers/swc.ts +++ b/src/transpilers/swc.ts @@ -143,6 +143,7 @@ export function createSwcOptions( strict, alwaysStrict, noImplicitUseStrict, + jsxImportSource, } = compilerOptions; let swcTarget = targetMapping.get(target!) ?? 'es3'; @@ -235,6 +236,7 @@ export function createSwcOptions( pragma: jsxFactory!, pragmaFrag: jsxFragmentFactory!, runtime: jsxRuntime, + importSource: jsxImportSource, }, useDefineForClassFields, },