File tree Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -123,12 +123,20 @@ const writeEdgeFunction = async ({
123123 }
124124}
125125
126+ type NetlifyPluginConstantsWithEdgeFunctions = NetlifyPluginConstants & {
127+ // Until https://github.com/netlify/build/pull/4481 lands
128+ INTERNAL_EDGE_FUNCTIONS_SRC ?: string
129+ }
130+
131+ export const cleanupEdgeFunctions = async ( {
132+ INTERNAL_EDGE_FUNCTIONS_SRC = '.netlify/edge-functions' ,
133+ } : NetlifyPluginConstantsWithEdgeFunctions ) => {
134+ await emptyDir ( INTERNAL_EDGE_FUNCTIONS_SRC )
135+ }
136+
126137export const writeDevEdgeFunction = async ( {
127138 INTERNAL_EDGE_FUNCTIONS_SRC = '.netlify/edge-functions' ,
128- } : NetlifyPluginConstants & {
129- // The constants type needs an update
130- INTERNAL_EDGE_FUNCTIONS_SRC ?: string
131- } ) => {
139+ } : NetlifyPluginConstantsWithEdgeFunctions ) => {
132140 const manifest : FunctionManifest = {
133141 functions : [
134142 {
Original file line number Diff line number Diff line change @@ -16,7 +16,12 @@ import {
1616 generateCustomHeaders ,
1717} from './helpers/config'
1818import { onPreDev } from './helpers/dev'
19- import { enableEdgeInNextConfig , writeEdgeFunctions , loadMiddlewareManifest } from './helpers/edge'
19+ import {
20+ enableEdgeInNextConfig ,
21+ writeEdgeFunctions ,
22+ loadMiddlewareManifest ,
23+ cleanupEdgeFunctions ,
24+ } from './helpers/edge'
2025import { moveStaticPages , movePublicFiles , patchNextFiles } from './helpers/files'
2126import { generateFunctions , setupImageFunction , generatePagesResolver } from './helpers/functions'
2227import { generateRedirects , generateStaticRedirects } from './helpers/redirects'
@@ -81,6 +86,8 @@ const plugin: NetlifyPlugin = {
8186 } ,
8287 )
8388
89+ await cleanupEdgeFunctions ( constants )
90+
8491 const middlewareManifest = await loadMiddlewareManifest ( netlifyConfig )
8592
8693 let usingEdge = false
You can’t perform that action at this time.
0 commit comments