Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Next.js to 9.4.0 #13

Merged
merged 1 commit into from
May 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
},
"cSpell.words": [
"browserconfig",
"camelcase",
"destructure",
"etags",
"favicons",
Expand Down
3 changes: 0 additions & 3 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const TsconfigPathsWebpackPlugin = require("tsconfig-paths-webpack-plugin");
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");

const redirects = () => [
Expand Down Expand Up @@ -40,8 +39,6 @@ module.exports = {
generateEtags: false,
poweredByHeader: false,
webpack: (config, options) => {
config.resolve.plugins.push(new TsconfigPathsWebpackPlugin());

if (process.env.RUN_WEBPACK_BUNDLE_ANALYZER === "true") {
config.plugins.push(
new BundleAnalyzerPlugin({
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@
"app-manifest-loader": "^2.4.1",
"babel-plugin-emotion": "^10.0.33",
"file-loader": "^4.3.0",
"next": "^9.3.5",
"next": "^9.4.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"tsconfig-paths-webpack-plugin": "^3.2.0",
"typescript": "^3.8.3",
"webpack": "^4.43.0",
"webpack-bundle-analyzer": "^3.7.0"
Expand Down
71 changes: 2 additions & 69 deletions src/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,81 +3,14 @@
import Document, { Head, Html, Main, NextScript } from "next/document";
import React from "react";

const isDevelopment = process.env.NODE_ENV === "development";

/* eslint-disable */

class CustomHead extends Head {
render() {
const { styles } = this.context._documentProps;

let { head } = this.context._documentProps;
let children = this.props.children;
// show a warning if Head contains <title> (only in development)
if (process.env.NODE_ENV !== 'production') {
children = React.Children.map(children, (child: any) => {
const isReactHelmet =
child && child.props && child.props['data-react-helmet'];
if (child && child.type === 'title' && !isReactHelmet) {
console.warn(
"Warning: <title> should not be used in _document.js’s <Head>. https://err.sh/next.js/no-document-title",
);
}
return child;
});
if (this.props.crossOrigin)
console.warn(
'Warning: `Head` attribute `crossOrigin` is deprecated. https://err.sh/next.js/doc-crossorigin-deprecated',
);
}

// try to parse styles from fragment for backwards compat
const curStyles: React.ReactElement[] = Array.isArray(styles)
? (styles as React.ReactElement[])
: [];
if (
styles &&
// @ts-ignore Property 'props' does not exist on type ReactElement
styles.props &&
// @ts-ignore Property 'props' does not exist on type ReactElement
Array.isArray(styles.props.children)
) {
const hasStyles = (el: React.ReactElement) =>
el &&
el.props &&
el.props.dangerouslySetInnerHTML &&
el.props.dangerouslySetInnerHTML.__html;
// @ts-ignore Property 'props' does not exist on type ReactElement
styles.props.children.map((child: React.ReactElement) => {
if (Array.isArray(child)) {
child.map((el) => hasStyles(el) && curStyles.push(el));
} else if (hasStyles(child)) {
curStyles.push(child);
}
});
}

return (
<head {...this.props}>
{children}
{head}
{this.getCssLinks()}
{styles || null}
</head>
);
}
}

/* eslint-enable */

class MyDocument extends Document {
render() {
return (
<Html lang="en-CA" dir="ltr">
{isDevelopment ? <Head /> : <CustomHead />}
<Head />
<body>
<Main />
{isDevelopment && <NextScript />}
<NextScript />
</body>
</Html>
);
Expand Down
6 changes: 6 additions & 0 deletions src/pages/_error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,10 @@ const Error: FunctionComponent = () => (
</Page>
);

export const config = {
// https://github.com/zeit/next.js/pull/11949
// eslint-disable-next-line @typescript-eslint/camelcase
unstable_runtimeJS: false,
};

export default Error;
6 changes: 6 additions & 0 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,10 @@ const Home: FunctionComponent = () => (
</Page>
);

export const config = {
// https://github.com/zeit/next.js/pull/11949
// eslint-disable-next-line @typescript-eslint/camelcase
unstable_runtimeJS: false,
};

export default Home;
Loading