@@ -20,10 +20,10 @@ import { type CodePatcher, applyCodePatches } from "./patch/codePatcher.js";
2020
2121interface CodeCustomization {
2222 // These patches are meant to apply on user and next generated code
23- additionalCodePatches : CodePatcher [ ] ;
23+ additionalCodePatches ? : CodePatcher [ ] ;
2424 // These plugins are meant to apply during the esbuild bundling process.
2525 // This will only apply to OpenNext code.
26- additionalPlugins : ( contentUpdater : ContentUpdater ) => Plugin [ ] ;
26+ additionalPlugins ? : ( contentUpdater : ContentUpdater ) => Plugin [ ] ;
2727}
2828
2929export async function createServerBundle (
@@ -167,7 +167,7 @@ async function generateBundle(
167167 // Copy env files
168168 buildHelper . copyEnvFile ( appBuildOutputPath , packagePath , outputPath ) ;
169169
170- // Copy all necessary traced files{
170+ // Copy all necessary traced files
171171 const { tracedFiles, manifests } = await copyTracedFiles ( {
172172 buildOutputPath : appBuildOutputPath ,
173173 packagePath,
@@ -179,15 +179,6 @@ async function generateBundle(
179179 const additionalCodePatches = codeCustomization ?. additionalCodePatches ?? [ ] ;
180180
181181 await applyCodePatches ( options , Array . from ( tracedFiles ) , manifests , [
182- // TODO: create real code patchers here
183- {
184- name : "fakePatchChunks" ,
185- pathFilter : / c h u n k s \/ \d + \. j s / ,
186- patchCode : async ( { code, manifests } ) => {
187- console . log ( manifests ) ;
188- return `console.log("patched chunk");\n${ code } ` ;
189- } ,
190- } ,
191182 ...additionalCodePatches ,
192183 ] ) ;
193184
@@ -211,7 +202,9 @@ async function generateBundle(
211202
212203 const updater = new ContentUpdater ( options ) ;
213204
214- const additionalPlugins = codeCustomization ?. additionalPlugins ( updater ) ?? [ ] ;
205+ const additionalPlugins = codeCustomization ?. additionalPlugins
206+ ? codeCustomization . additionalPlugins ( updater )
207+ : [ ] ;
215208
216209 const plugins = [
217210 openNextReplacementPlugin ( {
@@ -239,6 +232,7 @@ async function generateBundle(
239232 overrides,
240233 } ) ,
241234 ...additionalPlugins ,
235+ // The content updater plugin must be the last plugin
242236 updater . plugin ,
243237 ] ;
244238
0 commit comments