@antfu.me is there an officially recommended way to support dedent-like functionality in shiki.style?
hoping to add built-in dedent for code blocks without overriding shiki
Posts by Brandon McConnell
Thanks! I emailed you
@adelfaure.bsky.social can i hire u for a new ascii project??
This is backward. How is canceling a debate promoting free speech?
Promoting free speech would mean promoting open debate. This is exactly the opposite.
where were you in the last presidential term where the left continually celebrated politicians, doctors, and reporters alike getting silenced and canceled?
if free speech died, it happened long before now
@t0nyyates.bsky.social can i be added to your list? would love for people to be able to find me on x that way
I'm happy to open an issue for this as well, except there's a fair chance I'm just doing something wrong. 😅
I really appreciate you maintaining such a great plugin. I know a lot of work goes into that. I'm happy to compensate you for any time spent on this if you like.
@jamie.build Hi Jamie, I'm updating an app to Tailwind 4 and noticing with some of my dialog exit animations that the dialog briefly reappears after animating out. This only happens intermittently.
Any chance you'd be willing to take a look at this with me?
Yeah, that's how I've been doing it so far, but targeting specific elements would be pretty neat
@miriam.codes I was curious if you knew of any spec work being done on CSS nesting support inside of @keyframes, so we can do things like this:
@keyframes {
0% {
width: 0px;
> span {
opacity: 0%;
}
}
100% {
width: 50px;
> span {
opacity: 100%;
}
}
}
Yes, I actually made that switch right after sending you that message haha
Still, how would you avoid useEffect here, if you would? I'm waiting until the session is ready to know if the user is logged in or not.
@chance.dev I'm curious how you'd approach this pattern if you were trying to strip out this useEffect.
gist.github.com/brandonmccon...
If a user is logged in, the root should redirect them to `/dashboard`. Otherwise, it redirects them to `/home`.
Yes, a lot of this boils down to the desire for nested components.
I generally advocate for separating concerns and moving complex logic into new components, but I often have to do this for a simple conditional and nested pieces of composition simply to hold state.
I’d love nesting!
Thanks again!
BUILD PLUGIN (4/4)
This approach seems to have the fewest gotchas and simplifies the syntax, making it feel more native.
My biggest hesitation with this approach is that I believe in “Just JavaScript,” and while this would be JS, it feels more magical since it happens outside of React.
BUILD PLUGIN (3/4)
Immediately, I could replace that <$> wrapper with a familiar-feeling string directive, like 'use render' (or similar).
Any block using that directive would immediately be broken out into a separate component.
BUILD PLUGIN (2/4)
Something great about this approach is that as long as the pre-compilation is robust and works effectively, I could simplify the syntax even further.
Right away, we remove the need to use a callback; we can simply match any content wrapped in syntax like <$> and expand that.
BUILD PLUGIN (1/4)
e.g. Vite/Webpack/etc.
In this approach, I would pre-compile any uses of this <$> syntax and *actually* break its usage out into separate functional components within the same file.
Natural hoisting makes this even easier because we don’t have to worry about order.
PROXIES
With the proxies approach, instead of passing the hooks themselves to the callback, I would pass a proxy that watches how the hook is used and somehow carries that usage back to the component instance itself, outside the callback.
I’m not sure how difficult (or possible) that is.
I think for v1 to actually make sense, I clearly need to change something here to support or align with React’s Rules of Hooks, which most of these appear to break.
I have two defining ideas—
– proxies
– build plugin
Because my implementation goes a bit deeper than those others, I can do some things to optimize usage within the package, like auto-memoization, striving to follow the same patterns as the compiler.
There are countless solutions and packages out there trying to solve this same problem, so it’s definitely a pain point felt in the framework that I think the core team could tackle in an equally or more elegantly.
I’m not as knowledgeable as you in the compiler’s inner workings.
My primary objective here was to tackle this problem with an approach that ensures the hooks are initialized and used in the same render cycle, which they appear to be, but I can see how it might still violate the rules.
I agree that sticking to what is recommended as best practice should be promoted here.
Thinking through my implementation, it does feel like a pattern that React Compiler could officially support with the proper affordances.
Thanks, Dan! I really appreciate your thoughtful feedback here.
Do you happen to have a concrete example you could share that I could test around for where this would likely break?
My implementation is different than the usual `children()` approach, but I’m sure it hits the same limitations.
And if you would rather not discuss it on X, I’m happy to continue that conversation right here in this thread on Bluesky
TY 🙏🏼
Here is the most relevant message from Joe Savona over there:
x.com/en_js/status...
The conversation has progressed past that point into a few tangential conversations and DMs, but I think addressing and discussing the concern there would be fitting, both for my package and that article I shared^
There’s one engineer from Meta, who chimed in, convinced that this violates Rules of Hooks, but based on my understanding of the documentation, I don’t think it should.
This article’s implantation is nearly identical and makes the same non-violation claim:
unsplash.com/blog/calling...
@danabra.mov the conversation is happening on X, but I was hoping you could clear something up for me?
We’re having a discussion about Rules of Hooks, specifically using hooks inside of a render prop so the hooks are contained in the same render cycle, not passed between components
I can't share the full codebase yet (at least, without probably a BAA), but I can share the components that are failing to render in case that clearly points us toward the issue
DM'ing you
For context, I am not using `$effect` anywhere on in my app.
Turning off my excluded directories when searching my codebase, the only places `$effect` appears are in root.svelte, the file svelte generates at `[ROOT]/.svelte-kit/generated/root.svelte`