jaredpalmer / tsdx

Zero-config CLI for TypeScript package development
https://tsdx.io
MIT License
11.28k stars 507 forks source link

`@emotion/babel-preset-css-prop` not working with .tsx files #710

Closed sgentry closed 4 years ago

sgentry commented 4 years ago

Current Behavior

I've added an additional Babel preset (@emotion/babel-preset-css-prop) using .babelrc. When my React component has a .tsx file extension, this preset doesn't seem to get applied to transpiled output in dist folder. If I rename to .jsx, works great. Maybe I'm missing some additional configuration for this to work but I haven't found anything yet looking through docs.

Expected behavior

I expect my additional preset to be applied to all ts/tsx files.

Suggested solution(s)

Additional context

Your environment

Software Version(s)
TSDX 0.13.2
TypeScript 3.8.3
Browser
npm/Yarn 6.14.4/1.22.0
Node 12.16.2
Operating System Windows 10
agilgur5 commented 4 years ago

Is this for tsdx build specifically? There's an existing issue for Babel not being run on TS during tsdx test (#583)

Otherwise, there are integration tests for Babel configs for tsdx build. Reading the @emotion/babel-preset-css-prop docs, it says it changes the JSX from React.createElement to its own thing. So you'd probably need to set your tsconfig.json's jsx property to 'preserve' or something instead of 'react'.

When jsx: 'react' is set, TypeScript compiles the JSX instead of Babel. That's a TS thing rather than TSDX specific, so you wouldn't really find that in TSDX docs.

sgentry commented 4 years ago

Yes, this was for tsdx build. Looks like you are correct in that changing jsx to preserve fixed my issue. Sorry for the hassle but I appreciate your response. Thanks!