From 38cd5b933a314f5aa8d0acb2c158f3f60f833539 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Orb=C3=A1n?= Date: Thu, 23 Dec 2021 22:56:21 +0100 Subject: [PATCH 1/2] fix: use --- .../next.config.js | 18 ++++-------------- .../package.json | 7 +++---- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/examples/with-webpack-bundle-size-analyzer/next.config.js b/examples/with-webpack-bundle-size-analyzer/next.config.js index eb7b76c963823..734b2514b3160 100644 --- a/examples/with-webpack-bundle-size-analyzer/next.config.js +++ b/examples/with-webpack-bundle-size-analyzer/next.config.js @@ -1,14 +1,4 @@ -const { - WebpackBundleSizeAnalyzerPlugin, -} = require('webpack-bundle-size-analyzer') -const { ANALYZE } = process.env - -module.exports = { - webpack: function (config) { - if (ANALYZE) { - config.plugins.push(new WebpackBundleSizeAnalyzerPlugin('stats.txt')) - } - - return config - }, -} +const withBundleAnalyzer = require('@next/bundle-analyzer')({ + enabled: process.env.ANALYZE === 'true', +}) +module.exports = withBundleAnalyzer({}) diff --git a/examples/with-webpack-bundle-size-analyzer/package.json b/examples/with-webpack-bundle-size-analyzer/package.json index ebf2bfec9b82a..f7034df036adb 100644 --- a/examples/with-webpack-bundle-size-analyzer/package.json +++ b/examples/with-webpack-bundle-size-analyzer/package.json @@ -4,14 +4,13 @@ "dev": "next", "build": "next build", "start": "next start", - "analyze": "cross-env ANALYZE=1 next build && cat .next/stats.txt" + "analyze": "cross-env ANALYZE=true next build" }, "dependencies": { "cross-env": "^5.0.1", - "faker": "^4.1.0", + "@next/bundle-analyzer": "latest", "next": "latest", "react": "^17.0.2", - "react-dom": "^17.0.2", - "webpack-bundle-size-analyzer": "^2.7.0" + "react-dom": "^17.0.2" } } From 0bcf8dfea38be65fbc05411ca55178dd874c5e6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Orb=C3=A1n?= Date: Thu, 23 Dec 2021 22:57:45 +0100 Subject: [PATCH 2/2] fix: remove duplicate examples --- .../with-webpack-bundle-analyzer/.gitignore | 34 ------------------- .../with-webpack-bundle-analyzer/README.md | 3 -- .../.gitignore | 34 ------------------- .../README.md | 29 ---------------- .../next.config.js | 4 --- .../package.json | 16 --------- .../pages/about.js | 31 ----------------- .../pages/contact.js | 3 -- .../pages/index.js | 31 ----------------- 9 files changed, 185 deletions(-) delete mode 100644 examples/with-webpack-bundle-analyzer/.gitignore delete mode 100644 examples/with-webpack-bundle-analyzer/README.md delete mode 100644 examples/with-webpack-bundle-size-analyzer/.gitignore delete mode 100644 examples/with-webpack-bundle-size-analyzer/README.md delete mode 100644 examples/with-webpack-bundle-size-analyzer/next.config.js delete mode 100644 examples/with-webpack-bundle-size-analyzer/package.json delete mode 100644 examples/with-webpack-bundle-size-analyzer/pages/about.js delete mode 100644 examples/with-webpack-bundle-size-analyzer/pages/contact.js delete mode 100644 examples/with-webpack-bundle-size-analyzer/pages/index.js diff --git a/examples/with-webpack-bundle-analyzer/.gitignore b/examples/with-webpack-bundle-analyzer/.gitignore deleted file mode 100644 index 1437c53f70bc2..0000000000000 --- a/examples/with-webpack-bundle-analyzer/.gitignore +++ /dev/null @@ -1,34 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.js - -# testing -/coverage - -# next.js -/.next/ -/out/ - -# production -/build - -# misc -.DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# local env files -.env.local -.env.development.local -.env.test.local -.env.production.local - -# vercel -.vercel diff --git a/examples/with-webpack-bundle-analyzer/README.md b/examples/with-webpack-bundle-analyzer/README.md deleted file mode 100644 index 67387496d7e30..0000000000000 --- a/examples/with-webpack-bundle-analyzer/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Webpack Bundle Analyzer example - -This example have been moved here: [analyze-bundles](https://github.com/vercel/next.js/tree/canary/examples/analyze-bundles) diff --git a/examples/with-webpack-bundle-size-analyzer/.gitignore b/examples/with-webpack-bundle-size-analyzer/.gitignore deleted file mode 100644 index 1437c53f70bc2..0000000000000 --- a/examples/with-webpack-bundle-size-analyzer/.gitignore +++ /dev/null @@ -1,34 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.js - -# testing -/coverage - -# next.js -/.next/ -/out/ - -# production -/build - -# misc -.DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# local env files -.env.local -.env.development.local -.env.test.local -.env.production.local - -# vercel -.vercel diff --git a/examples/with-webpack-bundle-size-analyzer/README.md b/examples/with-webpack-bundle-size-analyzer/README.md deleted file mode 100644 index 5090527955457..0000000000000 --- a/examples/with-webpack-bundle-size-analyzer/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# Webpack Bundle Size Analyzer - -This example shows how to analyze the output bundles using [webpack-bundle-size-analyzer](https://www.npmjs.com/package/webpack-bundle-size-analyzer) - -## Preview - -Preview the example live on [StackBlitz](http://stackblitz.com/): - -[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/vercel/next.js/tree/canary/examples/with-webpack-bundle-size-analyzer) - -## How to use - -Execute [`create-next-app`](https://github.com/vercel/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 -npx create-next-app --example with-webpack-bundle-size-analyzer with-webpack-bundle-size-analyzer-app -# or -yarn create next-app --example with-webpack-bundle-size-analyzer with-webpack-bundle-size-analyzer-app -``` - -## Notes - -To analyze your webpack output, invoke the following command: - -```bash -npm run analyze -# or -yarn analyze -``` diff --git a/examples/with-webpack-bundle-size-analyzer/next.config.js b/examples/with-webpack-bundle-size-analyzer/next.config.js deleted file mode 100644 index 734b2514b3160..0000000000000 --- a/examples/with-webpack-bundle-size-analyzer/next.config.js +++ /dev/null @@ -1,4 +0,0 @@ -const withBundleAnalyzer = require('@next/bundle-analyzer')({ - enabled: process.env.ANALYZE === 'true', -}) -module.exports = withBundleAnalyzer({}) diff --git a/examples/with-webpack-bundle-size-analyzer/package.json b/examples/with-webpack-bundle-size-analyzer/package.json deleted file mode 100644 index f7034df036adb..0000000000000 --- a/examples/with-webpack-bundle-size-analyzer/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "private": true, - "scripts": { - "dev": "next", - "build": "next build", - "start": "next start", - "analyze": "cross-env ANALYZE=true next build" - }, - "dependencies": { - "cross-env": "^5.0.1", - "@next/bundle-analyzer": "latest", - "next": "latest", - "react": "^17.0.2", - "react-dom": "^17.0.2" - } -} diff --git a/examples/with-webpack-bundle-size-analyzer/pages/about.js b/examples/with-webpack-bundle-size-analyzer/pages/about.js deleted file mode 100644 index 76a9fb7cdc294..0000000000000 --- a/examples/with-webpack-bundle-size-analyzer/pages/about.js +++ /dev/null @@ -1,31 +0,0 @@ -import Link from 'next/link' -import faker from 'faker' - -const About = ({ name }) => { - return ( -
-

