Compare commits

..

2 Commits

Author SHA1 Message Date
JJ Kasper
4f0f44e746 Publish Stable
- @now/next@2.3.3
2020-01-02 13:18:38 -06:00
JJ Kasper
0da98a7f5d Revert "[now-next] Implement handle: miss for custom-routes (#3456)" (#3488)
This reverts commit 40bbff9bee.
2020-01-02 13:15:16 -06:00
10 changed files with 24 additions and 83 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@now/next",
"version": "2.3.3-canary.0",
"version": "2.3.3",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://zeit.co/docs/runtimes#official-runtimes/next-js",

View File

@@ -450,11 +450,7 @@ export const build = async ({
const prerenders: { [key: string]: Prerender | FileFsRef } = {};
const staticPages: { [key: string]: FileFsRef } = {};
const dynamicPages: string[] = [];
const dynamicDataRoutes: Array<{
src: string;
dest: string;
check: true;
}> = [];
const dynamicDataRoutes: Array<{ src: string; dest: string }> = [];
const appMountPrefixNoTrailingSlash = path.posix
.join('/', entryDirectory)
@@ -880,7 +876,6 @@ export const build = async ({
src: dataRouteRegex.replace(/^\^/, `^${appMountPrefixNoTrailingSlash}`),
// Location of lambda in builder output
dest: path.posix.join(entryDirectory, dataRoute),
check: true,
});
});
}
@@ -948,28 +943,6 @@ export const build = async ({
routes: [
// redirects take the highest priority
...redirects,
// Next.js page lambdas, `static/` folder, reserved assets, and `public/`
// folder
{ handle: 'filesystem' },
...rewrites,
// Custom Next.js 404 page (TODO: do we want to remove this?)
...(isLegacy
? []
: [
{
src: path.join('/', entryDirectory, '.*'),
dest: path.join('/', entryDirectory, '_error'),
status: 404,
check: true,
},
]),
// Routes that are checked after each rewrite and no filesystem match
{ handle: 'miss' },
// Dynamic routes
...dynamicRoutes,
...dynamicDataRoutes,
// Routes that are checked after filesystem match
{ handle: 'hit' },
// Before we handle static files we need to set proper caching headers
{
// This ensures we only match known emitted-by-Next.js files and not
@@ -984,6 +957,24 @@ export const build = async ({
headers: { 'cache-control': 'public,max-age=31536000,immutable' },
continue: true,
},
{ src: path.join('/', entryDirectory, '_next(?!/data(?:/|$))(?:/.*)?') },
// Next.js page lambdas, `static/` folder, reserved assets, and `public/`
// folder
{ handle: 'filesystem' },
...rewrites,
// Dynamic routes
...dynamicRoutes,
...dynamicDataRoutes,
// Custom Next.js 404 page (TODO: do we want to remove this?)
...(isLegacy
? []
: [
{
src: path.join('/', entryDirectory, '.*'),
dest: path.join('/', entryDirectory, '_error'),
status: 404,
},
]),
],
watch: [],
childProcesses: [],

View File

@@ -353,7 +353,7 @@ export async function getDynamicRoutes(
dynamicPages: string[],
isDev?: boolean,
routesManifest?: RoutesManifest
): Promise<{ src: string; dest: string; check: true }[]> {
): Promise<{ src: string; dest: string }[]> {
if (!dynamicPages.length) {
return [];
}
@@ -367,7 +367,6 @@ export async function getDynamicRoutes(
return {
src: regex,
dest: !isDev ? path.join('/', entryDirectory, page) : page,
check: true,
};
}
);
@@ -424,7 +423,7 @@ export async function getDynamicRoutes(
matcher: getRouteRegex && getRouteRegex(pageName).re,
}));
const routes: { src: string; dest: string; check: true }[] = [];
const routes: { src: string; dest: string }[] = [];
pageMatchers.forEach(pageMatcher => {
// in `now dev` we don't need to prefix the destination
const dest = !isDev
@@ -435,7 +434,6 @@ export async function getDynamicRoutes(
routes.push({
src: pageMatcher.matcher.source,
dest,
check: true,
});
}
});

View File

@@ -1,6 +1,6 @@
{
"dependencies": {
"next": "9.1.7-canary.11",
"next": "^9.1.4-canary.1",
"react": "^16.8.6",
"react-dom": "^16.8.6"
}

View File

@@ -1,6 +1,6 @@
{
"dependencies": {
"next": "9.1.7-canary.11",
"next": "^9.1.4-canary.1",
"react": "^16.8.6",
"react-dom": "^16.8.6"
}

View File

@@ -1,19 +0,0 @@
module.exports = {
generateBuildId() {
return 'testing-build-id';
},
experimental: {
async rewrites() {
return [
{
source: '/blog/post-1',
destination: '/blog/post-2',
},
{
source: '/blog/post-2',
destination: '/404',
},
];
},
},
};

View File

@@ -1,10 +0,0 @@
{
"version": 2,
"builds": [{ "src": "package.json", "use": "@now/next" }],
"probes": [
{
"path": "/blog/post-1",
"mustContain": "post-2"
}
]
}

View File

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

View File

@@ -1,11 +0,0 @@
import { useRouter } from 'next/router'
const Page = () => (
<>
<p>Post: {useRouter().query.post}</p>
</>
)
Page.getInitialProps = () => ({ hello: 'world' })
export default Page

View File

@@ -117,7 +117,6 @@ describe('build meta dev', () => {
{
src: '^/(nested\\/([^\\/]+?)(?:\\/)?)$',
dest: 'http://localhost:5000/$1',
check: true,
},
{ src: '/data.txt', dest: 'http://localhost:5000/data.txt' },
]);