2
2
import { join , relative } from 'path'
3
3
4
4
import type { NetlifyPlugin } from '@netlify/build'
5
- import { greenBright , bold , redBright } from 'chalk'
5
+ import { bold , redBright } from 'chalk'
6
6
import { existsSync , readFileSync } from 'fs-extra'
7
7
import { outdent } from 'outdent'
8
8
@@ -16,12 +16,7 @@ import {
16
16
generateCustomHeaders ,
17
17
} from './helpers/config'
18
18
import { onPreDev } from './helpers/dev'
19
- import {
20
- enableEdgeInNextConfig ,
21
- writeEdgeFunctions ,
22
- loadMiddlewareManifest ,
23
- cleanupEdgeFunctions ,
24
- } from './helpers/edge'
19
+ import { writeEdgeFunctions , loadMiddlewareManifest , cleanupEdgeFunctions } from './helpers/edge'
25
20
import { moveStaticPages , movePublicFiles , patchNextFiles } from './helpers/files'
26
21
import { generateFunctions , setupImageFunction , generatePagesResolver } from './helpers/functions'
27
22
import { generateRedirects , generateStaticRedirects } from './helpers/redirects'
@@ -88,30 +83,30 @@ const plugin: NetlifyPlugin = {
88
83
89
84
const middlewareManifest = await loadMiddlewareManifest ( netlifyConfig )
90
85
91
- let usingEdge = false
92
-
93
- if ( middlewareManifest ?. functions && Object . keys ( middlewareManifest . functions ) . length !== 0 ) {
94
- usingEdge = true
95
- if ( process . env . NEXT_DISABLE_NETLIFY_EDGE ) {
96
- failBuild ( outdent `
97
- You are using Next.js experimental edge runtime, but have set NEXT_DISABLE_NETLIFY_EDGE to true. This is not supported.
98
- To use edge runtime, remove the env var ${ bold `NEXT_DISABLE_NETLIFY_EDGE` } .
99
- ` )
100
- }
86
+ if (
87
+ middlewareManifest ?. functions &&
88
+ Object . keys ( middlewareManifest . functions ) . length !== 0 &&
89
+ process . env . NEXT_DISABLE_NETLIFY_EDGE
90
+ ) {
91
+ failBuild ( outdent `
92
+ You are using Next.js experimental edge runtime, but have set NEXT_DISABLE_NETLIFY_EDGE to true. This is not supported.
93
+ To use edge runtime, remove the env var ${ bold `NEXT_DISABLE_NETLIFY_EDGE` } .
94
+ ` )
101
95
}
102
96
103
- if ( middlewareManifest ?. middleware && Object . keys ( middlewareManifest . middleware ) . length !== 0 ) {
104
- usingEdge = true
105
- if ( process . env . NEXT_DISABLE_NETLIFY_EDGE ) {
106
- console . log (
107
- redBright ( outdent `
108
- You are using Next.js Middleware without Netlify Edge Functions.
109
- This is deprecated because it negatively affects performance and will disable ISR and static rendering.
110
- It also disables advanced middleware features from @netlify/next
111
- To get the best performance and use Netlify Edge Functions, remove the env var ${ bold `NEXT_DISABLE_NETLIFY_EDGE` } .
112
- ` ) ,
113
- )
114
- }
97
+ if (
98
+ middlewareManifest ?. middleware &&
99
+ Object . keys ( middlewareManifest . middleware ) . length !== 0 &&
100
+ process . env . NEXT_DISABLE_NETLIFY_EDGE
101
+ ) {
102
+ console . log (
103
+ redBright ( outdent `
104
+ You are using Next.js Middleware without Netlify Edge Functions.
105
+ This is deprecated because it negatively affects performance and will disable ISR and static rendering.
106
+ It also disables advanced middleware features from @netlify/next
107
+ To get the best performance and use Netlify Edge Functions, remove the env var ${ bold `NEXT_DISABLE_NETLIFY_EDGE` } .
108
+ ` ) ,
109
+ )
115
110
}
116
111
117
112
if ( isNextAuthInstalled ( ) ) {
@@ -178,16 +173,7 @@ const plugin: NetlifyPlugin = {
178
173
buildId,
179
174
} )
180
175
181
- if ( usingEdge ) {
182
- await writeEdgeFunctions ( netlifyConfig )
183
-
184
- await enableEdgeInNextConfig ( publish )
185
-
186
- console . log ( outdent `
187
- ✨ Deploying middleware and functions to ${ greenBright `Netlify Edge Functions` } ✨
188
- This feature is in beta. Please share your feedback here: https://ntl.fyi/next-netlify-edge
189
- ` )
190
- }
176
+ await writeEdgeFunctions ( netlifyConfig )
191
177
} ,
192
178
193
179
async onPostBuild ( {
0 commit comments