Skip to content
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

chore: netlify edge experiment #54

Closed
2 of 11 tasks
hi-ogawa opened this issue Apr 22, 2022 · 3 comments
Closed
2 of 11 tasks

chore: netlify edge experiment #54

hi-ogawa opened this issue Apr 22, 2022 · 3 comments

Comments

@hi-ogawa
Copy link
Owner

hi-ogawa commented Apr 22, 2022

todo

  • reverse engineering netlify-cli
  • understand runtime
  • understand build
    • use cli
    • use "internal" manifest
    • use edge-bundler
    • use own script
  • remix integration
    • use template (and remix experimental branch)
    • use own patch
    • server config
      • ServerBuildTarget, ServerModuleFormat, ServerPlatform
    • dependencies resolution
      • need to emit "import map"? (or does "edge bundler" do it?)
      • switch "implementations" from "remix-node" to "remix-deno"
  • routing priority (cf. context.next https://docs.netlify.com/netlify-labs/experimental-features/edge-functions/api/#netlify-specific-context-object)
    • static assets
    • routes in minifest.json
    • redirect in netlify.toml
    • delegate by returning undefined
  • cpu limit
  • setup deno development
    • deno compatible tsc
    • editor
@hi-ogawa
Copy link
Owner Author

reverse engineering

based on hello world app https://docs.netlify.com/netlify-labs/experimental-features/edge-functions/get-started/

netlify dev

$ netlify --version
netlify-cli/10.1.0 linux-x64 node-v14.19.1
$ pgrep -a -f netlify
1369473 netlify dev
1369475 node /home/hiroshi/.volta/tools/image/packages/netlify-cli/bin/netlify dev
1369720 /home/hiroshi/.config/netlify/deno-cli/deno run --allow-all --unstable --import-map=data:application/json;base64,eyJpbXBvcnRzIjp7Im5ldGxpZnk6ZWRnZSI6Imh0dHBzOi8vZWRnZS1ib290c3RyYXAubmV0bGlmeS5hcHAvdjEvaW5kZXgudHMifX0= --quiet /tmp/tmp-1369475-VvX8lfTGcyV5/dev.js 42045
  • .netlify/edge-functions-import-map.json
{"imports":{"netlify:edge":"https://edge-bootstrap.netlify.app/v1/index.ts"}}
$ curl https://edge-bootstrap.netlify.app/v1/index.ts
export type { Context } from "../bootstrap/context.ts";
export type { EdgeFunction } from "../bootstrap/edge_function.ts";
  • /tmp/tmp-1369475-VvX8lfTGcyV5/dev.js
import { boot } from "https://625d32be1b90870009edfc99--edge-bootstrap.netlify.app/bootstrap/index-combined.ts";

const functions = {};


  try {
    const { default: func } = await import("file:///home/hiroshi/code/personal/ytsub-v3/netlify-edge/netlify/edge-functions/hello.js");

    if (typeof func === "function") {
      functions["hello"] = func;
    } else {
      console.log("\u001b[91m◈\u001b[39m \u001b[31mFailed\u001b[39m to load Edge Function \u001b[33mhello\u001b[39m. The file does not seem to have a function as the default export.");
    }
  } catch (error) {
    console.log("\u001b[91m◈\u001b[39m \u001b[31mFailed\u001b[39m to run Edge Function \u001b[33mhello\u001b[39m:");
    console.error(error);
  }
  

boot(functions);

@hi-ogawa
Copy link
Owner Author

netlify build

$ netlify build
...
────────────────────────────────────────────────────────────────
  1. Edge Functions bundling                                    
────────────────────────────────────────────────────────────────

Packaging Edge Functions from netlify/edge-functions directory:
 - hello

(Edge Functions bundling completed in 1.9s)

────────────────────────────────────────────────────────────────
  Netlify Build Complete                                        
────────────────────────────────────────────────────────────────

(Netlify Build completed in 2s)

  • .netlify/edge-functions-dist/manifest.json
{
  "bundles": [
    {
      "asset": "839869060036ab59a60b1d7e0eac1648ee117f19baf968acd3d3f6e35fb5f280.js",
      "format": "js"
    }
  ],
  "routes": [
    {
      "function": "hello",
      "pattern": "^/test$"
    }
  ],
  "bundler_version": "0.12.0"
}
  • .netlify/edge-functions-dist/839869060036ab59a60b1d7e0eac1648ee117f19baf968acd3d3f6e35fb5f280.js
...
function __default() {
    return new Response("Hey");
}
const functions = {
    "hello": __default
};
serve1(functions);

@hi-ogawa
Copy link
Owner Author

hi-ogawa commented Apr 29, 2022

As investigated in

the ecosystem doesn't look ready to run full web server in deno/netlify-edge.
Thus closing.

EDIT:

one more blocker to use netlify-edge (deno) and planetscale mysql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant