mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-09 21:07:46 +00:00
[cli] Serialize duplicate EdgeFunction references as symlinks in vc build (#11027)
Enables the symlink optimization that currently exists for `Lambda` instances, but now for `EdgeFunction` instances as well. This will be particularly beneficial for Remix applications which use edge functions for many routes, since they will now all be represented by the same underling function in production. --------- Co-authored-by: Sean Massa <EndangeredMassa@gmail.com>
This commit is contained in:
@@ -1248,3 +1248,42 @@ describe('build', () => {
|
||||
).toEqual('marketing');
|
||||
});
|
||||
});
|
||||
|
||||
it('should create symlinks for duplicate references to Lambda / EdgeFunction instances', async () => {
|
||||
if (process.platform === 'win32') {
|
||||
console.log('Skipping test on Windows');
|
||||
return;
|
||||
}
|
||||
const cwd = fixture('functions-symlink');
|
||||
const output = join(cwd, '.vercel/output');
|
||||
client.cwd = cwd;
|
||||
const exitCode = await build(client);
|
||||
expect(exitCode).toEqual(0);
|
||||
|
||||
// "functions" directory has output Functions
|
||||
const functions = await fs.readdir(join(output, 'functions'));
|
||||
expect(functions.sort()).toEqual([
|
||||
'edge.func',
|
||||
'edge2.func',
|
||||
'lambda.func',
|
||||
'lambda2.func',
|
||||
]);
|
||||
expect(
|
||||
fs.lstatSync(join(output, 'functions/lambda.func')).isDirectory()
|
||||
).toEqual(true);
|
||||
expect(
|
||||
fs.lstatSync(join(output, 'functions/edge.func')).isDirectory()
|
||||
).toEqual(true);
|
||||
expect(
|
||||
fs.lstatSync(join(output, 'functions/lambda2.func')).isSymbolicLink()
|
||||
).toEqual(true);
|
||||
expect(
|
||||
fs.lstatSync(join(output, 'functions/edge2.func')).isSymbolicLink()
|
||||
).toEqual(true);
|
||||
expect(fs.readlinkSync(join(output, 'functions/lambda2.func'))).toEqual(
|
||||
'lambda.func'
|
||||
);
|
||||
expect(fs.readlinkSync(join(output, 'functions/edge2.func'))).toEqual(
|
||||
'edge.func'
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user