From 8b48508ce8cbbe65be24d2190c05037833636886 Mon Sep 17 00:00:00 2001 From: Rafael Almeida Date: Thu, 17 Oct 2019 02:08:03 -0300 Subject: [PATCH] Remove inferno example (#9108) --- examples/using-inferno/README.md | 49 -------------------- examples/using-inferno/lib/inferno-compat.js | 11 ----- examples/using-inferno/next.config.js | 20 -------- examples/using-inferno/package.json | 20 -------- examples/using-inferno/pages/about.js | 3 -- examples/using-inferno/pages/index.js | 11 ----- examples/using-inferno/server.js | 29 ------------ 7 files changed, 143 deletions(-) delete mode 100644 examples/using-inferno/README.md delete mode 100644 examples/using-inferno/lib/inferno-compat.js delete mode 100644 examples/using-inferno/next.config.js delete mode 100644 examples/using-inferno/package.json delete mode 100644 examples/using-inferno/pages/about.js delete mode 100644 examples/using-inferno/pages/index.js delete mode 100644 examples/using-inferno/server.js diff --git a/examples/using-inferno/README.md b/examples/using-inferno/README.md deleted file mode 100644 index 5671e91d0c..0000000000 --- a/examples/using-inferno/README.md +++ /dev/null @@ -1,49 +0,0 @@ -# Inferno example - -> **Important**: Inferno does not support hooks nor Suspense. It may work on development where React is utilized instead of Inferno, but it will break as soon as you try to build it or start it out of development. - -## How to use - -### Using `create-next-app` - -Execute [`create-next-app`](https://github.com/zeit/next.js/tree/canary/packages/create-next-app) with [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) or [npx](https://github.com/zkat/npx#readme) to bootstrap the example: - -```bash -npx create-next-app --example using-inferno using-inferno-app -# or -yarn create next-app --example using-inferno using-inferno-app -``` - -### Download manually - -Download the example: - -```bash -curl https://codeload.github.com/zeit/next.js/tar.gz/canary | tar -xz --strip=2 next.js-canary/examples/using-inferno -cd using-inferno -``` - -Install it and run: - -```bash -npm install -npm run dev -# or -yarn -yarn 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 uses [Inferno](https://github.com/infernojs/inferno), an insanely fast, 9kb React-like library for building high-performance user interfaces on both the client and server. Here we've customized Next.js to use Inferno instead of React in the production build. - -Here's how we did it: - -- Use `next.config.js` to customize our webpack config to support [inferno-compat](https://www.npmjs.com/package/inferno-compat) -- Create `lib/inferno-compat.js` to polyfill the `React.createContext` API (required by Next.js) that is not available by `inferno-compat` diff --git a/examples/using-inferno/lib/inferno-compat.js b/examples/using-inferno/lib/inferno-compat.js deleted file mode 100644 index e21320e5f6..0000000000 --- a/examples/using-inferno/lib/inferno-compat.js +++ /dev/null @@ -1,11 +0,0 @@ -const React = require('inferno-compat') -const createContext = require('create-react-context/lib/implementation') - -Object.keys(React).forEach(key => { - if (key === 'default' || key === '__esModule') return - exports[key] = React[key] -}) - -// bypass export of React.createContext -exports.createContext = createContext -exports.default = React.default diff --git a/examples/using-inferno/next.config.js b/examples/using-inferno/next.config.js deleted file mode 100644 index c4f32880fb..0000000000 --- a/examples/using-inferno/next.config.js +++ /dev/null @@ -1,20 +0,0 @@ -const path = require('path') - -module.exports = { - webpack: function (config, { dev }) { - // For the development version, we'll use React. - // Because, it support react hot loading and so on. - if (dev) { - return config - } - - config.resolve.alias = { - ...config.resolve.alias, - react: path.resolve('./lib/inferno-compat.js'), - 'react-dom': path.resolve('./lib/inferno-compat.js'), - 'react-dom/server': 'inferno-server' - } - - return config - } -} diff --git a/examples/using-inferno/package.json b/examples/using-inferno/package.json deleted file mode 100644 index 2f74fa7bf5..0000000000 --- a/examples/using-inferno/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "using-inferno", - "version": "1.0.0", - "scripts": { - "dev": "node server.js", - "build": "next build", - "start": "NODE_ENV=production node server.js" - }, - "dependencies": { - "create-react-context": "0.3.0", - "inferno": "7.3.2", - "inferno-compat": "7.3.2", - "inferno-server": "7.3.2", - "module-alias": "^2.0.0", - "next": "latest", - "react": "^16.7.0", - "react-dom": "^16.7.0" - }, - "license": "MIT" -} diff --git a/examples/using-inferno/pages/about.js b/examples/using-inferno/pages/about.js deleted file mode 100644 index f89b580228..0000000000 --- a/examples/using-inferno/pages/about.js +++ /dev/null @@ -1,3 +0,0 @@ -import React from 'react' - -export default () =>
About us
diff --git a/examples/using-inferno/pages/index.js b/examples/using-inferno/pages/index.js deleted file mode 100644 index a136ee0b5a..0000000000 --- a/examples/using-inferno/pages/index.js +++ /dev/null @@ -1,11 +0,0 @@ -import React from 'react' -import Link from 'next/link' - -export default () => ( -
- Hello World.{' '} - - About - -
-) diff --git a/examples/using-inferno/server.js b/examples/using-inferno/server.js deleted file mode 100644 index 0e351d2cc4..0000000000 --- a/examples/using-inferno/server.js +++ /dev/null @@ -1,29 +0,0 @@ -const port = parseInt(process.env.PORT, 10) || 3000 -const dev = process.env.NODE_ENV !== 'production' -const moduleAlias = require('module-alias') -const path = require('path') - -// For the development version, we'll use React. -// Because, it support react hot loading and so on. -if (!dev) { - moduleAlias.addAlias('react', path.resolve('./lib/inferno-compat.js')) - moduleAlias.addAlias('react-dom/server', 'inferno-server') - moduleAlias.addAlias('react-dom', path.resolve('./lib/inferno-compat.js')) -} - -const { createServer } = require('http') -const { parse } = require('url') -const next = require('next') - -const app = next({ dev }) -const handle = app.getRequestHandler() - -app.prepare().then(() => { - createServer((req, res) => { - const parsedUrl = parse(req.url, true) - handle(req, res, parsedUrl) - }).listen(port, err => { - if (err) throw err - console.log(`> Ready on http://localhost:${port}`) - }) -}) -- GitLab