DEV Community

Discussion on: How to Deploy Angular Universal to Vercel

Collapse
 
mickl profile image
Mick

Thanks a lot for the article! Does this also work with Vercel Edge Runtime, which is just a subset of the Node API?

Collapse
 
jdgamble555 profile image
Jonathan Gamble • Edited

I have not tested it, but there is no reason it shouldn't work on the edge, as it is just JavaScript. You can try adding this to the index.js:

export const config = {
  runtime: 'edge',
};
Enter fullscreen mode Exit fullscreen mode

vercel.com/docs/edge-network/caching

Let me know if you figure it out!

J

Collapse
 
mickl profile image
Mick • Edited

It would require to also set the response header as written in the docs BUT I tried it out and it doesnt work:

Error: The Edge Function "api/index" is referencing unsupported modules:

  • dist/server/main.js: crypto, fs, http, https, net, os, path, querystring, stream, string_decoder, timers, tty, url, zlib, node:fs, node:path

There is an open feature request to remove the dependencies of Angular Universal (e.g. remove Express) so it can work on workers that dont support full Node API like Vercel Edge Functions or Cloudflare Pages BUT it will probably be closed if it doesnt get 20 upvotes in the next week:

github.com/angular/angular-cli/iss...

Thread Thread
 
jdgamble555 profile image
Jonathan Gamble • Edited

Yup, I just tried it and go the same error. Normally in Node.js, you could use the "browser" key in package.json to ignore certain imports, but the edge uses Deno. Until this gets resolved (I upvoted BTW), I don't see Angular Universal being possible on Vercel or any Edge. However, AnalogJS may be a different thing.

Thread Thread
 
mickl profile image
Mick

Did you find anything out in the meantime?

Thread Thread
 
mickl profile image
Mick

I got it working thangs to @trongthuong96 ! I posted it on top level

Thread Thread
 
jdgamble555 profile image
Jonathan Gamble

Ok, great, could you post the working config?

Thread Thread
 
mickl profile image
Mick

Posted it on top level