diff --git a/.changeset/olive-trees-applaud.md b/.changeset/olive-trees-applaud.md new file mode 100644 index 000000000..3ab20743d --- /dev/null +++ b/.changeset/olive-trees-applaud.md @@ -0,0 +1,5 @@ +--- +'@vercel/build-utils': minor +--- + +Add new optional prerender field: experimentalStreamingLambdaPath diff --git a/packages/build-utils/src/prerender.ts b/packages/build-utils/src/prerender.ts index 85c6e7693..33ad39eca 100644 --- a/packages/build-utils/src/prerender.ts +++ b/packages/build-utils/src/prerender.ts @@ -12,6 +12,7 @@ interface PrerenderOptions { initialStatus?: number; passQuery?: boolean; sourcePath?: string; + experimentalStreamingLambdaPath?: string; } export class Prerender { @@ -26,6 +27,7 @@ export class Prerender { public initialStatus?: number; public passQuery?: boolean; public sourcePath?: string; + public experimentalStreamingLambdaPath?: string; constructor({ expiration, @@ -38,6 +40,7 @@ export class Prerender { initialStatus, passQuery, sourcePath, + experimentalStreamingLambdaPath, }: PrerenderOptions) { this.type = 'Prerender'; this.expiration = expiration; @@ -130,5 +133,14 @@ export class Prerender { } this.allowQuery = allowQuery; } + + if (experimentalStreamingLambdaPath !== undefined) { + if (typeof experimentalStreamingLambdaPath !== 'string') { + throw new Error( + 'The `experimentalStreamingLambdaPath` argument for `Prerender` must be a string.' + ); + } + this.experimentalStreamingLambdaPath = experimentalStreamingLambdaPath; + } } } diff --git a/packages/build-utils/test/unit.test.ts b/packages/build-utils/test/unit.test.ts index 4cf103b46..46502060d 100644 --- a/packages/build-utils/test/unit.test.ts +++ b/packages/build-utils/test/unit.test.ts @@ -387,6 +387,42 @@ it('should support passQuery correctly', async () => { ); }); +it('should support experimentalStreamingLambdaPath correctly', async () => { + new Prerender({ + expiration: 1, + fallback: null, + group: 1, + bypassToken: 'some-long-bypass-token-to-make-it-work', + experimentalStreamingLambdaPath: undefined, + }); + new Prerender({ + expiration: 1, + fallback: null, + group: 1, + bypassToken: 'some-long-bypass-token-to-make-it-work', + experimentalStreamingLambdaPath: '/some/path/to/lambda', + }); + new Prerender({ + expiration: 1, + fallback: null, + group: 1, + bypassToken: 'some-long-bypass-token-to-make-it-work', + }); + + expect(() => { + new Prerender({ + expiration: 1, + fallback: null, + group: 1, + bypassToken: 'some-long-bypass-token-to-make-it-work', + // @ts-expect-error testing invalid field + experimentalStreamingLambdaPath: 1, + }); + }).toThrowError( + `The \`experimentalStreamingLambdaPath\` argument for \`Prerender\` must be a string.` + ); +}); + it('should support require by path for legacy builders', () => { const index = require('../');