Compare commits

..

4 Commits

Author SHA1 Message Date
JJ Kasper
47f92f8f14 Publish Stable
- @vercel/next@2.6.15
- @vercel/node@1.7.4
2020-07-29 15:43:53 -05:00
JJ Kasper
9aa669d735 Publish Canary
- vercel@20.0.0-canary.7
 - @vercel/next@2.6.15-canary.0
2020-07-29 15:41:14 -05:00
JJ Kasper
99cab6f34a [next] Fix lambda opt-out for index page (#4950)
This makes sure we detect a fully static `/index` page correctly since the `prerender-manifest` lists it as `/` and we were expecting `/index` during the lambda building opt-out check

x-ref: https://github.com/vercel/next.js/discussions/15619
2020-07-29 16:36:13 -04:00
JJ Kasper
547e7dccf7 [next] Add test cases for route /index handling (#4002)
This adds some test cases for `/index` handling to ensure we are being consistent with local development and production
2020-07-29 17:49:28 +00:00
26 changed files with 409 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "vercel",
"version": "20.0.0-canary.6",
"version": "20.0.0-canary.7",
"preferGlobal": true,
"license": "Apache-2.0",
"description": "The command-line interface for Vercel",
@@ -64,8 +64,8 @@
"dependencies": {
"@vercel/build-utils": "2.4.3-canary.2",
"@vercel/go": "1.1.5-canary.0",
"@vercel/next": "2.6.14",
"@vercel/node": "1.7.4-canary.1",
"@vercel/next": "2.6.15",
"@vercel/node": "1.7.4",
"@vercel/python": "1.2.2",
"@vercel/redwood": "0.0.2-canary.1",
"@vercel/ruby": "1.2.3",

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/next",
"version": "2.6.14",
"version": "2.6.15",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",

View File

@@ -880,7 +880,13 @@ export const build = async ({
!prerenderManifest.fallbackRoutes[route] &&
!prerenderManifest.legacyBlockingRoutes[route]
) {
nonLambdaSsgPages.add(route);
// if the 404 page used getStaticProps we need to update static404Page
// since it wasn't populated from the staticPages group
if (route === '/404') {
static404Page = path.join(entryDirectory, '404');
}
nonLambdaSsgPages.add(route === '/' ? '/index' : route);
}
};

View File

@@ -0,0 +1,5 @@
module.exports = {
generateBuildId() {
return 'testing-build-id';
},
};

View File

@@ -0,0 +1,42 @@
{
"version": 2,
"builds": [{ "src": "package.json", "use": "@now/next" }],
"probes": [
{
"path": "/",
"mustContain": "hello from index"
},
{
"path": "/index",
"mustContain": "hello from index"
},
{
"path": "/nested-index/index",
"mustContain": "hello from nested index"
},
{
"path": "/sub",
"mustContain": "hello from sub index"
},
{
"path": "/sub/index",
"mustContain": "hello from sub id"
},
{
"path": "/sub/another",
"mustContain": "hello from sub id"
},
{
"path": "/api/sub",
"mustContain": "hi from sub index"
},
{
"path": "/api/sub/index",
"mustContain": "hi from sub id"
},
{
"path": "/api/sub/another",
"mustContain": "hi from sub id"
}
]
}

View File

@@ -0,0 +1,7 @@
{
"dependencies": {
"next": "latest",
"react": "^16.8.6",
"react-dom": "^16.8.6"
}
}

View File

@@ -0,0 +1 @@
export default (req, res) => res.end('hi from sub id')

View File

@@ -0,0 +1 @@
export default (req, res) => res.end('hi from sub index');

View File

@@ -0,0 +1,2 @@
const page = () => 'hello from index';
export default page;

View File

@@ -0,0 +1 @@
export default () => 'hello from nested index';

View File

@@ -0,0 +1,3 @@
const page = () => "hello from sub id"
page.getInitialProps = () => ({ hello: 'hi' })
export default page

View File

@@ -0,0 +1,3 @@
const page = () => 'hello from sub index';
page.getInitialProps = () => ({ hello: 'hi' });
export default page;

View File

@@ -0,0 +1,5 @@
module.exports = {
generateBuildId() {
return 'testing-build-id';
},
};

View File

@@ -0,0 +1,113 @@
{
"version": 2,
"uploadNowJson": true,
"builds": [{ "src": "package.json", "use": "@vercel/next" }],
"probes": [
{
"path": "/forever",
"status": 200,
"mustContain": "hello"
},
{
"path": "/blog/post-1",
"status": 200,
"mustContain": "post-1"
},
{
"path": "/blog/post-2",
"status": 200,
"mustContain": "post-2"
},
{
"path": "/_next/data/testing-build-id/blog/post-1.json",
"status": 200,
"mustContain": "post-1"
},
{
"path": "/_next/data/testing-build-id/blog/post-2.json",
"status": 200,
"mustContain": "post-2"
},
{
"path": "/blog/post-1/comment-1",
"status": 200,
"mustContain": "comment-1"
},
{
"path": "/blog/post-2/comment-2",
"status": 200,
"mustContain": "comment-2"
},
{
"path": "/_next/data/testing-build-id/blog/post-1/comment-1.json",
"status": 200,
"mustContain": "comment-1"
},
{
"path": "/_next/data/testing-build-id/blog/post-2/comment-2.json",
"status": 200,
"mustContain": "comment-2"
},
{
"path": "/_next/data/testing-build-id/forever.json",
"status": 200,
"mustContain": "world"
},
{
"path": "/_next/data/testing-build-id/another2.json",
"status": 200,
"mustContain": "world"
},
{
"path": "/nofallback/one",
"status": 200,
"mustContain": "one"
},
{
"path": "/nofallback/two",
"status": 200,
"mustContain": "two"
},
{
"path": "/nofallback/nope",
"status": 404,
"mustContain": "page not <!-- -->found"
},
{
"path": "/_next/data/testing-build-id/nofallback/one.json",
"status": 200,
"mustContain": "one"
},
{
"path": "/_next/data/testing-build-id/nofallback/two.json",
"status": 200,
"mustContain": "two"
},
{
"path": "/_next/data/testing-build-id/nofallback/nope.json",
"status": 404
},
{
"path": "/404",
"status": 404,
"mustContain": "page not <!-- -->found"
},
{
"logMustNotContain": "WARNING: your application is being opted out of @vercel/next's optimized lambdas mode due to legacy routes"
},
{
"logMustNotContain": "WARNING: Your application is being opted out of \"@vercel/next\" optimized lambdas mode due to `functions` config"
},
{
"logMustNotContain": "Traced Next.js serverless functions for external files in"
},
{
"logMustNotContain": "All serverless functions created in"
},
{
"logMustNotContain": "Compressed shared serverless function files"
}
]
}

View File

@@ -0,0 +1,7 @@
{
"dependencies": {
"next": "canary",
"react": "^16.8.6",
"react-dom": "^16.8.6"
}
}

View File

@@ -0,0 +1,11 @@
export default function Page({ found }) {
return <p>page not {found}</p>;
}
export const getStaticProps = () => {
return {
props: {
found: 'found',
},
};
};

View File

@@ -0,0 +1,22 @@
import React from 'react';
// eslint-disable-next-line camelcase
export async function getStaticProps() {
return {
props: {
world: 'world',
random: Math.random(),
time: new Date().getTime(),
},
};
}
export default ({ world, time, random }) => {
return (
<>
<p id="hello">hello: {world}</p>
<span id="time">time: {time}</span>
<span id="random">random: {random}</span>
</>
);
};

View File

@@ -0,0 +1,20 @@
import React from 'react';
// eslint-disable-next-line camelcase
export async function getStaticProps() {
return {
props: {
world: 'world',
time: new Date().getTime(),
},
};
}
export default ({ world, time }) => {
return (
<>
<p>hello: {world}</p>
<span>time: {time}</span>
</>
);
};

View File

@@ -0,0 +1,39 @@
import React from 'react';
// eslint-disable-next-line camelcase
export async function getStaticPaths() {
return {
paths: [
'/blog/post-1/comment-1',
{ params: { post: 'post-2', comment: 'comment-2' } },
'/blog/post-1337/comment-1337',
'/blog/post-123/comment-321',
],
fallback: false,
};
}
// eslint-disable-next-line camelcase
export async function getStaticProps({ params }) {
return {
props: {
post: params.post,
random: Math.random(),
comment: params.comment,
time: new Date().getTime(),
},
};
}
export default ({ post, comment, time, random }) => {
if (!post) return <p>loading...</p>;
return (
<>
<p id="post">Post: {post}</p>
<p id="comment">Comment: {comment}</p>
<span id="time">time: {time}</span>
<span id="random">random: {random}</span>
</>
);
};

View File

@@ -0,0 +1,38 @@
import React from 'react';
// eslint-disable-next-line camelcase
export async function getStaticPaths() {
return {
paths: ['/blog/post-1', { params: { post: 'post-2' } }, '/blog/post-123'],
fallback: false,
};
}
// eslint-disable-next-line camelcase
export async function getStaticProps({ params }) {
if (params.post === 'post-10') {
await new Promise(resolve => {
setTimeout(() => resolve(), 1000);
});
}
return {
props: {
post: params.post,
random: Math.random(),
time: (await import('perf_hooks')).performance.now(),
},
};
}
export default ({ post, time, random }) => {
if (!post) return <p>loading...</p>;
return (
<>
<p id="post">Post: {post}</p>
<span id="time">time: {time}</span>
<span id="random">random: {random}</span>
</>
);
};

View File

@@ -0,0 +1,21 @@
import React from 'react';
// eslint-disable-next-line camelcase
export async function getStaticProps() {
return {
props: {
world: 'world',
time: new Date().getTime(),
},
revalidate: false,
};
}
export default ({ world, time }) => {
return (
<>
<p>hello: {world}</p>
<span>time: {time}</span>
</>
);
};

View File

@@ -0,0 +1,9 @@
export default () => 'Hi';
export const getStaticProps = () => {
return {
props: {
hello: 'world',
},
};
};

View File

@@ -0,0 +1,30 @@
import React from 'react';
// eslint-disable-next-line camelcase
export async function getStaticPaths() {
return {
paths: ['/nofallback/one', { params: { slug: 'two' } }],
fallback: false,
};
}
// eslint-disable-next-line camelcase
export async function getStaticProps({ params }) {
return {
props: {
slug: params.slug,
time: (await import('perf_hooks')).performance.now(),
},
};
}
export default ({ slug, time }) => {
return (
<>
<p>
Slug ({slug.length}): {slug}
</p>
<span>time: {time}</span>
</>
);
};

View File

@@ -0,0 +1,9 @@
export default () => 'Hi';
export const getStaticProps = () => {
return {
props: {
hello: 'world',
},
};
};

View File

@@ -1 +1,9 @@
export default () => 'Hi';
export const getStaticProps = () => {
return {
props: {
hello: 'world',
},
};
};

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/node",
"version": "1.7.4-canary.1",
"version": "1.7.4",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/node-js",