Skip to content

Commit

Permalink
Merge branch 'canary' into fix_custom_amp_validator
Browse files Browse the repository at this point in the history
  • Loading branch information
yosuke-furukawa authored Nov 7, 2019
2 parents 5ec434b + 210dca8 commit bdcb615
Show file tree
Hide file tree
Showing 34 changed files with 324 additions and 551 deletions.
2 changes: 1 addition & 1 deletion examples/with-firebase-hosting-and-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.0.0",
"description": "Host Next.js SSR app on Firebase Cloud Functions with Firebase Hosting redirects. Built with typescript.",
"engines": {
"node": "8"
"node": "10"
},
"scripts": {
"dev": "next src/app",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Header from './Header'
import Header from './Header';

const App = ({ children }: { children?: any }) => (
<main>
<Header />
{children}
</main>
)
);

export default App
export default App;
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import Link from 'next/link'
import Link from 'next/link';

export default ({ pathname }: { pathname?: any }) => (
<header>
<Link href="/">
<Link href='/'>
<a className={pathname === '/' ? 'is-active' : ''}>Home</a>
</Link>
<Link href="/about">
<Link href='/about'>
<a className={pathname === '/about' ? 'is-active' : ''}>About</a>
</Link>
</header>
)
);
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import App from '../components/App'
import App from '../components/App';

export default () => (
<App>
<p>About Page</p>
</App>
)
);
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import App from '../components/App'
import App from '../components/App';

export default () => (
<App>
<p>Index Page</p>
</App>
)
);
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-env jest */

import React from 'react'
import { render } from 'react-testing-library'
import { render } from '@testing-library/react'

import App from '../pages/index.js'

