-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: allow conditional rendering when RenderScript
is enabled
#1057
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 3f1f082 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure of the lint CI fail, but the fix here looks great to me. Thanks!
About docs, I think we need to update this part: https://docs.astro.build/en/guides/client-side-scripts/#opting-out-of-processing
Astro will not process your script tags in some situations. In particular, adding type="module" or any attribute other than src to a <script> tag will cause Astro to treat the tag as if it had an is:inline directive.
The same will be true when the script is written in a JSX expression.
Good call, I'll update docs. The lint action fail is happening in main so it's unrelated. |
No problem with the docs PR making this change to be accurate! BUT to check:
|
That's a great question! It's possible some folks are probably still relying on the old script behavior, and their sites will behave differently after upgrading if we keep this as a patch release. To make the transition smoother we could go with a minor release instead, then for the next Astro minor, we can make the "breaking" change to the script behavior, and add a note to the changelog so people are aware of the change.
I think adding a note to the upgrade guide is a good idea! Was actually looking for a place to add it, so this is perfect.
That's a good point! This is technically a fix as since v5, it was intended that processed scripts could be rendered conditionally. I'll update the changeset to reflect that. Thanks for the feedback! 🙌 |
Hmm I didn't expect this to be possibly as big of a breaking change, but I think it might still be worth fixing this so we get a consistent conditional rendering behaviour like shown in the issue. I'd still consider this a bug fix, but of the potentially breaking kind. And if it turns out to be quite breaking we could consider reverting the behaviour and queue this for Astro 6. My bad for no thinking this through before 😅 |
Agreed! I think it's worth fixing this bug now, and we can mention this in the minor version blog post if we push this as a minor release. That way, those upgrading to next minor can be aware of the change and update their scripts accordingly, and current users are shielded (assuming most folks pin on minor version and that they read release notes 😅). I feel like this kinda breaks semver though, but I think it's the most happy path to fix this bug if we wanna push this before Astro 6. And yeah, we can always revert if it becomes too big of a problem. Will lookout in support to gauge it. |
I'm not sure how we can only limit this to the Astro minor. We have |
Good catch! I wrongly assumed that we pinned the compiler with |
Yes, I think that's fine (if a little sneaky? 😅 ) Like I suggested, I think making sure this breaking changes is reflected in the upgrade guide allows this to be considered a fix of a thing we intended to break, just didn't properly break for v5! We should use the changeset to be clear that this is fixing an issue with a previously breaking change to get it to work as intended, so you might actually see the breaking change NOW -- I think that's our story, and we're sticking to it! (And, avoiding the need to wait until v6) |
Co-authored-by: Sarah Rainsberger <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving for docs, and the Docs PR is good to merge when this is released, too!
Awesome, thanks for your reviews and suggestions! |
Changes
Conditionally rendered processed scripts were inlined like normal scripts. This made sense before
renderScript
was introduced as processed scripts (and styles) couldn't be conditionally rendered. Now that processed scripts can be conditionally rendered, we shouldn't inline them like normal scripts.This PR adds the ability to conditionally render processed scripts
Testing
RenderScript
is enabled or notDocs