[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
I can do a video call on Discord or Google meet if needed
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...
Yes it's from another module
and I have try to kill and restart server is not working too
for the video : https://youtu.be/fydxXDyOrCE
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
I will try
gl
nop
I have try and is not working
I have still the bug
can you show me the code?
library code :
app.tsx :
home.tsx :
mm that does look good
this why I open the issue ^^" I don't understand why it doesn't work
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
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...
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
okay π
done β
Much better, thanks π
@lxsmnsyc π€ I have open this thread since our last thread about the library where you tell me to move my build process to tsup
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)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
interesting
have you checked if this same issue happens in a basic Vite template? or does this only happen with Start
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 ?
Playground isn't ideal for testing these so yes Vite would be great
π Do you have any url where I can find the template ?
Vite has one
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-viteGitHub
GitHub - qlaffont/test-vite
Contribute to qlaffont/test-vite development by creating an account on GitHub.
So vite found
And solid-start not !
well if you have this issue then it's still a bit similar, regardless
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 π
π
sorry everyone's kinda on a holiday break for now so please be patient until everyone gets back
Happy new year and sorry to insist but I'm available to fix this issue as soon as possible π
any update ? @lxsmnsyc π€
I haven't touched this yet. Have you made an issue thread?
Yes
Should i ping someone to have the issue moving�
?
π
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
?)I will try π
@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.
For information ryansolid answered on github but i have still an errorβ¦
can you help me on my bug ? (see github)
@lxsmnsyc π€ any idea ?
haven't tried it myself yet sorry, just got something in my hands recently
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 $ ?
@Mirardes I'd recommend bumping the issue thread
I have ping ryan on the issue
@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
π i keep you in touch today
@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.now if you see some Babel warnings, you can ignore that, it will be resolved in the next Start patch release
@lsx
@lxsmnsyc π€
I have updated test-cmp repro to update to last version
of solidjs / solidstart/rosetty
but did you do the list of things I mentioned?
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 ?
except you added
rosetty-solid
in include
you've already fixed it in 0.75okay I remove it and retry
Now I'm in 0.81
like I mentioned you can also remove the vite-plugin-solid
same
Yes it's an used package
The repro has been updated with last changes and the bug persist
Okay at 0.81 you're back on the problem again
π€
You've bundled your dependencies
https://unpkg.com/browse/[email protected]/dist/index.js
why didn't change the configuration
I didn't
tsup config ?
Hmmm
There are some things I would recommend changing
@lxsmnsyc π€ I have push 0.82 without dep but error is still present
these might be a solution to the bundling issue
I just have change peerDependencies to dependencies and tsup don't bundle them
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
okay
also loosen up the version for
dayjs
maybe just ^1.11
π
Now if there's still some issue
I guess switching to rollup is the last idea
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...
still present
I will check
put external in cli seems to work https://github.com/qlaffont/rosetty-solid/commit/1f2f79985df0a249aeea3e9fe6d37894c1877083
Now I have a strange reactivity issue i will try to investigate (change language does nothing but in test it's working 0-o)
reactivity issue fixed @lxsmnsyc π€ but :
- If I remove SSR: false
- Vinxi crash : (see message.txt)
any idea ?
I'll check this later
Okay thanks !
I have updated the repro accordingly
cannot test it because you have rosetty-solid linked locally in your computer.
@lxsmnsyc π€ π€ you can pull
any update ? π
any news ?
π
@lxsmnsyc π€
Will probably look into this again in the weekend. i just have so many stuff on my hands
any update ? (btw I have seen your plugin for HMR, it seems promising :0 ) @lxsmnsyc π€
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
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 π€
1. dayjs/esm
2. date-fns is actually much better in tree-shaking than dayjs
but it's your choice
Okay I will refactor it, i keep you in touch
@lxsmnsyc π€ Since I have refactor the library with date-fns it seems to work !
nice
Thanks for your help ! I will try now to move my currently app to solid-start 2.0 ^^ @lxsmnsyc π€ do you want the reward ?
not really
Okay thanks for your help I can close this support ticket and the github issue π