-
Notifications
You must be signed in to change notification settings - Fork 401
refactor: adopt @tanstack/server-functions-plugin #1715
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
Conversation
🦋 Changeset detectedLatest commit: 9dd8425 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 💥 An error occurred when fetching the changed packages and changesets in this PR |
More templates
commit: |
|
This is insanely cool. |
|
@brenelz , to make the CI green for the docs build, it's just a matter of adjusting the rollup config to avoid the AsyncLocalStorage error for the client bundle. You can move
Or have both for now like below: // docs/app.config.ts
import { defineConfig } from "@solidjs/start/config";
import tailwindcss from "tailwindcss";
import { config } from "vinxi/plugins/config";
export default defineConfig({
// experimental: { islands: true },
server: {
preset: "cloudflare_module",
alias: {
"_mime": "mime/index.js"
},
rollupConfig: {
external: ["__STATIC_CONTENT_MANIFEST", "node:async_hooks"]
}
},
vite: {
build: {
rollupOptions: {
external: ["__STATIC_CONTENT_MANIFEST", "node:async_hooks"]
}
},
plugins: [
config("tailwind", {
css: {
postcss: {
plugins: [tailwindcss]
}
}
} as any)
]
}
}); |
|
That's awesome!! Meanwhile I'm working on improving the test story around here so we can merge this more confidently. |
|
Since we don't have a test suite, the manual testing I've done here is to install the pkg.pr.new, and add the below to the Counter of the basic example, and set function useServer() {
"use server";
console.log("Counter Server Function", isServer) // <- returns True on server
}
export default function Counter() {
console.log("Counter Init", isServer) // <- returns False in client
useServer()
const [count, setCount] = createSignal(0);
return (
<button class="increment" onClick={() => setCount(count() + 1)} type="button">
Clicks: {count()}
</button>
);
}And it appear to work as expected both in |
|
I am wondering how easy it would be to test this out in one of my projects via npm link 🙈, or is there a chance we could publish this on some special name/tag to give it a try? |
|
@katywings , there is the pkg.pr.new link here - can you use that? |
|
@birkskyum I was just going to say the same thing. I haven't actually used it before but seems cool |
|
Just merged #1719 |
birkskyum
left a comment
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.
E2E test passing. LGTM
.changeset/violet-steaks-mate.md
Outdated
| @@ -0,0 +1,5 @@ | |||
| --- | |||
| "@solidjs/start": minor | |||
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.
I was kinda expecting this one to be a patch since it's not changing any API nor is it adding a new feature.
wdyt?
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.
I recommended the minor but I'm good with a patch too.
|
Testing this out right now, so far it doesn't work at all for me, most likely because it seems to have a completely different approach to decide which dependencies to externalize. Still figuring it out the details though. You gonna get a second analysis soon 😅 Edit: Yeah so it looks like this completely fails to externalize server libraries in the client bundling, resulting in errors during the build. Plus countless warnings for every node built-in module ( |
|
Here is a very basic reproduction of the missing externalization, this works in |
|
I wonder if this is a problem in this PR or a general thing with the Tanstack Server Functions plugin 🤔 - afaik @tannerlinsley mentioned that the Tanstack plugin actually should externalize more heavily than Vinxi and not less - so I assume this must be a problem on our side 🤔. |
|
There are externalization tests added to the test suite, so this PR should be rebased, and pass those. |
|
@katywings , next time you have a chance to check it, let us know if it fares better for you now with the externalization fixed. |
✅ Deploy Preview for solid-start-landing-page ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
|
Okay I went through my project with this branch and successfully tested DEV & PROD. Could not find a single issue 🥳👌. |
|
@atilafassina , I tried to follow the guide at Conventional Commit, but the new Contributing Compliance doesn't pass... can you see what's going wrong here? Does it lack some workflow permissions? |
|
I'm sure you guys are already aware but this is a breaking change when declaring server functions from within components returning the error "Server Functions cannot be nested in other blocks or functions". Might want to mention this in the release notes? |
Why are you declaring a server function from within a component scope? Ideally, you are writing server function code independently from component rendering so keep your code easier to maintain and test. |
|
This also appears to have broken support for async generators as server functions #1886 |
|
@theturtle32 can you add a test for that in our server function test suite? |
Resolves #1735
Replace @vinxi/server-functions with @tanstack/server-functions-plugin