From bff27710321ac984373514d0bb81cddd099a8c23 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Mon, 29 Jun 2020 16:08:27 +0200 Subject: [PATCH] Clean up plugins Preparation for a larger rewrite --- packages/next-plugin-material-ui/package.json | 17 ---------------- packages/next-plugin-material-ui/readme.md | 3 --- .../src/document-head-tags-server.js | 17 ---------------- .../src/unstable-enhance-app-server.js | 7 ------- .../src/unstable-get-styles-server.js | 3 --- .../src/unstable-post-hydration.js | 7 ------- .../next/build/plugins/collect-plugins.ts | 3 --- packages/next/client/index.js | 14 ------------- packages/next/pages/_document.tsx | 20 +------------------ 9 files changed, 1 insertion(+), 90 deletions(-) delete mode 100644 packages/next-plugin-material-ui/package.json delete mode 100644 packages/next-plugin-material-ui/readme.md delete mode 100644 packages/next-plugin-material-ui/src/document-head-tags-server.js delete mode 100644 packages/next-plugin-material-ui/src/unstable-enhance-app-server.js delete mode 100644 packages/next-plugin-material-ui/src/unstable-get-styles-server.js delete mode 100644 packages/next-plugin-material-ui/src/unstable-post-hydration.js diff --git a/packages/next-plugin-material-ui/package.json b/packages/next-plugin-material-ui/package.json deleted file mode 100644 index 9fca04c6ad018..0000000000000 --- a/packages/next-plugin-material-ui/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "@next/plugin-material-ui", - "version": "9.4.5-canary.22", - "repository": { - "url": "vercel/next.js", - "directory": "packages/next-plugin-material-ui" - }, - "nextjs": { - "name": "Material UI", - "required-env": [] - }, - "peerDependencies": { - "@material-ui/styles": "*", - "next": "*", - "react": "*" - } -} diff --git a/packages/next-plugin-material-ui/readme.md b/packages/next-plugin-material-ui/readme.md deleted file mode 100644 index dd01503074746..0000000000000 --- a/packages/next-plugin-material-ui/readme.md +++ /dev/null @@ -1,3 +0,0 @@ -# Unstable @next/plugin-material-ui - -This package is still very experimental and should not be used at this point diff --git a/packages/next-plugin-material-ui/src/document-head-tags-server.js b/packages/next-plugin-material-ui/src/document-head-tags-server.js deleted file mode 100644 index fc91dc7aefaea..0000000000000 --- a/packages/next-plugin-material-ui/src/document-head-tags-server.js +++ /dev/null @@ -1,17 +0,0 @@ -import React from 'react' - -export default async function headTags() { - return ( - <> - - - - - ) -} diff --git a/packages/next-plugin-material-ui/src/unstable-enhance-app-server.js b/packages/next-plugin-material-ui/src/unstable-enhance-app-server.js deleted file mode 100644 index 531a864a7b215..0000000000000 --- a/packages/next-plugin-material-ui/src/unstable-enhance-app-server.js +++ /dev/null @@ -1,7 +0,0 @@ -import React from 'react' -import { ServerStyleSheets } from '@material-ui/styles' - -export default async function enhanceApp(ctx) { - ctx.sheets = new ServerStyleSheets() - return (App) => (props) => ctx.sheets.collect() -} diff --git a/packages/next-plugin-material-ui/src/unstable-get-styles-server.js b/packages/next-plugin-material-ui/src/unstable-get-styles-server.js deleted file mode 100644 index 68d9eaefe12c4..0000000000000 --- a/packages/next-plugin-material-ui/src/unstable-get-styles-server.js +++ /dev/null @@ -1,3 +0,0 @@ -export default async function getStyles(ctx) { - return ctx.sheets.getStyleElement() -} diff --git a/packages/next-plugin-material-ui/src/unstable-post-hydration.js b/packages/next-plugin-material-ui/src/unstable-post-hydration.js deleted file mode 100644 index 0aed41d517a84..0000000000000 --- a/packages/next-plugin-material-ui/src/unstable-post-hydration.js +++ /dev/null @@ -1,7 +0,0 @@ -export default async function unstablePostHydration() { - // Remove the server-side injected CSS. - const jssStyles = document.querySelector('#jss-server-side') - if (jssStyles) { - jssStyles.parentNode.removeChild(jssStyles) - } -} diff --git a/packages/next/build/plugins/collect-plugins.ts b/packages/next/build/plugins/collect-plugins.ts index e0d80e3951eeb..2c4b036afe39d 100644 --- a/packages/next/build/plugins/collect-plugins.ts +++ b/packages/next/build/plugins/collect-plugins.ts @@ -24,9 +24,6 @@ export const VALID_MIDDLEWARE = [ 'on-error-client', 'on-error-server', 'babel-preset-build', - 'unstable-post-hydration', - 'unstable-get-styles-server', - 'unstable-enhance-app-server', ] type ENV_OPTIONS = { [name: string]: string } diff --git a/packages/next/client/index.js b/packages/next/client/index.js index 9dae7d78ae445..56b6f598a253c 100644 --- a/packages/next/client/index.js +++ b/packages/next/client/index.js @@ -79,20 +79,6 @@ class Container extends React.Component { componentDidMount() { this.scrollToHash() - if (process.env.__NEXT_PLUGINS) { - // eslint-disable-next-line - import('next-plugin-loader?middleware=unstable-post-hydration!') - .then((mod) => { - return mod.default() - }) - .catch((postHydrationErr) => { - console.error( - 'Error calling post-hydration for plugins', - postHydrationErr - ) - }) - } - // We need to replace the router state if: // - the page was (auto) exported and has a query string or search (hash) // - it was auto exported and is a dynamic route (to provide params) diff --git a/packages/next/pages/_document.tsx b/packages/next/pages/_document.tsx index 69019a9bd792e..1e61f6e4f1612 100644 --- a/packages/next/pages/_document.tsx +++ b/packages/next/pages/_document.tsx @@ -56,30 +56,12 @@ export default class Document

extends Component { static async getInitialProps( ctx: DocumentContext ): Promise { - const enhancers = process.env.__NEXT_PLUGINS - ? await import( - // @ts-ignore loader syntax - 'next-plugin-loader?middleware=unstable-enhance-app-server!' - ).then((mod) => mod.default(ctx)) - : [] - const enhanceApp = (App: any) => { - for (const enhancer of enhancers) { - App = enhancer(App) - } return (props: any) => } const { html, head } = await ctx.renderPage({ enhanceApp }) - const styles = [ - ...flush(), - ...(process.env.__NEXT_PLUGINS - ? await import( - // @ts-ignore loader syntax - 'next-plugin-loader?middleware=unstable-get-styles-server!' - ).then((mod) => mod.default(ctx)) - : []), - ] + const styles = [...flush()] return { html, head, styles } }