From b1ea1475942be77a5bf343683d3c2865c9a3b362 Mon Sep 17 00:00:00 2001 From: Luis Alvarez Date: Mon, 17 Feb 2020 18:49:51 -0500 Subject: [PATCH] Update readme and remove example files --- examples/with-polyfills/README.md | 45 +-------------------- examples/with-polyfills/client/polyfills.js | 13 ------ examples/with-polyfills/next.config.js | 19 --------- examples/with-polyfills/package.json | 14 ------- examples/with-polyfills/pages/index.js | 3 -- 5 files changed, 1 insertion(+), 93 deletions(-) delete mode 100644 examples/with-polyfills/client/polyfills.js delete mode 100644 examples/with-polyfills/next.config.js delete mode 100644 examples/with-polyfills/package.json delete mode 100644 examples/with-polyfills/pages/index.js diff --git a/examples/with-polyfills/README.md b/examples/with-polyfills/README.md index e0dfcd78f6e3..4980064017b3 100644 --- a/examples/with-polyfills/README.md +++ b/examples/with-polyfills/README.md @@ -1,44 +1 @@ -# Example app with polyfills - -Next.js supports browsers from IE10 to the latest. It adds polyfills as they need. But Next.js cannot add polyfills for code inside NPM modules. So sometimes, you need to add polyfills by yourself. - -This how you can do it easily with Next.js's custom webpack config feature. - -## Deploy your own - -Deploy the example using [ZEIT Now](https://zeit.co/now): - -[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/next.js/tree/canary/examples/with-polyfills) - -## How to use - -### Using `create-next-app` - -Execute [`create-next-app`](https://github.com/zeit/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init) or [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) to bootstrap the example: - -```bash -npm init next-app --example with-polyfills with-polyfills-app -# or -yarn create next-app --example with-polyfills with-polyfills-app -``` - -### Download manually - -Download the example: - -```bash -curl https://codeload.github.com/zeit/next.js/tar.gz/master | tar -xz --strip=2 next.js-master/examples/with-polyfills -cd with-polyfills -``` - -Install it and run: - -```bash -npm install -npm run dev -# or -yarn -yarn dev -``` - -Deploy it to the cloud with [ZEIT Now](https://zeit.co/new?filter=next.js&utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)). +This example has been deprecated and removed in favor of Next.js polyfills chunk ([#10212](https://github.com/zeit/next.js/pull/10212)), which does a better work at identifying the required polyfills for non-modern browsers. diff --git a/examples/with-polyfills/client/polyfills.js b/examples/with-polyfills/client/polyfills.js deleted file mode 100644 index 9ac9779f40f8..000000000000 --- a/examples/with-polyfills/client/polyfills.js +++ /dev/null @@ -1,13 +0,0 @@ -/* eslint no-extend-native: 0 */ -// core-js comes with Next.js. So, you can import it like below -import includes from 'core-js/library/fn/string/virtual/includes' -import repeat from 'core-js/library/fn/string/virtual/repeat' -import assign from 'core-js/library/fn/object/assign' - -// Add your polyfills -// This files runs at the very beginning (even before React and Next.js core) -console.log('Load your polyfills') - -String.prototype.includes = includes -String.prototype.repeat = repeat -Object.assign = assign diff --git a/examples/with-polyfills/next.config.js b/examples/with-polyfills/next.config.js deleted file mode 100644 index 3c845eee6cb3..000000000000 --- a/examples/with-polyfills/next.config.js +++ /dev/null @@ -1,19 +0,0 @@ -module.exports = { - webpack: function(cfg) { - const originalEntry = cfg.entry - cfg.entry = async () => { - const entries = await originalEntry() - - if ( - entries['main.js'] && - !entries['main.js'].includes('./client/polyfills.js') - ) { - entries['main.js'].unshift('./client/polyfills.js') - } - - return entries - } - - return cfg - }, -} diff --git a/examples/with-polyfills/package.json b/examples/with-polyfills/package.json deleted file mode 100644 index b98ad551a8e6..000000000000 --- a/examples/with-polyfills/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "with-polyfills", - "version": "1.0.0", - "scripts": { - "dev": "next", - "build": "next build", - "start": "next start" - }, - "dependencies": { - "next": "latest", - "react": "^16.7.0", - "react-dom": "^16.7.0" - } -} diff --git a/examples/with-polyfills/pages/index.js b/examples/with-polyfills/pages/index.js deleted file mode 100644 index 835481d065b0..000000000000 --- a/examples/with-polyfills/pages/index.js +++ /dev/null @@ -1,3 +0,0 @@ -console.log('Inside the /index.js page') - -export default () =>
Hello World