S
SolidJSβ€’12mo ago
Mirardes

[Solid-Start] Issue with context who don't return the value

Hello I have a very strange bug with the new solid-start template : I have a library who is package with tsup and tsup-preset-solid : https://github.com/qlaffont/rosetty-solid When I try to import my provider to access to my context and call it in my app sometimes I can access to the context value and sometimes I got undefined If i rebuild with tsup -> It will work 1 time and the other time is breaking but no changes have been made on the code It's very frustrating... Can someone can help me, it is very strange and it is blocking me to make the migration to new solid start for my company :
88 Replies
Mirardes
MirardesOPβ€’11mo ago
I can do a video call on Discord or Google meet if needed
bigmistqke
bigmistqkeβ€’11mo ago
I initially thought it would be related to https://github.com/solidjs/solid-refresh/issues/33 but as you mention you are importing the provider from another module, so not sure
GitHub
useContext return undefined Β· Issue #33 Β· solidjs/solid-refresh
Describe the bug Here is the example code type CtxType = { foo : string } const Ctx = createContext<CtxType>() const useAppCtx = () => { const ctx = useContext(Ctx) if (!ctx) throw 'co...
Mirardes
MirardesOPβ€’11mo ago
Yes it's from another module and I have try to kill and restart server is not working too
bigmistqke
bigmistqkeβ€’11mo ago
a wait, maybe it is related can you put the createContext in another module and import it into the Provider's? pretty sure it's the bug described in the issue
Mirardes
MirardesOPβ€’11mo ago
I will try
bigmistqke
bigmistqkeβ€’11mo ago
gl
Mirardes
MirardesOPβ€’11mo ago
nop I have try and is not working I have still the bug
bigmistqke
bigmistqkeβ€’11mo ago
can you show me the code?
Mirardes
MirardesOPβ€’11mo ago
library code : app.tsx : home.tsx :
bigmistqke
bigmistqkeβ€’11mo ago
mm that does look good
Mirardes
MirardesOPβ€’11mo ago
this why I open the issue ^^" I don't understand why it doesn't work
bigmistqke
bigmistqkeβ€’11mo ago
yes i think this is a good one for a github issue i didn't understand the vid properly it looks like a build issue
Mirardes
MirardesOPβ€’11mo ago
GitHub
[Bug?]: Issue with context who don't return the value Β· Issue #1185...
Duplicates I have searched the existing issues Latest version I have tested the latest version Current behavior 😯 Context return undefined Expected behavior πŸ€” Context should return value Steps to r...
bigmistqke
bigmistqkeβ€’11mo ago
i would mb describe the issue a bit better on gh, for documentation sake instead of linking to discord not so accessible for other developers with similar issues in the future
Mirardes
MirardesOPβ€’11mo ago
okay πŸ‘ done βœ…
bigmistqke
bigmistqkeβ€’11mo ago
Much better, thanks πŸ™
Mirardes
MirardesOPβ€’11mo ago
@lxsmnsyc πŸ€– I have open this thread since our last thread about the library where you tell me to move my build process to tsup
lxsmnsyc
lxsmnsycβ€’11mo ago
Honestly I saw the vid but had trouble seeing the vid because it's too wide. Discord is unfriendly with videos seems to be an HMR issue The tricky part here is that useContext might be referring to different RosettyContext which happens in HMR. is the context file in TSX type? (probably not a big deal when the library is bundled, interestingly)
Mirardes
MirardesOPβ€’11mo ago
this is why you can found the youtube video ^^ yes it is in tsx type. and my dist is like that : For me is not an HMR issue because If i stop the server and restart it, the error persist
lxsmnsyc
lxsmnsycβ€’11mo ago
interesting have you checked if this same issue happens in a basic Vite template? or does this only happen with Start
Mirardes
MirardesOPβ€’11mo ago
I have try to use the same source code with SolidJS Playground no issue do you want still want i try with basic vite template ?
lxsmnsyc
lxsmnsycβ€’11mo ago
Playground isn't ideal for testing these so yes Vite would be great
Mirardes
MirardesOPβ€’11mo ago
πŸ‘Œ Do you have any url where I can find the template ?
lxsmnsyc
lxsmnsycβ€’11mo ago
Vite has one
Mirardes
MirardesOPβ€’11mo ago
Context is found but I have a strange bug : "computations created outside a createRoot or render will never be disposed" Repro : https://github.com/qlaffont/test-vite
GitHub
GitHub - qlaffont/test-vite
Contribute to qlaffont/test-vite development by creating an account on GitHub.
Mirardes
MirardesOPβ€’11mo ago
So vite found And solid-start not !
lxsmnsyc
lxsmnsycβ€’11mo ago
well if you have this issue then it's still a bit similar, regardless
Mirardes
MirardesOPβ€’11mo ago
But this bug is not present everytime so I don't understand if you have time to make a video call to debug it and fix it, it will help me a lot πŸ™ πŸ‘‹
lxsmnsyc
lxsmnsycβ€’11mo ago
sorry everyone's kinda on a holiday break for now so please be patient until everyone gets back
Mirardes
MirardesOPβ€’11mo ago
Happy new year and sorry to insist but I'm available to fix this issue as soon as possible πŸ™‚ any update ? @lxsmnsyc πŸ€–
lxsmnsyc
lxsmnsycβ€’11mo ago
I haven't touched this yet. Have you made an issue thread?
Mirardes
MirardesOPβ€’11mo ago
Yes Should i ping someone to have the issue moving…? ? πŸ‘‹
lxsmnsyc
lxsmnsycβ€’11mo ago
question, have you tested this with the latest Start? (also not sure if this affects the problem but try loosing up the peerDependency version for SolidJS, maybe ^1.8?)
Mirardes
MirardesOPβ€’11mo ago
I will try πŸ‘Œ
Mirardes
MirardesOPβ€’11mo ago
@lxsmnsyc πŸ€– bug still present ! I give you the repro to help debug : https://github.com/qlaffont/test-cmp
GitHub
GitHub - qlaffont/test-cmp
Contribute to qlaffont/test-cmp development by creating an account on GitHub.
Mirardes
MirardesOPβ€’11mo ago
For information ryansolid answered on github but i have still an error… can you help me on my bug ? (see github) @lxsmnsyc πŸ€– any idea ?
lxsmnsyc
lxsmnsycβ€’11mo ago
haven't tried it myself yet sorry, just got something in my hands recently
Mirardes
MirardesOPβ€’11mo ago
Yes no problem ! @lxsmnsyc πŸ€– 1 month I have the issue without a solution ... I'm desperated .... Are you insterested in a bounty to solve this bug ? 50 $ ?
lxsmnsyc
lxsmnsycβ€’11mo ago
@Mirardes I'd recommend bumping the issue thread
Mirardes
MirardesOPβ€’11mo ago
I have ping ryan on the issue
lxsmnsyc
lxsmnsycβ€’11mo ago
@Mirardes here are some thoughts: - I've tested the repo you provided through StackBlitz however everything seemed to be outdated, so I cannot test these accurately. - The SyntaxError you had was already resolved in a later version of SolidStart (>0.4.4) - you don't need to install vite-plugin-solid - In rosetty-solid's 1.0.74, you have the entire solid-js bundled. I'd like to request updating the repo with the latest packages
Mirardes
MirardesOPβ€’11mo ago
πŸ‘ i keep you in touch today
lxsmnsyc
lxsmnsycβ€’11mo ago
@Mirardes so I forked the repo to try it out with the latest setup, here's some fixes you need to do: - entry-server should be fixed with the latest change on createHandler. You can check out the start repo's examples - dayjs and rosetty shall be included in optimizeDeps > include list. You also need to remove the exclude config.
No description
lxsmnsyc
lxsmnsycβ€’11mo ago
now if you see some Babel warnings, you can ignore that, it will be resolved in the next Start patch release
Mirardes
MirardesOPβ€’11mo ago
@lsx
No description
Mirardes
MirardesOPβ€’11mo ago
@lxsmnsyc πŸ€– I have updated test-cmp repro to update to last version of solidjs / solidstart/rosetty
lxsmnsyc
lxsmnsycβ€’11mo ago
but did you do the list of things I mentioned?
Mirardes
MirardesOPβ€’11mo ago
Yes I have done this
In rosetty-solid's 1.0.74, you have the entire solid-js bundled.
How can you indicate to tsup-solid to not do that ?
lxsmnsyc
lxsmnsycβ€’11mo ago
except you added rosetty-solid in include you've already fixed it in 0.75
Mirardes
MirardesOPβ€’11mo ago
okay I remove it and retry Now I'm in 0.81
lxsmnsyc
lxsmnsycβ€’11mo ago
like I mentioned you can also remove the vite-plugin-solid
Mirardes
MirardesOPβ€’11mo ago
same Yes it's an used package The repro has been updated with last changes and the bug persist
lxsmnsyc
lxsmnsycβ€’11mo ago
Okay at 0.81 you're back on the problem again
Mirardes
MirardesOPβ€’11mo ago
πŸ€”
lxsmnsyc
lxsmnsycβ€’11mo ago
Mirardes
MirardesOPβ€’11mo ago
why didn't change the configuration I didn't tsup config ?
lxsmnsyc
lxsmnsycβ€’11mo ago
Hmmm There are some things I would recommend changing
Mirardes
MirardesOPβ€’11mo ago
@lxsmnsyc πŸ€– I have push 0.82 without dep but error is still present
lxsmnsyc
lxsmnsycβ€’11mo ago
these might be a solution to the bundling issue
Mirardes
MirardesOPβ€’11mo ago
I just have change peerDependencies to dependencies and tsup don't bundle them
lxsmnsyc
lxsmnsycβ€’11mo ago
you still have them bundled: https://unpkg.com/browse/[email protected]/dist/ Okay hmmm, first is Mark these as peerDependencies like before: https://github.com/qlaffont/rosetty-solid/blob/master/package.json#L104-L108 BUT also add them to devDependencies
Mirardes
MirardesOPβ€’11mo ago
okay
lxsmnsyc
lxsmnsycβ€’11mo ago
also loosen up the version for dayjs maybe just ^1.11
Mirardes
MirardesOPβ€’11mo ago
πŸ†—
lxsmnsyc
lxsmnsycβ€’11mo ago
Now if there's still some issue I guess switching to rollup is the last idea
lxsmnsyc
lxsmnsycβ€’11mo ago
GitHub
devDependencies are bundled even if they are in peerDependencies as...
According to the readme: By default tsup bundles all import-ed modules but dependencies and peerDependencies in your package.json are always excluded. So, I would think that if peerDependencies are...
Mirardes
MirardesOPβ€’11mo ago
still present
No description
Mirardes
MirardesOPβ€’11mo ago
I will check
Mirardes
MirardesOPβ€’11mo ago
Now I have a strange reactivity issue i will try to investigate (change language does nothing but in test it's working 0-o)
Mirardes
MirardesOPβ€’11mo ago
reactivity issue fixed @lxsmnsyc πŸ€– but : - If I remove SSR: false - Vinxi crash : (see message.txt)
Mirardes
MirardesOPβ€’11mo ago
any idea ?
lxsmnsyc
lxsmnsycβ€’11mo ago
I'll check this later
Mirardes
MirardesOPβ€’11mo ago
Okay thanks ! I have updated the repro accordingly
lxsmnsyc
lxsmnsycβ€’11mo ago
cannot test it because you have rosetty-solid linked locally in your computer.
Mirardes
MirardesOPβ€’11mo ago
@lxsmnsyc πŸ€– πŸ€– you can pull any update ? πŸ™‚ any news ? πŸ™‚ @lxsmnsyc πŸ€–
lxsmnsyc
lxsmnsycβ€’11mo ago
Will probably look into this again in the weekend. i just have so many stuff on my hands
Mirardes
MirardesOPβ€’11mo ago
any update ? (btw I have seen your plugin for HMR, it seems promising :0 ) @lxsmnsyc πŸ€–
lxsmnsyc
lxsmnsycβ€’11mo ago
is it possible to drop dayjs? seems like it has been always problematic but whatever okay yeah dayjs is problematic even with ssr.noExternal, it cannot be solved it doesn't comply with modern bundling practices it doesn't even have an esm bundle if anything, I would recommend using date-fns oh wait it seems to ship with esm the only question is if you're using that
Mirardes
MirardesOPβ€’11mo ago
dayjs I use it for date formating I have removed date-fns to use dayjs because it is less heavy So what is your recommendation ? @lxsmnsyc πŸ€–
lxsmnsyc
lxsmnsycβ€’11mo ago
1. dayjs/esm 2. date-fns is actually much better in tree-shaking than dayjs but it's your choice
Mirardes
MirardesOPβ€’11mo ago
Okay I will refactor it, i keep you in touch @lxsmnsyc πŸ€– Since I have refactor the library with date-fns it seems to work !
lxsmnsyc
lxsmnsycβ€’11mo ago
nice
Mirardes
MirardesOPβ€’11mo ago
Thanks for your help ! I will try now to move my currently app to solid-start 2.0 ^^ @lxsmnsyc πŸ€– do you want the reward ?
lxsmnsyc
lxsmnsycβ€’11mo ago
not really
Mirardes
MirardesOPβ€’11mo ago
Okay thanks for your help I can close this support ticket and the github issue πŸ™‚
Want results from more Discord servers?
Add your server