-
Notifications
You must be signed in to change notification settings - Fork 22
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
Adapt Superflare to work with Wrangler 3 and Remix v2 (vite compiler) #66
Conversation
plus remove the @remix-run/dev patch
• reference: https://github.com/remix-run/remix/tree/main/templates/cloudflare-workers • also, update @superflare/remix peerDependencies • remove unused @remix-run/serve dependency • move @remix-run/server-runtime from devDependencies → dependencies • upgrade to latest @cloudflare/workers-types + make it consistent across workspaces
…and refactor it to be an async function, plus add a D1DatabaseAdaptor for exposing a compatible API for a SqlliteDB instance
@@ -88,14 +88,17 @@ export async function getManifest( | |||
return JSON.parse(manifest); | |||
} | |||
|
|||
function getNodeText(node: RenderableTreeNode) { | |||
function getNodeText(renderableNode: RenderableTreeNode) { | |||
if (typeof renderableNode === "string") return renderableNode; |
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.
@jplhomer heads up that this line is a change in behavior. in the previous version of this function, if typeof node === "string"
, the function returned an empty string, which i thought might be a bug, but if it is in fact desired, i will just lump this check in with the conditions in the next if
statement (on line 93) so that it also returns an empty string.
…plus take advantage of MetaFunction type’s generics
From the wrangler docs: “Only required if your wrangler.toml does not include a main key” Source: https://developers.cloudflare.com/workers/wrangler/commands/#dev
reproduces the changes suggested in remix-run/remix#9774
• the Env type is now generated by the wrangler types command and written to worker-configuration.d.ts • note however that it doesn’t include CF_PAGES or APP_KEY, which are both used in examples/remix-cms/functions/[[remix]].ts
removing the ;./index' import from superflare-remix/dev.ts makes it so that there is no possible issue with using static `import {…} from 'superflare'` in superflare-remix/index.ts, because that file won’t be executed outside of the vite bundle/execution context
@jplhomer i just pushed up a change to the this leaves the last known TODO item for me as the documentation, which i am happy to get started on once i have a better idea of what you think the plan should be for this PR. |
v2.12.1 includes remix-run/remix#9976, which changed the API contract of the fromNodeRequest util that we will depend on in superflareDevProxyVitePlugin
using entry.server.tsx meant that sessions weren’t committed for redirects, e.g. the default logout route action, which calls ``` auth.logout(); return redirect("/"); ``` this commit takes over the middleware portion of the cloudflareDevProxyVitePlugin logic and frames the request/response lifecycle with superflare.config initialization + getLoadContext before the request handler is invoked, and commit session cookie handling after
fixes UTF 8 text encoding / rendering, at least when running the docs app locally
@jplhomer tl;dr could you please trigger the the gory details: i refactored the new
but a couple of days ago, i noticed that the default other recent changes are adopting the new workers Static Assets feature, upgrading from |
not having a language identifier results in: TypeError: Cannot read properties of undefined (reading 'toLowerCase') at Highlight (/Users/foo/superflare/node_modules/.pnpm/[email protected][email protected]/node_modules/prism-react-renderer/src/components/highlight.ts:14:30)
fixes tests locally on my machine
@acusti Just ran again! Thanks for pushing on this - things are crazy for me right now but I anticipate being able to take a look at this and getting it merged ASAP and switch the project into |
also, allow it to be overwritten in case someone wants to make superflare work with a wrangler.toml
@jplhomer that’s great news, and thanks for triggering a new release! i will start in on updating the documentation. also, after using the new releases in my own project, i discovered that i wasn’t providing |
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 phenomenal work. Can't believe you kept up with this. Thank you!
// Import singleton-dependent modules via viteDevServer to get | ||
// the same instance of the Config singleton class as in app code. | ||
const superflare = await server.ssrLoadModule("superflare"); |
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.
Wow, super clever way to share between module graphs.
@jplhomer thanks so much for the kind words! but oh dear, it seems i broke the docs site; let me know if you want any help debugging it. i did have to change a number of things to get it to work with the upgraded stack. shall i create a new branch to start on documentation updates? there are some subtle changes to document that should be trivial for new superflare consumers but should probably be called out for existing folks looking to upgrade in an upgrade guide or the like. things like with the latest |
@acusti no worries! The only errors I can get from the server are: Which seems to correspond to a Cloudflare 1003, something about direct IP references which doesn't add up 🤔 It also fails locally when I I gave it about 30 minutes but can't seem to find any leads - since it's fresher in your mind, maybe you can uncover what might be happening differently in dev vs prod/local build? |
Also yes, updating the docs would be great. We haven't added a changeset yet, so there's not a major hurry to get them up. |
Update: Found the issue! For some reason, deploying via Cloudflare integration wasn't setting |
that’s odd, i haven’t needed to set that manually with other cloudflare workers remix projects. i figured the most likely thing to break with the docs site was the search integration, but that actually seems to work fine! except for a CSS thing that seems to be the result of the site not having the necessary styles for the |
This PR:
migrate
command’s--db
option is now the name of the DB binding, not a path to the actual local DB filedev
command now runsremix vite:dev
for the main server +wrangler dev
in parallel to enable Durable Objectsbetter-sqlite3
in favor ofwrangler
’sgetPlatformProxy
API./d1js/*
vendored files@superflare/remix
plugin, available at@superflare/remix/dev
, which providessuperflareDevProxyVitePlugin
, a drop-in replacement for remix’scloudflareDevProxyVitePlugin
that supports superflare and its automatic session handling and auth featurespnpm
turbo
implements #62