Skip to content

Commit 01d8719

Browse files
committed
feat: support jsx
1 parent 25a059d commit 01d8719

4 files changed

Lines changed: 35 additions & 1 deletion

File tree

src/utils/filename.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import path from 'node:path'
22

33
export const RE_JS: RegExp = /\.([cm]?)js$/
4-
export const RE_TS: RegExp = /\.([cm]?)ts$/
4+
export const RE_TS: RegExp = /\.([cm]?)tsx?$/
55
export const RE_DTS: RegExp = /\.d\.([cm]?)ts$/
66
export const RE_NODE_MODULES: RegExp = /node_modules/
77

tests/__snapshots__/index.test.ts.snap

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,27 @@ declare function generateTransform(s: MagicString | undefined, id: string): Code
179179
export { MagicStringAST, build };"
180180
`;
181181
182+
exports[`tsx 1`] = `
183+
"// tsx.d.ts
184+
import { JSX } from "solid-js";
185+
186+
//#region tests/fixtures/tsx.d.ts
187+
declare function createComponent(): JSX.HTMLAttributes<HTMLElement>;
188+
189+
//#endregion
190+
export { createComponent };
191+
// tsx.js
192+
import { jsx } from "react/jsx-runtime";
193+
194+
//#region tests/fixtures/tsx.tsx
195+
function createComponent() {
196+
return /* @__PURE__ */ jsx("div", {});
197+
}
198+
199+
//#endregion
200+
export { createComponent };"
201+
`;
202+
182203
exports[`typescript compiler 1`] = `
183204
"// entry1.d.ts
184205

tests/fixtures/tsx.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import type { JSX } from 'solid-js'
2+
3+
export function createComponent(): JSX.HTMLAttributes<HTMLElement> {
4+
return <div />
5+
}

tests/index.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ test('basic', async () => {
1414
expect(snapshot).toMatchSnapshot()
1515
})
1616

17+
test('tsx', async () => {
18+
const { snapshot } = await rolldownBuild(
19+
path.resolve(dirname, 'fixtures/tsx.tsx'),
20+
[dts()],
21+
)
22+
expect(snapshot).toMatchSnapshot()
23+
})
24+
1725
test('typescript compiler', async () => {
1826
const root = path.resolve(dirname, 'fixtures/tsc')
1927
const { snapshot } = await rolldownBuild(

0 commit comments

Comments
 (0)