-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
refactor(core): move actions inside core #13262
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 126ec8a The changes in this PR will be included in the next version bump. 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 |
fd88009
to
e285d9e
Compare
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.
Although this is a refactor, maybe should we have a changeset to be safe in case people face issues
b9ef104
to
bd84a49
Compare
CodSpeed Performance ReportMerging #13262 will not alter performanceComparing Summary
|
Turns out it is not as simple as that, it requires a full refactor of the architecture. I'll see to that |
64e2187
to
c2042d2
Compare
I checked the e2e test that failed, and the issue isn't much clear. The db package fails to run the seed file, however it doesn't happen when I run the dev server for the fixture. Also, when running the fixture locally, the likes action (the action) works as expected, but the query doesn't return the expected data. This doesn't happen for the comments action. As for now, I commented on them. |
f47d495
to
0cf031e
Compare
@@ -17,7 +18,7 @@ export function PostComment({ | |||
<form | |||
method="POST" | |||
data-testid="client" | |||
action={actions.blog.comment} | |||
action={actions.blog.comment.toString()} |
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.
Just noting that if this is required, it's a user-side bug. Understand if this is just a debug in-progress
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.
That's intentional. For some reason, the toString()
isn't called anymore. Has something changed in the TSX compiler? I bet that if we use a template literal, the toString()
function is called, however... like this, toString()
isn't automatically called, so I am afraid the transformation is doing something fishy
@@ -192,6 +194,15 @@ export class RenderContext { | |||
} | |||
let response: Response; | |||
|
|||
if (!ctx.isPrerendered) { |
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.
Nice, this looks like the fix we needed.
And I'll add some context from @JacobNWolf 's issue to make sure we test it: Actions were being bundled into edge middleware, when they should only be bundled into your server runtime. It looks like this moves the functionality into the server runtime, but I wanna make sure we make a test project (ideally a fixture) that confirms actions aren't bundled into middleware by accident still.
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.
Amazing. Thank you guys.
astro
@astrojs/cloudflare
@astrojs/netlify
@astrojs/node
@astrojs/vercel
commit: |
0cf031e
to
126ec8a
Compare
@JacobNWolf, can you please use the latest preview release and see if that fixes your issue? |
Changes
This PR moves actions inside core. Actions are now part of the pipeline, and they are loaded in the same way the middleware is loaded:
ModuleLoader
in developmentmoduleId
when build for SSRThe internal virtual module of the actions is in charge of emitting a stub of the actions in case the user doesn't have any.
The injections of the actions during development is done inside the
route.ts
. I decided to do it there because I wanted to assume that the actions must be already loaded when creating theRenderContext
, which is our agnostic runtime renderer. Because fo that, thePipeline
class also exposes a method calledsetActions
.Testing
Current tests and functionality should stay the same. The Actions middleware was already set to be the last one, which is the same as we just moved inside the
lastNext
callback we have in core.Docs
N/A