We are happy to introduce Next.js 5.1, which features support for environment configuration, phases, source maps, and new Next.js plugins.
Major performance improvements are introduced: resolving pages is 102x faster, and error pages are loaded more efficiently.
In addition to bumping Next.js, we upgrade the peer dependencies react and react-dom
Be sure to upgrade next-plugins like @zeit/next-css , @zeit/next-sass , @zeit/next-less or @zeit/next-typescript as well.
Thanks to the architectural changes in Next.js 5.0, we were able to simplify the logic that resolves pages based on url path. These changes were based on research from @oliviertassinari . Previously resolving a page took an average of 2.347ms . With the new logic resolving the same page takes on average 0.023ms .
This is an excerpt. The full article is published by Next.js Blog.
Answers to common questions regarding this article's topic, architecture, and practical applications.
We are happy to introduce Next.js 5.1, which features support for environment configuration, phases, source maps, and new Next.js plugins.
How It Works
Some next-plugins like @zeit/next-css are only required when Next.js is in development mode or when running next build. You can now export a function that returns the configuration object instead of immediately exporting the object. module.exports = (phase, { defaultConfig }) => config;
next.config.js exporting a function that returns
the user configuration Exporting a function will give you access to the phase in which Next.js is running, for e
General
Previously Next.js had a special error handling mechanism for detecting server errors when loading page bundles. A page bundle is the javascript file that is loaded on the client side to load the page, for example /_next/-/page/index.js. If there were an error, like a build ID mismatch, the page bundle would still be served with a 200 HTTP status, but the contents would be a JSON representation of an error generated by the Next.js server. The rea
General
With the introduction of universal webpack in Next.js 5 adding source maps to your production environment became as simple as adding a few lines to next.config.js: module.exports = {
webpack(config, { dev }) {
if (!dev) {
config.devtool = 'source-map';
for (const plugin of config.plugins) {
if (plugin['constructor']['name'] === 'UglifyJsPlugin') {
plugin.options.sourceMap = true;
break;
}
General
We've introduced two new official plugins. @zeit/next-bundle-analyzer allows for easily setting up webpack-bundle-analyzer to analyze the server side and client side bundles separately. Additionally there were a lot of improvements to the official css, less, and sass plugins regarding hot reloading and bundling. For example there is no longer a flash of unstyled content in development mode. And styles in subcomponents get picked up as well.