Expand Down
12 changes: 6 additions & 6 deletions examples/with-jest-react-testing-library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
"version": "1.0.0",
"dependencies": {
"next": "latest",
"react": "^16.7.0",
"react-dom": "^16.7.0"
"react": "^16.11.0",
"react-dom": "^16.11.0"
},
"devDependencies": {
"@babel/core": "7.3.4",
"babel-jest": "24.1.0",
"jest": "24.1.0",
"react-testing-library": "^5.4.2"
"@babel/core": "7.6.4",
"@testing-library/react": "9.3.2",
"babel-jest": "24.9.0",
"jest": "24.9.0"
},
"scripts": {
"test": "jest",
Expand Down
20 changes: 16 additions & 4 deletions examples/with-patternfly/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,22 @@ module.exports = withCSS(
// if they live under a 'fonts' or 'pficon' directory
include: [
path.resolve(__dirname, 'node_modules/patternfly/dist/fonts'),
path.resolve(__dirname, 'node_modules/@patternfly/react-core/dist/styles/assets/fonts'),
path.resolve(__dirname, 'node_modules/@patternfly/react-core/dist/styles/assets/pficon'),
path.resolve(__dirname, 'node_modules/@patternfly/patternfly/assets/fonts'),
path.resolve(__dirname, 'node_modules/@patternfly/patternfly/assets/pficon')
path.resolve(
__dirname,
'node_modules/@patternfly/react-core/dist/styles/assets/fonts'
),
path.resolve(
__dirname,
'node_modules/@patternfly/react-core/dist/styles/assets/pficon'
),
path.resolve(
__dirname,
'node_modules/@patternfly/patternfly/assets/fonts'
),
path.resolve(
__dirname,
'node_modules/@patternfly/patternfly/assets/pficon'
)
],
use: {
loader: 'file-loader',
Expand Down
25 changes: 20 additions & 5 deletions examples/with-sentry-simple/next.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
const withSourceMaps = require('@zeit/next-source-maps')()

module.exports = withSourceMaps({
env: {
SENTRY_DSN: 'hello-world',
// would want to synchronously grab git commit id here for
// best debugging experience
SENTRY_RELEASE: '0.0.1'
webpack: (config, options) => {
// In `pages/_app.js`, Sentry is imported from @sentry/node. While
// @sentry/browser will run in a Node.js environment, @sentry/node will use
// Node.js-only APIs to catch even more unhandled exceptions.
//
// This works well when Next.js is SSRing your page on a server with
// Node.js, but it is not what we want when your client-side bundle is being
// executed by a browser.
//
// Luckily, Next.js will call this webpack function twice, once for the
// server and once for the client. Read more:
// https://nextjs.org/docs#customizing-webpack-config
//
// So ask Webpack to replace @sentry/node imports with @sentry/browser when
// building the browser's bundle
if (!options.isServer) {
config.resolve.alias['@sentry/node'] = '@sentry/browser'
}

return config
}
})
3 changes: 2 additions & 1 deletion examples/with-sentry-simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"start": "next start"
},
"dependencies": {
"@next/plugin-sentry": "latest",
"@sentry/browser": "^5.1.0",
"@sentry/node": "^5.6.2",
"next": "latest",
"react": "^16.8.6",
"react-dom": "^16.8.6"
Expand Down
22 changes: 22 additions & 0 deletions examples/with-sentry-simple/pages/_app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react'
import App from 'next/app'
import * as Sentry from '@sentry/node'

Sentry.init({
// Replace with your project's Sentry DSN
dsn: 'https://[email protected]/1111111'
})

class MyApp extends App {
render () {
const { Component, pageProps } = this.props

// Workaround for https://github.com/zeit/next.js/issues/8592
const { err } = this.props
const modifiedPageProps = { ...pageProps, err }

return <Component {...modifiedPageProps} />
}
}

export default MyApp
66 changes: 66 additions & 0 deletions examples/with-sentry-simple/pages/_error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import React from 'react'
import Error from 'next/error'
import * as Sentry from '@sentry/node'

const MyError = ({ statusCode, hasGetInitialPropsRun, err }) => {
if (!hasGetInitialPropsRun && err) {
// getInitialProps is not called in case of
// https://github.com/zeit/next.js/issues/8592. As a workaround, we pass
// err via _app.js so it can be captured
Sentry.captureException(err)
}

return <Error statusCode={statusCode} />
}

MyError.getInitialProps = async ({ res, err, asPath }) => {
const errorInitialProps = await Error.getInitialProps({ res, err })

// Workaround for https://github.com/zeit/next.js/issues/8592, mark when
// getInitialProps has run
errorInitialProps.hasGetInitialPropsRun = true

if (res) {
// Running on the server, the response object is available.
//
// Next.js will pass an err on the server if a page's `getInitialProps`
// threw or returned a Promise that rejected

if (res.statusCode === 404) {
// Opinionated: do not record an exception in Sentry for 404
return { statusCode: 404 }
}

if (err) {
Sentry.captureException(err)

return errorInitialProps
}
} else {
// Running on the client (browser).
//
// Next.js will provide an err if:
//
// - a page's `getInitialProps` threw or returned a Promise that rejected
// - an exception was thrown somewhere in the React lifecycle (render,
// componentDidMount, etc) that was caught by Next.js's React Error
// Boundary. Read more about what types of exceptions are caught by Error
// Boundaries: https://reactjs.org/docs/error-boundaries.html
if (err) {
Sentry.captureException(err)

return errorInitialProps
}
}

// If this point is reached, getInitialProps was called without any
// information about what the error might be. This is unexpected and may
// indicate a bug introduced in Next.js, so record it in Sentry
Sentry.captureException(
new Error(`_error.js getInitialProps missing data at path: ${asPath}`)
)

return errorInitialProps
}

export default MyError
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "9.1.3-canary.1"
"version": "9.1.3-canary.2"
}
2 changes: 1 addition & 1 deletion packages/create-next-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-next-app",
"version": "9.1.3-canary.1",
"version": "9.1.3-canary.2",
"keywords": [
"react",
"next",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-bundle-analyzer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/bundle-analyzer",
"version": "9.1.3-canary.1",
"version": "9.1.3-canary.2",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-mdx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/mdx",
"version": "9.1.3-canary.1",
"version": "9.1.3-canary.2",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-google-analytics/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-google-analytics",
"version": "9.1.2-canary.1",
"version": "9.1.3-canary.2",
"nextjs": {
"name": "Google Analytics",
"required-env": [
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-material-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-material-ui",
"version": "9.1.2-canary.1",
"version": "9.1.3-canary.2",
"nextjs": {
"name": "Material UI",
"required-env": []
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-sentry/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-sentry",
"version": "9.1.2-canary.1",
"version": "9.1.3-canary.2",
"nextjs": {
"name": "Sentry",
"required-env": [
Expand Down
2 changes: 1 addition & 1 deletion packages/next/build/babel/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ module.exports = (
...options['preset-react'],
},
],
require('@babel/preset-typescript'),
[require('@babel/preset-typescript'), { allowNamespaces: true }],
],
plugins: [
[
Expand Down
5 changes: 1 addition & 4 deletions packages/next/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import {
printTreeView,
} from './utils'
import getBaseWebpackConfig from './webpack-config'
import { getPageChunks } from './webpack/plugins/chunk-graph-plugin'
import { writeBuildId } from './write-build-id'

const fsAccess = promisify(fs.access)
Expand Down Expand Up @@ -347,8 +346,6 @@ export default async function build(dir: string, conf = null): Promise<void> {
const analysisBegin = process.hrtime()
await Promise.all(
pageKeys.map(async page => {
const chunks = getPageChunks(page)

const actualPage = page === '/' ? '/index' : page
const size = await getPageSizeInKb(
actualPage,
Expand Down Expand Up @@ -434,7 +431,7 @@ export default async function build(dir: string, conf = null): Promise<void> {
}
}

pageInfos.set(page, { size, chunks, serverBundle, static: isStatic })
pageInfos.set(page, { size, serverBundle, static: isStatic })
})
)
staticCheckWorkers.end()
Expand Down
Loading

0 comments on commit bdcb615

Please sign in to comment.