About Page

-

Welcome, {name}.

-

- This page is using getStaticProps, so the name will always be {name}{' '} - even if you reload the page. -

-
- - Home Page - -
-
- ) -} - -export async function getStaticProps() { - const name = faker.name.findName() - return { - props: { - name, - }, - } -} - -export default About diff --git a/examples/with-webpack-bundle-size-analyzer/pages/contact.js b/examples/with-webpack-bundle-size-analyzer/pages/contact.js deleted file mode 100644 index c3dcb2c564907..0000000000000 --- a/examples/with-webpack-bundle-size-analyzer/pages/contact.js +++ /dev/null @@ -1,3 +0,0 @@ -export default function Contact() { - return
This is the contact page.
-} diff --git a/examples/with-webpack-bundle-size-analyzer/pages/index.js b/examples/with-webpack-bundle-size-analyzer/pages/index.js deleted file mode 100644 index f29d9fb4bf12c..0000000000000 --- a/examples/with-webpack-bundle-size-analyzer/pages/index.js +++ /dev/null @@ -1,31 +0,0 @@ -import Link from 'next/link' -import faker from 'faker' - -const Index = ({ name }) => { - return ( -
-

Home Page

-

Welcome, {name}.

-

- This page is using getServerSideProps, so the name will be different - every time the page is rendered. -

-
- - About Page - -
-
- ) -} - -export async function getServerSideProps() { - const name = faker.name.findName() - return { - props: { - name, - }, - } -} - -export default Index