From 12e8b1265d39ca83b2b1c42acaf66693de12bc75 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Tue, 27 Jun 2017 07:02:30 +0200 Subject: [PATCH 1/3] Document usage of without (#2369) --- readme.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/readme.md b/readme.md index 25f49a38..8cc03351 100644 --- a/readme.md +++ b/readme.md @@ -319,6 +319,8 @@ export default () => ( That will generate the URL string `/about?name=Zeit`, you can use every property as defined in the [Node.js URL module documentation](https://nodejs.org/api/url.html#url_url_strings_and_url_objects). +##### Replace instead of push url + The default behaviour for the `` component is to `push` a new url into the stack. You can use the `replace` prop to prevent adding a new entry. ```jsx @@ -329,6 +331,18 @@ export default () => ( ) ``` +##### Using a component that support `onClick` + +`` supports any component that supports the `onClick` event. In case you don't provide an `` tag, it will only add the `onClick` event handler and won't pass the `href` property. + +```jsx +// pages/index.js +import Link from 'next/link' +export default () => ( +
Click
+) +``` + #### Imperatively

From 23c2f02f56063d7cebf3940f0eb02b8acfadabb6 Mon Sep 17 00:00:00 2001 From: Arunoda Susiripala Date: Thu, 29 Jun 2017 00:46:21 +0530 Subject: [PATCH 2/3] Make it easy and meaningful to analyze the bundle. (#2393) --- .../with-webpack-bundle-analyzer/README.md | 15 ++++----- .../next.config.js | 25 +++++++-------- .../with-webpack-bundle-analyzer/package.json | 10 +++--- .../pages/contact.js | 5 +++ .../pages/index.js | 31 +++++++++++++++++-- server/build/plugins/combine-assets-plugin.js | 3 +- 6 files changed, 59 insertions(+), 30 deletions(-) create mode 100644 examples/with-webpack-bundle-analyzer/pages/contact.js diff --git a/examples/with-webpack-bundle-analyzer/README.md b/examples/with-webpack-bundle-analyzer/README.md index 49d3d028..00619a43 100644 --- a/examples/with-webpack-bundle-analyzer/README.md +++ b/examples/with-webpack-bundle-analyzer/README.md @@ -11,21 +11,18 @@ curl https://codeload.github.com/zeit/next.js/tar.gz/master | tar -xz --strip=2 cd with-webpack-bundle-analyzer ``` -Install it and run: +Install it ```bash npm install -npm run dev -``` - -Deploy it to the cloud with [now](https://zeit.co/now) ([download](https://zeit.co/download)) - -```bash -now ``` ## The idea behind the example This example shows how to analyze the output bundles using [webpack-bundle-analyzer](https://github.com/th0r/webpack-bundle-analyzer#as-plugin) -To view the stats use `npm run bundle:view` +To analyze your webpack output, invoke the following command: + +```bash +npm run analyze +``` diff --git a/examples/with-webpack-bundle-analyzer/next.config.js b/examples/with-webpack-bundle-analyzer/next.config.js index 0bd0c84d..ad085831 100644 --- a/examples/with-webpack-bundle-analyzer/next.config.js +++ b/examples/with-webpack-bundle-analyzer/next.config.js @@ -1,17 +1,16 @@ -const {BundleAnalyzerPlugin} = require('webpack-bundle-analyzer') +const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer') +const { ANALYZE } = process.env + module.exports = { - webpack: (config, { dev }) => { - // Perform customizations to config - config.plugins.push( - new BundleAnalyzerPlugin({ - analyzerMode: 'disabled', - // For all options see https://github.com/th0r/webpack-bundle-analyzer#as-plugin - generateStatsFile: true, - // Will be available at `.next/stats.json` - statsFilename: 'stats.json' - }) - ) - // Important: return the modified config + webpack: function (config) { + if (ANALYZE) { + config.plugins.push(new BundleAnalyzerPlugin({ + analyzerMode: 'server', + analyzerPort: 8888, + openAnalyzer: true + })) + } + return config } } diff --git a/examples/with-webpack-bundle-analyzer/package.json b/examples/with-webpack-bundle-analyzer/package.json index 2d15a47e..cb1657d9 100644 --- a/examples/with-webpack-bundle-analyzer/package.json +++ b/examples/with-webpack-bundle-analyzer/package.json @@ -5,13 +5,15 @@ "dev": "next", "build": "next build", "start": "next start", - "bundle:view": "webpack-bundle-analyzer .next/stats.json" + "analyze": "cross-env ANALYZE=1 next build" }, "dependencies": { "next": "latest", - "react": "^15.4.2", - "react-dom": "^15.4.2", - "webpack-bundle-analyzer": "^2.3.0" + "cross-env": "^5.0.1", + "faker": "^4.1.0", + "react": "^15.6.1", + "react-dom": "^15.6.1", + "webpack-bundle-analyzer": "^2.8.2" }, "author": "", "license": "ISC" diff --git a/examples/with-webpack-bundle-analyzer/pages/contact.js b/examples/with-webpack-bundle-analyzer/pages/contact.js new file mode 100644 index 00000000..ad1b3696 --- /dev/null +++ b/examples/with-webpack-bundle-analyzer/pages/contact.js @@ -0,0 +1,5 @@ +export default () => ( +
+ This is the contact page. +
+) diff --git a/examples/with-webpack-bundle-analyzer/pages/index.js b/examples/with-webpack-bundle-analyzer/pages/index.js index d120061e..11df6e46 100644 --- a/examples/with-webpack-bundle-analyzer/pages/index.js +++ b/examples/with-webpack-bundle-analyzer/pages/index.js @@ -1,4 +1,29 @@ +import React from 'react' import Link from 'next/link' -export default () => ( -
Hello World. About
-) + +export default class Index extends React.Component { + static getInitialProps ({ req }) { + if (req) { + // Runs only in the server + const faker = require('faker') + const name = faker.name.findName() + return { name } + } + + // Runs only in the client + return { name: 'Arunoda' } + } + + render () { + const { name } = this.props + return ( +
+

Home Page

+

Welcome, {name}

+
+ About Page +
+
+ ) + } +} diff --git a/server/build/plugins/combine-assets-plugin.js b/server/build/plugins/combine-assets-plugin.js index 439c7dd0..5093b051 100644 --- a/server/build/plugins/combine-assets-plugin.js +++ b/server/build/plugins/combine-assets-plugin.js @@ -15,7 +15,8 @@ export default class CombineAssetsPlugin { if (!asset) return newSource += `${asset.source()}\n` - delete compilation.assets[name] + + // We keep existing assets since that helps when analyzing the bundle }) compilation.assets[this.output] = { From 5d797702d12511e882aa172575b6c90f160d4546 Mon Sep 17 00:00:00 2001 From: Arunoda Susiripala Date: Thu, 29 Jun 2017 00:47:13 +0530 Subject: [PATCH 3/3] 2.4.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7d086dc7..f152b992 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "next", - "version": "2.4.5", + "version": "2.4.6", "description": "Minimalistic framework for server-rendered React applications", "main": "./dist/server/next.js", "license": "MIT",