[next] fix lambda creation when using edge runtime (#9204)

Co-authored-by: remorses <beats.by.morse@gmail.com>
This commit is contained in:
JJ Kasper
2023-01-11 09:35:21 -08:00
committed by GitHub
parent 84f93d8af4
commit 3f47587a8b
3 changed files with 22 additions and 1 deletions

View File

@@ -2662,7 +2662,7 @@ async function getServerlessPages(params: {
for (const edgeFunctionFile of Object.keys(
middlewareManifest?.functions ?? {}
)) {
const edgePath = edgeFunctionFile.slice(1) + '.js';
const edgePath = (edgeFunctionFile.slice(1) || 'index') + '.js';
delete normalizedAppPaths[edgePath];
delete pages[edgePath];
}

View File

@@ -8,6 +8,18 @@ jest.setTimeout(ms('6m'));
describe(`${__dirname.split(path.sep).pop()}`, () => {
it('should normalize routes in build results output', async () => {
// TODO: remove after bug with edge functions on Windows
// is resolved upstream in Next.js
if (process.platform === 'win32') {
const indexPage = path.join(__dirname, 'pages/index.tsx');
await fs.writeFile(
indexPage,
(
await fs.readFile(indexPage, 'utf8')
).replace('runtime: ', '// runtime: ')
);
}
const files = [
'index.test.js',
'next.config.js',
@@ -35,5 +47,9 @@ describe(`${__dirname.split(path.sep).pop()}`, () => {
expect(output).toHaveProperty('test/api/hello');
expect(output['test/api/hello'].type).toEqual('EdgeFunction');
for (const name in output) {
expect(output[name].type).not.toBe('Lambda');
}
});
});

View File

@@ -9,3 +9,8 @@ const Home: NextPage = () => {
}
export default Home
export const config = {
runtime: 'experimental-edge',
}