Skip to content

Commit

Permalink
[edge] upgrade edge runtime to allow reading EdgeRuntime global dynam…
Browse files Browse the repository at this point in the history
…ically

while allowing to override the provider with an env var, to enable
  customers/libraries to have custom implementations based on different
  edge runtime providers.
  • Loading branch information
Schniz committed Jul 12, 2022
1 parent c2b40d0 commit 7f56e59
Show file tree
Hide file tree
Showing 8 changed files with 378 additions and 319 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -55,7 +55,7 @@
"@babel/plugin-proposal-object-rest-spread": "7.14.7",
"@babel/preset-flow": "7.14.5",
"@babel/preset-react": "7.14.5",
"@edge-runtime/jest-environment": "1.1.0-beta.10",
"@edge-runtime/jest-environment": "1.1.0-beta.11",
"@fullhuman/postcss-purgecss": "1.3.0",
"@mdx-js/loader": "0.18.0",
"@next/bundle-analyzer": "workspace:*",
Expand Down
9 changes: 8 additions & 1 deletion packages/next/build/webpack-config.ts
Expand Up @@ -1497,7 +1497,14 @@ export default async function getBaseWebpackConfig(
...(compilerType !== 'edge-server'
? {}
: {
EdgeRuntime: JSON.stringify('edge-runtime'),
EdgeRuntime: JSON.stringify(
/**
* Cloud providers can set this environment variable to allow users
* and library authors to have different implementations based on
* the runtime they are running with, if it's not using `edge-runtime`
*/
process.env.NEXT_EDGE_RUNTIME_PROVIDER || 'edge-runtime'
),
}),
// TODO: enforce `NODE_ENV` on `process.env`, and add a test:
'process.env.NODE_ENV': JSON.stringify(
Expand Down

0 comments on commit 7f56e59

Please sign in to comment.