Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Target edge runtime conditionally #39075

Closed
benmerckx opened this issue Jul 27, 2022 · 0 comments
Closed

Target edge runtime conditionally #39075

benmerckx opened this issue Jul 27, 2022 · 0 comments

Comments

@benmerckx
Copy link
Contributor

Describe the feature you'd like to request

Api routes configured with {runtime: 'experimental-edge'} target "browser" exports during bundling.
Libraries that use conditional exports might want to export different code for server and client. Currently it seems there's no way to target the edge api routes specifically. For users this can result in build errors such as Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime for unwanted browser specific code.

Cloudflare workers via wrangler have the option of targetting the "worker" export.

Describe the solution you'd like

Provide a target which enables libraries to conditionally provide exports for the edge runtime. Potentially re-use the "worker" condition or a more fitting and unique condition.

{
  "exports": {
    // Target edge runtime
    "edge": "./server.js",
    // Actual browsers
    "browser": "./client.js",
    // Everything else
    "default": "./server.js"
  }
}

Describe alternatives you've considered

Don't see other options.

@vercel vercel locked and limited conversation to collaborators Jul 28, 2022
@balazsorban44 balazsorban44 converted this issue into discussion #39094 Jul 28, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant