#solid-jsx not working
246 messages ยท Page 1 of 1 (latest)
@plain flame any idea?
my vite config
import { defineConfig } from "vite";
import solidPlugin from "vite-plugin-solid";
import mdx from "@mdx-js/rollup";
export default defineConfig({
plugins: [solidPlugin(), mdx({ jsxImportSource: "solid-jsx" })],
server: {
port: 3000,
},
build: {
target: "esnext",
},
});
Have you got "type": "module" in your package.json?
oh cool the error is gone now!
Feel free to close this thread if your query is resolved. Perhaps open another one if you have a different question.
Thanks, @left hill . There's a section dedicated to this in the beginning of the README file,
Use mdx or xdm with solid-js.
This module is ESM only, due to mdx and xdm being ESM only.
Adding
"type": "module"
in package.json is one option.
i tried this but i get some postcss error now
Well, if your project is a module, you need to be explicit
it's postcss.config.cjs if you are writing common JS
Or use a more modern syntax and postcss.config.js or mjs
i renamed the file and i get this error now
It's the same issue.
You really need to read ๐ these error messages.
Just name it tailwind.config.cjs
If something uses module.exports..., it's cjs
oh
i changed the syntax for both the files but i get the same error!
You can use export default for tailwind and postcss, if you prefer that
What did you do exactly?
If your files are using module.exports, name them .cjs
It's not that renaming works, it's that you're confused with cjs and mjs syntax, and you have every right to be...
It's an issue inherited from common js modules used by Node before the proper JS module specification
So, I recommend that you use those only when nothing else works
This one would work if it was named tailwind.config.mjs
postcss needs imports there
If you're using vite, I don't think you need postcss
I think you probably are
Try unocss https://github.com/unocss/unocss
Also
It's faster than tailwind, and has a better VSCode plugin, IMHO
There's a sample repo which demonstrates solid SVG clock here
Uses unocss, Vite, TypeScript
There's also ESLint config
Could be a nice start if you're not too far along
Yeah, Prettier also
faster in build time?
also i dont use vscode so the vscode plugin wont matter to me :p
It has a faster engine, and has all the optimizations that Tailwind has
does it have a lsp?
ok i can use this with neovim!
You're on your own there
dont worry about that, ive used custom lsps in neovim before
If you have ESLint and Prettier working in Neovim, I'd be curious too see that
that works since ages lul
Typescript type check also?
yes
tsserver works in neovim
so almost all vscode lsps will work in neovim too
Hm, I would really love to have my setup from solid-clock repo transfered to neovim
i install all the lsp/formatter/linter/debugger etc binaries from mason.nvim plugin
incase you're curious about my config, this is it https://github.com/NvChad/NvChad ๐
you dont have to start from a full blown config first
make your own
Going from no set up to instant IDE using kickstart.nvim in #nvim.
Check out the repo: https://github.com/nvim-lua/kickstart.nvim
PDE Video: https://youtu.be/QMVIJhC9Veg
Twitch
We're always live streamin on twitch!Twitch : https://twitch.tv/teej_dv
Discord: https://discord.gg/h2yeg4wrSK
Links
Twitch: https://twitch.tv/teej_dv
Twitter...
I setup the entire neovim experience from nothing to LSP!
REPO: https://github.com/ThePrimeagen/init.lua
chapters
00:00 Introduction
00:35 Init.lua - Your First Files
02:23 The First Remap
03:43 Plugin Manager and Fuzzy Finder
07:07 Colorscheme
09:08 Treesitter
13:30 3 Must Have Plugins
18:06 LSP Setup
21:33 Editor Settings
24:24 THE BEST ...
btw can I use unocss classes in css files?
i do it a lot with tailwind
Yes, there's apply also
Your config should be working OOTB, unless you're using typography preset
wew looks cool! will try it out ๐
Only things that you will need to do is move theme config from theme: { extend: { ... } } to just theme: { }
And to uno.config.ts file
thx i'll do the change today!
btw how do i highlight the code tags which are in the jsx generated by solid-jsx?
i tried using prism-js but didnt work
You can check out how it's done on solid-js site - there are other things you need to set for code highlightning
solid-js site uses solid-jsx?
ive used highlightjs with solid-marked before,worked fine
this works but there's 1 sec delay ๐ฆ
without settimeout it doesnt work
createEffect(() => {
document.querySelectorAll("pre code").forEach((el) => {
console.log(el)
});
});
that doesnt print anything, doesnt createEffect run after component has been rendered?
with solid-marked, i was able to set highlight to code elements after they rendered
You're not doing it correctly.
Solid-site uses solid-mdx, but it doesn't matter what's used since this is a matter of mdx-js configuration.
hmm then how do I add the highlight stuff to all code elements at compile time?
is it possible?
It is, it works that way on solid-site
import rehypeHighlight from 'rehype-highlight';
Do you have that in your mdx-js config?
no
didnt know there was a mdx-js config!
whats the difference between solid-mdx and solid-jsx?
i tried from the solid-jsx readme, couldnt find anything syntax highlight related ๐ค
The difference is that solid-jsx works over jsx function and fixes some of the issues that you can encounter due to solid differently dealing with elements than react
solid-mdx just precreates and exports basic components, so that they are there when imported
The difference is also that solid-mdx compiles to jsx, and that jsx goes through solid, so if you have a component inside mdx itself, it would be reactive.
But why would you write a component inside mdx, I'm not sure.
wew thx just including this worked!
you could have issues when building
The instructions for highlight plugins are not in solid-jsx docs, it belongs to @pale slatex-js
also does rehype provide a css file for the syntax classes?
is there a default one?
You could basically download a custom theme, and just add that to your css
I'm not sure about the defaults...
oh no wonder my previous theme file from highlight.js worked ๐
yep
Code that powers the SolidJS.com platform. Contribute to solidjs/solid-site development by creating an account on GitHub.
Here's what solid uses
There's also some theming there for markdown prose
That you don't need
btw @plain flame is it possible to run code whenever the elements in outlet from solidjs-router change?
or at route change
It should be
this works
but if i remove printing of location.pathname then it stops working
cant i include location.pathname in array of createeffect?
Yes, because the effect does not know that it should run
you could use on
createEffect(on(() => location.pathname, { your code ... }));
If you need to explicitly depend on something
But that almost always points that you're not doing it right
oh solid's createEffect works differently
How do you mean differently? It works exactly as it should, unlike React ones ๐
effects knows their deps, and rerender accordingly
i assumed it'd had that array of dependencies too, like react ๐
Read the festive docs
There's no array of deps, and components do not rerender, in fact, they dissappear
There's quite a bit to process, I'll give you that
i did before, its easy to forget when I work with react/solid on the same day!
Yep,
you sure this is the right syntax?
Not 100% percent, but it's there
or On's a function in solidjs module?
You need to import on, first
yep
oh got it, i was using your previous code. thx for all the help!
np, keep on pushing...
btw solid-js compiles all the jsx stuff to vanilla js right? then why is it not a devdependency?
i put it and solid-router as devdependcy, it still works :0
tried out unocss today, its quite fast!
but i dont get any completions at all in vscode ( installed unocss extension )
however i do get some completions in neovim
where vscode shows no completions at all :/
nvm i give up man
tailwind might be bloated as compared to this but it has a good community support & lsp too
nvm fixed it
this doesnt work
btw @plain flame can i select multiple child elements with unocss?
and the same thing works on the playground
my unoconfig contains the same presets as the playground btw
import transformerAttributifyJsx from "@unocss/transformer-attributify-jsx";
import {
defineConfig,
presetAttributify,
presetUno,
} from 'unocss'
export default defineConfig({
presets: [
presetUno(),
presetAttributify(),
],
transformers: [
transformerAttributifyJsx(),
],
});
[&>*:bg-red] doesnt work at all
but [&>*]:bg-red works in the playground
Not sure about custom selectors
If it doesn't work, there's a special rule in the playground for that, you just need to copy it inside your config
The rules are basically regexes
Most of the time, you can just add things that you need
no such rule in the playground config
Then it must work in your code also
it doesnt, thats why i asked it here
I would need to see your config
here
<div bg-lime p-5 class="[&>p]:bg-red">
<p> kek</p>
</div>
Not sure why that doesn't work
Where's the playground link?
Also, I'm noticing that it's not underlined, so uno is not recognising it
yep then why does it work?
Uno does not recognize it
You'll have to look or ask on their GitHub for arbitrary selectors syntax, haven't used it
But bg-lime and p-5 are underlined
So, you see that these are recognized
Your arbitrary selector is not
yes
Why does it work in that specific case, I don't know
It's something with the playgrond
But it's not recognized and it will not work
is there any other way through which i could select? like selecting all p elements in parent div
oh doesnt work locally for me ://
do i need a preset for this?
You don't it's arbitrary
ughh man then what could go wrong
:((
With auto completion
Now I'm not aware of the syntax for those, but you can always ask
can you check if it works on this project? the starter project is very minimal ( just for testing )
Can't you put that on code sandbox or
Ok lemme try
So, it's a bug in solid
Solid
Voby
Svelte
So, looks like an issue in Solid to me
That's one downside -this custom JSX transformation causes issues sometimes, the another one is no destructuring...
oh :((
oop nvm I see what you mean
done
also custom classes dont work on break points
for example
.custom-div {
@apply text-center bg-red;
}
lg:custom-div
this doesnt work like that of in tailwind
to test this you need transformers-directives https://github.com/unocss/unocss/tree/main/packages/transformer-directives
huh, that's not good...
But that's an issue in unocss, right?
@glass laurel, I've tried, but tailwind also does not apply custom classes on breakpoints, at least not on their playground
yes most likely
it works for me, try this
@layer base {
.custom-div {
@apply flex text-yellow-500;
}
}
@plain flame that wasnt a bug in solid, loading unocss plugin before solidplugin in vitejs config fixes this ๐
Hm, I don't see why would custom transform change the class string?