mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-10 04:22:12 +00:00
[build-utils] Deprecate EdgeFunction#name property (#11010)
The `name` property of the `EdgeFunction` class is no longer necessary on the infra side. Instead, its value is inferred based on the URL path that the function is representing. So deprecate the property on the class, and remove its usage throughout the codebase.
This commit is contained in:
9
.changeset/seven-carrots-begin.md
Normal file
9
.changeset/seven-carrots-begin.md
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
'@vercel/build-utils': minor
|
||||
'@vercel/static-build': patch
|
||||
'@vercel/hydrogen': patch
|
||||
'@vercel/remix-builder': patch
|
||||
'@vercel/node': patch
|
||||
---
|
||||
|
||||
Deprecate `EdgeFunction#name` property
|
||||
@@ -8,12 +8,13 @@ export class EdgeFunction {
|
||||
|
||||
/**
|
||||
* A display name for the edge function.
|
||||
* @deprecated This property should no longer be used. The name is inferred from the URL path of the function.
|
||||
*/
|
||||
name: string;
|
||||
name?: string;
|
||||
|
||||
/**
|
||||
* The deployment target.
|
||||
* Only v8-worker is currently supported.
|
||||
* Only `v8-worker` is currently supported.
|
||||
*/
|
||||
deploymentTarget: 'v8-worker';
|
||||
|
||||
|
||||
@@ -126,7 +126,6 @@ export const build: BuildV2 = async ({
|
||||
]);
|
||||
|
||||
const edgeFunction = new EdgeFunction({
|
||||
name: 'hydrogen',
|
||||
deploymentTarget: 'v8-worker',
|
||||
entrypoint: 'index.js',
|
||||
files: edgeFunctionFiles,
|
||||
|
||||
@@ -483,9 +483,6 @@ export const build: BuildV3 = async ({
|
||||
entrypoint: handler,
|
||||
files: preparedFiles,
|
||||
regions: staticConfig?.regions,
|
||||
|
||||
// TODO: remove - these two properties should not be required
|
||||
name: outputPath,
|
||||
deploymentTarget: 'v8-worker',
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -540,17 +540,7 @@ module.exports = config;`;
|
||||
throw new Error(`Could not determine server bundle for "${route.id}"`);
|
||||
}
|
||||
|
||||
output[path] =
|
||||
func instanceof EdgeFunction
|
||||
? // `EdgeFunction` currently requires the "name" property to be set.
|
||||
// Ideally this property will be removed, at which point we can
|
||||
// return the same `edgeFunction` instance instead of creating a
|
||||
// new one for each page.
|
||||
new EdgeFunction({
|
||||
...func,
|
||||
name: path,
|
||||
})
|
||||
: func;
|
||||
output[path] = func;
|
||||
|
||||
// If this is a dynamic route then add a Vercel route
|
||||
const re = getRegExpFromPath(rePath);
|
||||
@@ -573,10 +563,7 @@ module.exports = config;`;
|
||||
);
|
||||
const func =
|
||||
edgeFunctionIndex !== -1 ? functions[edgeFunctionIndex] : functions[0];
|
||||
output['404'] =
|
||||
func instanceof EdgeFunction
|
||||
? new EdgeFunction({ ...func, name: '404' })
|
||||
: func;
|
||||
output['404'] = func;
|
||||
}
|
||||
routes.push({
|
||||
src: '/(.*)',
|
||||
@@ -767,7 +754,6 @@ async function createRenderEdgeFunction(
|
||||
const fn = new EdgeFunction({
|
||||
files,
|
||||
deploymentTarget: 'v8-worker',
|
||||
name: 'render',
|
||||
entrypoint: handler,
|
||||
regions: config.regions,
|
||||
framework: {
|
||||
|
||||
@@ -80,7 +80,6 @@ export async function readBuildOutputDirectory({
|
||||
files: {
|
||||
'_middleware.js': middleware.file,
|
||||
},
|
||||
name: 'middleware',
|
||||
regions: (() => {
|
||||
try {
|
||||
const project = new Project();
|
||||
|
||||
Reference in New Issue
Block a user