Commit 18f8ab39 authored by Tim Neutkens's avatar Tim Neutkens

Merge branch 'master' into canary

# Conflicts:
#	examples/with-apollo/lib/initApollo.js
#	examples/with-apollo/package.json
#	examples/with-react-with-styles/package.json
#	examples/with-static-export/package.json
#	package.json
parents a35e747e 8bb31f09
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"name": "next-bench", "name": "next-bench",
"scripts": { "scripts": {
"build": "next build", "build": "next build",
"start": "npm run build && next start", "start": "NODE_ENV=production npm run build && NODE_ENV=production next start",
"bench:stateless": "ab -c1 -n3000 http://0.0.0.0:3000/stateless", "bench:stateless": "ab -c1 -n3000 http://0.0.0.0:3000/stateless",
"bench:stateless-big": "ab -c1 -n500 http://0.0.0.0:3000/stateless-big" "bench:stateless-big": "ab -c1 -n500 http://0.0.0.0:3000/stateless-big"
} }
......
module.exports = require('./dist/client/index')
...@@ -56,6 +56,8 @@ let ErrorDebugComponent ...@@ -56,6 +56,8 @@ let ErrorDebugComponent
let Component let Component
let stripAnsi = (s) => s let stripAnsi = (s) => s
export const emitter = new EventEmitter()
export default async ({ ErrorDebugComponent: passedDebugComponent, stripAnsi: passedStripAnsi } = {}) => { export default async ({ ErrorDebugComponent: passedDebugComponent, stripAnsi: passedStripAnsi } = {}) => {
// Wait for all the dynamic chunks to get loaded // Wait for all the dynamic chunks to get loaded
for (const chunkName of chunks) { for (const chunkName of chunks) {
...@@ -80,8 +82,6 @@ export default async ({ ErrorDebugComponent: passedDebugComponent, stripAnsi: pa ...@@ -80,8 +82,6 @@ export default async ({ ErrorDebugComponent: passedDebugComponent, stripAnsi: pa
err err
}) })
const emitter = new EventEmitter()
router.subscribe(({ Component, props, hash, err }) => { router.subscribe(({ Component, props, hash, err }) => {
render({ Component, props, err, hash, emitter }) render({ Component, props, err, hash, emitter })
}) })
...@@ -132,7 +132,7 @@ export async function renderError (error) { ...@@ -132,7 +132,7 @@ export async function renderError (error) {
} }
} }
async function doRender ({ Component, props, hash, err, emitter }) { async function doRender ({ Component, props, hash, err, emitter: emitterProp = emitter }) {
if (!props && Component && if (!props && Component &&
Component !== ErrorComponent && Component !== ErrorComponent &&
lastAppProps.Component === ErrorComponent) { lastAppProps.Component === ErrorComponent) {
...@@ -141,10 +141,6 @@ async function doRender ({ Component, props, hash, err, emitter }) { ...@@ -141,10 +141,6 @@ async function doRender ({ Component, props, hash, err, emitter }) {
props = await loadGetInitialProps(Component, { err, pathname, query, asPath }) props = await loadGetInitialProps(Component, { err, pathname, query, asPath })
} }
if (emitter) {
emitter.emit('before-reactdom-render', { Component, ErrorComponent })
}
Component = Component || lastAppProps.Component Component = Component || lastAppProps.Component
props = props || lastAppProps.props props = props || lastAppProps.props
...@@ -152,13 +148,13 @@ async function doRender ({ Component, props, hash, err, emitter }) { ...@@ -152,13 +148,13 @@ async function doRender ({ Component, props, hash, err, emitter }) {
// lastAppProps has to be set before ReactDom.render to account for ReactDom throwing an error. // lastAppProps has to be set before ReactDom.render to account for ReactDom throwing an error.
lastAppProps = appProps lastAppProps = appProps
emitterProp.emit('before-reactdom-render', { Component, ErrorComponent, appProps })
// We need to clear any existing runtime error messages // We need to clear any existing runtime error messages
ReactDOM.unmountComponentAtNode(errorContainer) ReactDOM.unmountComponentAtNode(errorContainer)
renderReactElement(createElement(App, appProps), appContainer) renderReactElement(createElement(App, appProps), appContainer)
if (emitter) { emitterProp.emit('after-reactdom-render', { Component, ErrorComponent, appProps })
emitter.emit('after-reactdom-render', { Component, ErrorComponent })
}
} }
let isInitialRender = true let isInitialRender = true
......
...@@ -3,7 +3,7 @@ import cookie from 'cookie' ...@@ -3,7 +3,7 @@ import cookie from 'cookie'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { ApolloProvider, getDataFromTree } from 'react-apollo' import { ApolloProvider, getDataFromTree } from 'react-apollo'
import initApollo from './init-apollo' import initApollo from './initApollo'
function parseCookies (ctx = {}, options = {}) { function parseCookies (ctx = {}, options = {}) {
return cookie.parse( return cookie.parse(
......
...@@ -15,9 +15,9 @@ ...@@ -15,9 +15,9 @@
"isomorphic-unfetch": "^2.0.0", "isomorphic-unfetch": "^2.0.0",
"next": "latest", "next": "latest",
"prop-types": "^15.5.10", "prop-types": "^15.5.10",
"react": "^15.5.4", "react": "^16.0.0",
"react-apollo": "^1.1.3", "react-apollo": "^1.1.3",
"react-dom": "^15.5.4" "react-dom": "^16.0.0"
}, },
"devDependencies": { "devDependencies": {
"ava": "^0.19.1", "ava": "^0.19.1",
......
...@@ -4,9 +4,9 @@ import cookie from 'cookie' ...@@ -4,9 +4,9 @@ import cookie from 'cookie'
import Link from 'next/link' import Link from 'next/link'
import gql from 'graphql-tag' import gql from 'graphql-tag'
import withData from '../lib/with-data' import withData from '../lib/withData'
import redirect from '../lib/redirect' import redirect from '../lib/redirect'
import checkLoggedIn from '../lib/check-logged-in' import checkLoggedIn from '../lib/checkLoggedIn'
class CreateAccount extends React.Component { class CreateAccount extends React.Component {
static async getInitialProps (context, apolloClient) { static async getInitialProps (context, apolloClient) {
......
...@@ -2,9 +2,9 @@ import React from 'react' ...@@ -2,9 +2,9 @@ import React from 'react'
import cookie from 'cookie' import cookie from 'cookie'
import { withApollo, compose } from 'react-apollo' import { withApollo, compose } from 'react-apollo'
import withData from '../lib/with-data' import withData from '../lib/withData'
import redirect from '../lib/redirect' import redirect from '../lib/redirect'
import checkLoggedIn from '../lib/check-logged-in' import checkLoggedIn from '../lib/checkLoggedIn'
class Index extends React.Component { class Index extends React.Component {
static async getInitialProps (context, apolloClient) { static async getInitialProps (context, apolloClient) {
......
...@@ -4,9 +4,9 @@ import cookie from 'cookie' ...@@ -4,9 +4,9 @@ import cookie from 'cookie'
import Link from 'next/link' import Link from 'next/link'
import gql from 'graphql-tag' import gql from 'graphql-tag'
import withData from '../lib/with-data' import withData from '../lib/withData'
import redirect from '../lib/redirect' import redirect from '../lib/redirect'
import checkLoggedIn from '../lib/check-logged-in' import checkLoggedIn from '../lib/checkLoggedIn'
class Signin extends React.Component { class Signin extends React.Component {
static async getInitialProps (context, apolloClient) { static async getInitialProps (context, apolloClient) {
......
import React from 'react' import React from 'react'
import ReactDOMServer from 'react-dom/lib/ReactDOMServer' import ReactDOMServer from 'react-dom/server'
export default function Noscript (props) { export default function Noscript (props) {
const staticMarkup = ReactDOMServer.renderToStaticMarkup(props.children) const staticMarkup = ReactDOMServer.renderToStaticMarkup(props.children)
......
...@@ -2,7 +2,7 @@ module.exports = { ...@@ -2,7 +2,7 @@ module.exports = {
webpack: (config, { dev }) => { webpack: (config, { dev }) => {
if (!dev) { if (!dev) {
config.resolve.alias = { config.resolve.alias = {
'react-dom/server': require.resolve('react-dom/dist/react-dom-server.min.js') 'react-dom/server': require.resolve('react-dom/umd/react-dom-server.browser.production.min.js')
} }
} }
return config return config
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
"start": "next start" "start": "next start"
}, },
"dependencies": { "dependencies": {
"next": "^3.0.3", "next": "latest",
"react": "^16.0.0", "react": "^16.0.0",
"react-dom": "^16.0.0", "react-dom": "^16.0.0",
"react-lazyload": "^2.2.7" "react-lazyload": "^2.2.7"
......
{ {
"name": "with-static-export",
"main": "server.js", "main": "server.js",
"dependencies": { "dependencies": {
"express": "^4.15.3", "express": "^4.15.3",
"isomorphic-unfetch": "^2.0.0", "isomorphic-unfetch": "^2.0.0",
"next": "beta", "next": "latest",
"react": "^15.5.4", "react": "^16.0.0",
"react-dom": "^15.5.4", "react-dom": "^16.0.0",
"serve": "^5.2.2" "serve": "^5.2.2"
}, },
"scripts": { "scripts": {
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
"files": [ "files": [
"dist", "dist",
"babel.js", "babel.js",
"client.js",
"link.js", "link.js",
"css.js", "css.js",
"head.js", "head.js",
......
...@@ -1190,6 +1190,8 @@ Next.js bundles [styled-jsx](https://github.com/zeit/styled-jsx) supporting scop ...@@ -1190,6 +1190,8 @@ Next.js bundles [styled-jsx](https://github.com/zeit/styled-jsx) supporting scop
- [with-external-scoped-css](./examples/with-external-scoped-css) - [with-external-scoped-css](./examples/with-external-scoped-css)
- [with-scoped-stylesheets-and-postcss](./examples/with-scoped-stylesheets-and-postcss) - [with-scoped-stylesheets-and-postcss](./examples/with-scoped-stylesheets-and-postcss)
- [with-global-stylesheet](./examples/with-global-stylesheet) - [with-global-stylesheet](./examples/with-global-stylesheet)
- [with-styled-jsx-scss](./examples/with-styled-jsx-scss)
- [with-styled-jsx-plugins](./examples/with-styled-jsx-plugins)
</details> </details>
......
...@@ -13,8 +13,8 @@ export default async function build (dir, conf = null) { ...@@ -13,8 +13,8 @@ export default async function build (dir, conf = null) {
const compiler = await webpack(dir, { buildId, buildDir, conf }) const compiler = await webpack(dir, { buildId, buildDir, conf })
try { try {
await runCompiler(compiler) const stats = await runCompiler(compiler)
await writeBuildStats(buildDir) await writeBuildStats(buildDir, stats)
await writeBuildId(buildDir, buildId) await writeBuildId(buildDir, buildId)
} catch (err) { } catch (err) {
console.error(`> Failed to build on ${buildDir}`) console.error(`> Failed to build on ${buildDir}`)
...@@ -46,7 +46,7 @@ function runCompiler (compiler) { ...@@ -46,7 +46,7 @@ function runCompiler (compiler) {
}) })
} }
async function writeBuildStats (dir) { async function writeBuildStats (dir, stats) {
// Here we can't use hashes in webpack chunks. // Here we can't use hashes in webpack chunks.
// That's because the "app.js" is not tied to a chunk. // That's because the "app.js" is not tied to a chunk.
// It's created by merging a few assets. (commons.js and main.js) // It's created by merging a few assets. (commons.js and main.js)
...@@ -58,6 +58,9 @@ async function writeBuildStats (dir) { ...@@ -58,6 +58,9 @@ async function writeBuildStats (dir) {
} }
const buildStatsPath = join(dir, '.next', 'build-stats.json') const buildStatsPath = join(dir, '.next', 'build-stats.json')
await fs.writeFile(buildStatsPath, JSON.stringify(assetHashMap), 'utf8') await fs.writeFile(buildStatsPath, JSON.stringify(assetHashMap), 'utf8')
const statsPath = join(dir, '.next', 'webpack-stats.json')
await fs.writeFile(statsPath, JSON.stringify(stats), 'utf8')
} }
async function writeBuildId (dir, buildId) { async function writeBuildId (dir, buildId) {
......
...@@ -43,6 +43,7 @@ export default async function createCompiler (dir, { buildId, dev = false, quiet ...@@ -43,6 +43,7 @@ export default async function createCompiler (dir, { buildId, dev = false, quiet
const entries = { const entries = {
'main.js': [ 'main.js': [
...defaultEntries, ...defaultEntries,
...config.clientBootstrap || [],
mainJS mainJS
] ]
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment