Skip to content

Commit

Permalink
Merge branch 'canary' into fix-30398
Browse files Browse the repository at this point in the history
  • Loading branch information
javivelasco committed Dec 2, 2021
2 parents 5a4b78c + a016713 commit ec74432
Show file tree
Hide file tree
Showing 23 changed files with 70 additions and 22 deletions.
2 changes: 1 addition & 1 deletion examples/cms-strapi/components/alert.js
Expand Up @@ -14,7 +14,7 @@ export default function Alert({ preview }) {
<div className="py-2 text-center text-sm">
{preview ? (
<>
This is page is a preview.{' '}
This page is a preview.{' '}
<a
href="/api/exit-preview"
className="underline hover:text-cyan duration-200 transition-colors"
Expand Down
5 changes: 4 additions & 1 deletion packages/next/export/index.ts
Expand Up @@ -600,7 +600,10 @@ export default async function exportApp(
ampValidationResult.errors.length > 0)
}
renderError = renderError || !!result.error
if (!!result.error) errorPaths.push(path)
if (!!result.error) {
const { page } = pathMap
errorPaths.push(page !== path ? `${page}: ${path}` : path)
}

if (options.buildExport && configuration) {
if (typeof result.fromBuildExportRevalidate !== 'undefined') {
Expand Down
2 changes: 1 addition & 1 deletion packages/next/server/web/spec-extension/response.ts
@@ -1,8 +1,8 @@
import type { I18NConfig } from '../../config-shared'
import type { CookieSerializeOptions } from 'next/dist/compiled/cookie'
import { NextURL } from '../next-url'
import { toNodeHeaders } from '../utils'
import cookie from 'next/dist/compiled/cookie'
import { CookieSerializeOptions } from '../types'

const INTERNALS = Symbol('internal response')
const REDIRECTS = new Set([301, 302, 303, 307, 308])
Expand Down
11 changes: 11 additions & 0 deletions packages/next/server/web/types.ts
Expand Up @@ -7,6 +7,17 @@ export interface NodeHeaders {
[header: string]: string | string[] | undefined
}

export interface CookieSerializeOptions {
domain?: string
encode?(val: string): string
expires?: Date
httpOnly?: boolean
maxAge?: number
path?: string
sameSite?: boolean | 'lax' | 'strict' | 'none'
secure?: boolean
}

export interface RequestData {
geo?: {
city?: string
Expand Down
Expand Up @@ -20,7 +20,6 @@ const runTests = () => {
expect(stderr).not.toContain('/amp')
expect(stderr).not.toContain('/ssr')
expect(stderr).not.toContain('/ssg')
expect(stderr).not.toContain('/hello')
})
}

Expand Down
16 changes: 16 additions & 0 deletions test/integration/handles-export-errors/pages/blog/[slug].js
@@ -0,0 +1,16 @@
export default function Page() {
throw new Error('oops')
}

export function getStaticProps() {
return {
props: {},
}
}

export function getStaticPaths() {
return {
paths: ['/blog/first', '/blog/second'],
fallback: false,
}
}
2 changes: 2 additions & 0 deletions test/integration/handles-export-errors/test/index.test.js
Expand Up @@ -19,5 +19,7 @@ describe('Handles Errors During Export', () => {
expect(stderr).toContain('/page-2')
expect(stderr).toContain('/page-3')
expect(stderr).toContain('/page-13')
expect(stderr).toContain('/blog/[slug]: /blog/first')
expect(stderr).toContain('/blog/[slug]: /blog/second')
})
})
16 changes: 0 additions & 16 deletions test/integration/middleware-typescript/test/index.test.js

This file was deleted.

Expand Up @@ -5,7 +5,7 @@ export const middleware: NextMiddleware = function (request) {
console.log(request.ua?.isBot)
console.log(request.ua?.ua)

return new Response(null, {
return new Response('hello from middleware', {
headers: {
'req-url-basepath': request.nextUrl.basePath,
'req-url-pathname': request.nextUrl.pathname,
Expand Down
Expand Up @@ -6,7 +6,7 @@
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"skipLibCheck": false,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
Expand Down
33 changes: 33 additions & 0 deletions test/production/middleware-typescript/test/index.test.ts
@@ -0,0 +1,33 @@
/* eslint-env jest */

import { join } from 'path'
import { createNext, FileRef } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import { renderViaHTTP } from 'next-test-utils'

const appDir = join(__dirname, '../app')

describe('should set-up next', () => {
let next: NextInstance

beforeAll(async () => {
next = await createNext({
files: {
pages: new FileRef(join(appDir, 'pages')),
'tsconfig.json': new FileRef(join(appDir, 'tsconfig.json')),
'next.config.js': new FileRef(join(appDir, 'next.config.js')),
},
dependencies: {
typescript: 'latest',
'@types/react': 'latest',
'@types/react-dom': 'latest',
},
})
})
afterAll(() => next.destroy())

it('should have built and started', async () => {
const html = await renderViaHTTP(next.url, '/interface/static')
expect(html).toContain('hello from middleware')
})
})

0 comments on commit ec74432

Please sign in to comment.