-
Notifications
You must be signed in to change notification settings - Fork 507
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
Using jsx in .jsx files not achievable -- Babel presets aren't used #443
Comments
Regarding babel, tsdx's README.md seems highly contradictory to me, stating at one point "While yes, TSDX does use Babel [...] it does not support custom babel configurations" and then "You can add your own .babelrc to the root of your project and TSDX will merge it with its own babel transforms" 🤔 |
good points. we may need to revisit that readme. meanwhile we'll need help digging into why this bug is happening, i dont really understand it myself. maybe something in our rollup config |
tsdx/src/createRollupConfig.ts Line 159 in 1d8f123
can you try locally modifying this to add .jsx and see if that fixes it |
Thank you for the quick response @sw-yx! According to babel docs:
I tried anyways and can verify that their docs are accurate, so no positive effect. Also, just tried |
oh dear. then i dont know why it doesnt work 😅 |
I am trying to achieve the exact same thing - switch to But the bug aside, does TSDX allow for custom babel conf or not? I agree that the README contradicts itself. |
So I put some console.log's in
The output of
|
👍 i dont remember when this feature was introduced, but i think in our switch back and forth on webpack plugins we probably broke this feature. cc @agilgur5 |
Can take a closer look tomorrow (just got back from weeks of travels today), but off the top of my head seems like a duplicate of #143 Regarding
|
So TSDX already defaults tsdx/src/createRollupConfig.ts Line 146 in 95ff6da
The tsconfig setting also doesn't impact Babel config in any way, as far as I can tell.
According to #143 and ezolenko/rollup-plugin-typescript2#150 (comment) , your {
"include": [
"*.ts+(|x)",
"**/*.ts+(|x)",
"*.js+(|x)",
"**/*.js+(|x)"
],
"compilerOptions": {
"allowJs": true
}
} (or equivalent on the I'm guessing you already have that set? There isn't a full repro here so not sure. Line 137 in 95ff6da
Try adding @babel/preset-env to your babelrc ? That would likely confirm that that line is the bug
There don't seem to be any tests for custom babel configs, so we'll have to create some, and that would help verify this possible bug better as well. Notably, none of the custom configs in #379 add any presets, only plugins |
@agilgur5 According to https://www.typescriptlang.org/docs/handbook/tsconfig-json.html with But wow! It seems changing my
really does the trick! |
To use .jsx files in the upcoming rich text field editor we need tsdx 0.12 together with the workaround mentioned on jaredpalmer/tsdx#443
To use .jsx files in the upcoming rich text field editor we need tsdx 0.12 together with the workaround mentioned on jaredpalmer/tsdx#443
To use .jsx files in the upcoming rich text field editor we need tsdx 0.12 together with the workaround mentioned on jaredpalmer/tsdx#443
Yes, I also wrote "(or equivalent on the
Ok, think that confirms that that line I was looking at & referenced above is a bug. Thanks for checking that! I'll get a PR out soon to fix that so you don't need to add |
- To use .jsx files in the upcoming rich text field editor we need tsdx 0.12 together with the workaround mentioned on jaredpalmer/tsdx#443 - Use docz 1.3.2 - Ran `yarn upgrade`
- To use .jsx files in the upcoming rich text field editor we need tsdx 0.12 together with the workaround mentioned on jaredpalmer/tsdx#443 - Use docz 1.3.2 - Ran `yarn upgrade`
- To use .jsx files in the upcoming rich text field editor we need tsdx 0.12.3 together with the workaround mentioned on jaredpalmer/tsdx#443 - Use docz 1.3.2 - Ran `yarn upgrade`
I’m still encountering this bug. Luckily adding those two babel presets fixed it for me 👍 |
@jlarmstrongiv you don't need to add
I had been considering adding it and changing |
Current Behavior
With my
tsconfig.json
'scompilerOptions.jsx
set to"react"
, when using.jsx
files that contain any jsx markup, ontsdx build
I getNow, I'd expect this to work out of the box with
.jsx
files but I also tried to instead set thetsconfig.json
'scompilerOptions.jsx: "preserve"
and use@babel/preset-react
via my .babelrcStill getting the same error. While the plugins I use seem to work, preset-react seems to not do the job for some reason.
Expected behavior
.jsx
files' jsx code should be transpiled according to the tsconfig'sjsx
option or there should be another way to achieve this.Additional context
Using the
.tsx
file extension instead of.jsx
for the same file, everything works as expected while usingjsx: "react"
but still can't get it to work withjsx: "preserve"
plus Babel.Your environment
The text was updated successfully, but these errors were encountered: