Skip to content

Commit

Permalink
feat(middleware): add ability to force single build pass (#613)
Browse files Browse the repository at this point in the history
  • Loading branch information
vicb authored Oct 30, 2024
1 parent a43b82b commit dfc174d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/yellow-phones-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@opennextjs/aws": patch
---

feat(middleware): add ability to force single build pass
7 changes: 6 additions & 1 deletion packages/open-next/src/build/createMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ import { installDependencies } from "./installDeps.js";
* Compiles the middleware bundle.
*
* @param options Build Options.
* @param forceOnlyBuildOnce force to build only once.
*/
export async function createMiddleware(options: buildHelper.BuildOptions) {
export async function createMiddleware(
options: buildHelper.BuildOptions,
{ forceOnlyBuildOnce = false } = {},
) {
logger.info(`Bundling middleware function...`);

const { appBuildOutputPath, config, outputDir } = options;
Expand Down Expand Up @@ -57,6 +61,7 @@ export async function createMiddleware(options: buildHelper.BuildOptions) {
defaultConverter: "aws-cloudfront",
includeCache: config.dangerous?.enableCacheInterception,
additionalExternals: config.edgeExternals,
onlyBuildOnce: forceOnlyBuildOnce === true,
});

installDependencies(outputPath, config.middleware?.install);
Expand Down

0 comments on commit dfc174d

Please sign in to comment.