-
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
feat: add support for Netlify Edge Functions #2866
feat: add support for Netlify Edge Functions #2866
Conversation
fix: add import map fix: declare globals fix: add types to server declaration fix: tidying up chore: remove deprecated magic imports refactor: change Netlify template to support both runtimes refactor: move edge functions template into examples feat: add edge manifest
feat: add import map fix: resolve path for runtime
config.serverBuildTarget === "deno" || | ||
config.serverBuildTarget === "netlify-edge" |
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.
This could be simplified to
["deno", "netlify-edge"].includes(config.serverBuildTarget]
SessionData, | ||
SessionIdStorageStrategy, | ||
SessionStorage, | ||
} from "https://esm.sh/@remix-run/server-runtime@1.4.1"; |
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.
Should we keep this or change it to something like we have in the remix-deno
package?
} from "https://esm.sh/@remix-run/server-runtime@1.4.1"; | |
} from "https://esm.sh/@remix-run/server-runtime?pin=v77"; |
isSession, | ||
json, | ||
redirect, | ||
} from "https://esm.sh/@remix-run/server-runtime@1.4.1"; |
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.
} from "https://esm.sh/@remix-run/server-runtime@1.4.1"; | |
} from "https://esm.sh/@remix-run/server-runtime?pin=v77"; |
import type { ServerBuild } from "https://esm.sh/@remix-run/server-runtime@1.3.5?pin=v77"; | ||
import { createRequestHandler as createRemixRequestHandler } from "https://esm.sh/@remix-run/server-runtime@1.3.5?pin=v77"; |
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.
These are referencing older versions.
We should at least update to latest version
import type { ServerBuild } from "https://esm.sh/@remix-run/server-runtime@1.3.5?pin=v77"; | |
import { createRequestHandler as createRemixRequestHandler } from "https://esm.sh/@remix-run/server-runtime@1.3.5?pin=v77"; | |
import type { ServerBuild } from "https://esm.sh/@remix-run/server-runtime@1.4.1?pin=v77"; | |
import { createRequestHandler as createRemixRequestHandler } from "https://esm.sh/@remix-run/server-runtime@1.4.1?pin=v77"; |
Or remove version number all together
import type { ServerBuild } from "https://esm.sh/@remix-run/server-runtime@1.3.5?pin=v77"; | |
import { createRequestHandler as createRemixRequestHandler } from "https://esm.sh/@remix-run/server-runtime@1.3.5?pin=v77"; | |
import type { ServerBuild } from "https://esm.sh/@remix-run/server-runtime?pin=v77"; | |
import { createRequestHandler as createRemixRequestHandler } from "https://esm.sh/@remix-run/server-runtime?pin=v77"; |
@@ -0,0 +1,917 @@ | |||
{ |
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.
We should probably delete this file, as none of the templates
have one
"index.js" | ||
], | ||
"peerDependencies": { | ||
"@remix-run/server-runtime": "*" |
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.
This should probably go into dependencies
I think? 🤔
@@ -1,4 +1,4 @@ | |||
import type { EntryContext } from "@remix-run/node"; | |||
import type { EntryContext } from "@remix-run/server-runtime"; |
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 think this should only be the case when choosing for "Netlify Edge Functions"
, so this file should be overridden by remix.init
? 🤔
@@ -1,4 +1,4 @@ | |||
import type { MetaFunction } from "@remix-run/node"; | |||
import type { MetaFunction } from "@remix-run/server-runtime"; |
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 think this should only be the case when choosing for "Netlify Edge Functions"
, so this file should be overridden by remix.init
? 🤔
@@ -10,7 +10,7 @@ | |||
"start": "cross-env NODE_ENV=production netlify dev" | |||
}, | |||
"dependencies": { | |||
"@netlify/functions": "^0.10.0", | |||
"@netlify/functions": "latest", | |||
"@remix-run/netlify": "*", |
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.
We should probably replace this with @remix-run/netlify-edge
when choosing for "Netlify Edge Functions"
in remix.init
@@ -10,7 +10,7 @@ | |||
"start": "cross-env NODE_ENV=production netlify dev" | |||
}, | |||
"dependencies": { | |||
"@netlify/functions": "^0.10.0", | |||
"@netlify/functions": "latest", | |||
"@remix-run/netlify": "*", | |||
"@remix-run/node": "*", |
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.
We should probably replace this with @remix-run/server-runtime
when choosing for "Netlify Edge Functions"
in remix.init
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
This PR adds a Remix adapter for the beta release of Netlify Edge Functions. It is implemented as a package
@remix-run/netlify-edge
and uses the Deno runtime with some small but important changes. Most significantly, this adapter bundles all of the generated server code (except the adapter itself), and by default expects that user code will use regular node-style imports rather than URL imports as expected by Deno. The generated server code is Deno-compatible, and can be used directly as a Netlify Edge Function. It is emitted into.netlify/edge-functions/server.js
. It also generates a manifest in.netlify/edge-functions/manifest.json
. The Deno runtime code is currently inlined inside the package, because it isn't published anywhere at present.This PR also adds some tooling to make life easier when working on Deno and Node code in the same repo. This includes defining
deno.enablePaths
in the VS Code settings, so that it only runs on Deno code, and adding an import map so that Deno code that uses bare imports (such as the imports ofbuild
) works as expected.It extends the default Netlify template, adding a
remix.init
script that asks if the user want to use Edge Functions, and setting the project up accordingly.Closes: #