solid-jsx not working
Error [ERR_REQUIRE_ESM]: require() of ES Module /home/sid/my-app/node_modules/@mdx-js/rollup/index.js from /ho
me/sid/my-app/vite.config.js not supported.
150 Replies
@.high1 any idea?
my vite config
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, @brendan_csel . 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 cjsoh
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
renaming both of them to cjs works!
thanks
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
GitHub
GitHub - unocss/unocss: The instant on-demand atomic CSS engine.
The instant on-demand atomic CSS engine. Contribute to unocss/unocss development by creating an account on GitHub.
Also
It's faster than tailwind, and has a better VSCode plugin, IMHO
There's a sample repo which demonstrates solid SVG clock here
GitHub
GitHub - high1/solid-clock: sauron clock in solid-js
sauron clock in solid-js. Contribute to high1/solid-clock development by creating an account on GitHub.
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?
Don't think so
And you don't need to mess with postcss
Unless you really need to
GitHub
GitHub - xna00/unocss-language-server
Contribute to xna00/unocss-language-server development by creating an account on GitHub.
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
GitHub
GitHub - neovim/nvim-lspconfig: Quickstart configs for Nvim LSP
Quickstart configs for Nvim LSP. Contribute to neovim/nvim-lspconfig development by creating an account on GitHub.
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
GitHub
GitHub - NvChad/NvChad: An attempt to make neovim cli functional li...
An attempt to make neovim cli functional like an IDE while being very beautiful, blazing fast startuptime - GitHub - NvChad/NvChad: An attempt to make neovim cli functional like an IDE while being...
Huh, it's a world for itself...
Not sure if I want to dive that deep inside
you dont have to start from a full blown config first
make your own
TJ DeVries
YouTube
Effective Neovim: Instant IDE
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...
ThePrimeagen
YouTube
0 to LSP : Neovim RC From Scratch
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
GitHub
unocss/packages/transformer-directives at main ยท unocss/unocss
The instant on-demand atomic CSS engine. Contribute to unocss/unocss development by creating an account on GitHub.
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
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
I told you to look at the code. ma ๐
rehypePlugins: [rehypeHighlight],
}),
didnt know there was a mdx-js config!
whats the difference between solid-mdx and solid-jsx?
There is - you should read the festive manual
๐
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 @md9742x-js
also does rehype provide a css file for the syntax classes?
You can have custom theming
there's hljs.css on solid-site
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
GitHub
solid-site/hljs.css at main ยท solidjs/solid-site
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 @.high1 is it possible to run code whenever the elements in
outlet
from solidjs-router change?
or at route changeIt 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
SolidJS
Solid is a purely reactive library. It was designed from the ground up with a reactive core. It's influenced by reactive principles developed by previous libraries.
i imported it, i get the same error
Your code also needs to be a function
on(() => location.pathname, () => { ... })
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 neovimwhere 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 @.high1 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
same as you would do it in tailwind
I think there's group-focus, group:hover
etc.
[&>: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
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
You see that the rule is not recognized?
It's not underlined
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 divThis works for me
[&_p]:bg-red
It will be underlined
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
It works for me
:((
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
https://stackblitz.com/edit/github-prvqmz?file=src%2FClockFace.tsx
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 :((
You can open an issue, though
It'll be fixed in 1.6.7, I hope
oop nvm I see what you mean
done
also custom classes dont work on break points
for example
lg:custom-div
this doesnt work like that of in tailwindto test this you need transformers-directives https://github.com/unocss/unocss/tree/main/packages/transformer-directives
GitHub
unocss/packages/transformer-directives at main ยท unocss/unocss
The instant on-demand atomic CSS engine. Contribute to unocss/unocss development by creating an account on GitHub.
huh, that's not good...
But that's an issue in unocss, right?
@siduck_og, I've tried, but tailwind also does not apply custom classes on breakpoints, at least not on their playground
Tailwind Play
Tailwind Play
An advanced online playground for Tailwind CSS that lets you use all of Tailwind's build-time features directly in the browser.
yes most likely
it works for me, try this
Tailwind Play
Tailwind Play
An advanced online playground for Tailwind CSS that lets you use all of Tailwind's build-time features directly in the browser.
@.high1 that wasnt a bug in solid, loading unocss plugin before solidplugin in vitejs config fixes this ๐
GitHub
Custom selectors not working only on solidjs ( unocss ) ยท Issue #14...
Describe the bug hi there, Im using unocss and i use this syntax to add classes for all span elements in a div [&_span]:bg-red , this will add bg-red to all span elements of the parent div ...
Hm, I don't see why would custom transform change the class string?
It's a liability... But it's solved.