mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-10 21:07:48 +00:00
Add optional experimentalStreamingLambda field for prerender (#10476)
This adds a new `experimentalStreamingLambda` field to Prerender outputs, allowing references to an optional streaming lambda path.
This commit is contained in:
5
.changeset/olive-trees-applaud.md
Normal file
5
.changeset/olive-trees-applaud.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@vercel/build-utils': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Add new optional prerender field: experimentalStreamingLambdaPath
|
||||||
@@ -12,6 +12,7 @@ interface PrerenderOptions {
|
|||||||
initialStatus?: number;
|
initialStatus?: number;
|
||||||
passQuery?: boolean;
|
passQuery?: boolean;
|
||||||
sourcePath?: string;
|
sourcePath?: string;
|
||||||
|
experimentalStreamingLambdaPath?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Prerender {
|
export class Prerender {
|
||||||
@@ -26,6 +27,7 @@ export class Prerender {
|
|||||||
public initialStatus?: number;
|
public initialStatus?: number;
|
||||||
public passQuery?: boolean;
|
public passQuery?: boolean;
|
||||||
public sourcePath?: string;
|
public sourcePath?: string;
|
||||||
|
public experimentalStreamingLambdaPath?: string;
|
||||||
|
|
||||||
constructor({
|
constructor({
|
||||||
expiration,
|
expiration,
|
||||||
@@ -38,6 +40,7 @@ export class Prerender {
|
|||||||
initialStatus,
|
initialStatus,
|
||||||
passQuery,
|
passQuery,
|
||||||
sourcePath,
|
sourcePath,
|
||||||
|
experimentalStreamingLambdaPath,
|
||||||
}: PrerenderOptions) {
|
}: PrerenderOptions) {
|
||||||
this.type = 'Prerender';
|
this.type = 'Prerender';
|
||||||
this.expiration = expiration;
|
this.expiration = expiration;
|
||||||
@@ -130,5 +133,14 @@ export class Prerender {
|
|||||||
}
|
}
|
||||||
this.allowQuery = allowQuery;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
36
packages/build-utils/test/unit.test.ts
vendored
36
packages/build-utils/test/unit.test.ts
vendored
@@ -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', () => {
|
it('should support require by path for legacy builders', () => {
|
||||||
const index = require('../');
|
const index = require('../');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user