Adds possibilty to analyze client and server bundle size (#677)

This commit is contained in:
Omar López 2021-09-29 08:36:58 -06:00 committed by GitHub
parent 4a07c27da5
commit e7314257c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 79 additions and 5 deletions

View File

@ -2,6 +2,10 @@
const withTM = require("next-transpile-modules")(["react-timezone-select"]);
const { i18n } = require("./next-i18next.config");
const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: process.env.ANALYZE === "true",
});
// So we can test deploy previews preview
if (process.env.VERCEL_URL && !process.env.BASE_URL) {
process.env.BASE_URL = "https://" + process.env.VERCEL_URL;
@ -42,7 +46,10 @@ if (process.env.GOOGLE_API_CREDENTIALS && !validJson(process.env.GOOGLE_API_CRED
);
}
module.exports = withTM({
const plugins = [withBundleAnalyzer, withTM];
// prettier-ignore
module.exports = () => plugins.reduce((acc, next) => next(acc), {
i18n,
eslint: {
// This allows production builds to successfully complete even if the project has ESLint errors.

View File

@ -3,6 +3,9 @@
"version": "1.0.0",
"private": true,
"scripts": {
"analyze": "ANALYZE=true next build",
"analyze:server": "BUNDLE_ANALYZE=server next build",
"analyze:browser": "BUNDLE_ANALYZE=browser next build",
"dev": "next dev",
"db-up": "docker-compose up -d",
"db-migrate": "yarn prisma migrate dev",
@ -85,6 +88,7 @@
"zod": "^3.8.2"
},
"devDependencies": {
"@next/bundle-analyzer": "11.1.2",
"@trivago/prettier-plugin-sort-imports": "2.0.4",
"@types/async": "^3.2.7",
"@types/bcryptjs": "^2.4.2",

View File

@ -763,6 +763,13 @@
require_optional "^1.0.1"
typeorm "^0.2.30"
"@next/bundle-analyzer@11.1.2":
version "11.1.2"
resolved "https://registry.yarnpkg.com/@next/bundle-analyzer/-/bundle-analyzer-11.1.2.tgz#7892c86f58028399000f402a5c7ca8aecb65686f"
integrity sha512-gDQ+tG8S+7fEL2NqubhZRFvQEYB4tKavTqONHDqSVxBMZ8sSzm12IzF2zZDIXdnrMzD90wmIZFUjC0EFnoHMSg==
dependencies:
webpack-bundle-analyzer "4.3.0"
"@next/env@11.1.2":
version "11.1.2"
resolved "https://registry.npmjs.org/@next/env/-/env-11.1.2.tgz"
@ -872,6 +879,11 @@
version "1.0.0"
resolved "https://registry.npmjs.org/@panva/asn1.js/-/asn1.js-1.0.0.tgz"
"@polka/url@^1.0.0-next.20":
version "1.0.0-next.20"
resolved "https://registry.yarnpkg.com/@polka/url/-/url-1.0.0-next.20.tgz#111b5db0f501aa89b05076fa31f0ea0e0c292cd3"
integrity sha512-88p7+M0QGxKpmnkfXjS4V26AnoC/eiqZutE8GLdaI5X12NY75bXSdTY9NkmYb2Xyk1O+MmkuO6Frmsj84V6I8Q==
"@prisma/client@^2.30.2":
version "2.30.3"
resolved "https://registry.npmjs.org/@prisma/client/-/client-2.30.3.tgz"
@ -1703,7 +1715,7 @@ acorn-walk@^7.0.0, acorn-walk@^7.1.1:
version "7.2.0"
resolved "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.2.0.tgz"
acorn-walk@^8.1.1:
acorn-walk@^8.0.0, acorn-walk@^8.1.1:
version "8.2.0"
resolved "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz"
@ -1711,7 +1723,7 @@ acorn@^7.0.0, acorn@^7.1.1, acorn@^7.4.0:
version "7.4.1"
resolved "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz"
acorn@^8.2.4, acorn@^8.4.1:
acorn@^8.0.4, acorn@^8.2.4, acorn@^8.4.1:
version "8.5.0"
resolved "https://registry.npmjs.org/acorn/-/acorn-8.5.0.tgz"
@ -2487,7 +2499,7 @@ commander@^5.1.0:
version "5.1.0"
resolved "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz"
commander@^6.0.0:
commander@^6.0.0, commander@^6.2.0:
version "6.2.1"
resolved "https://registry.npmjs.org/commander/-/commander-6.2.1.tgz"
@ -2905,6 +2917,11 @@ dotenv@^8.2.0:
version "8.6.0"
resolved "https://registry.npmjs.org/dotenv/-/dotenv-8.6.0.tgz"
duplexer@^0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.2.tgz#3abe43aef3835f8ae077d136ddce0f276b0400e6"
integrity sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg==
ecc-jsbn@~0.1.1:
version "0.1.2"
resolved "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz"
@ -3646,6 +3663,13 @@ gtoken@^5.0.4:
google-p12-pem "^3.0.3"
jws "^4.0.0"
gzip-size@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/gzip-size/-/gzip-size-6.0.0.tgz#065367fd50c239c0671cbcbad5be3e2eeb10e462"
integrity sha512-ax7ZYomf6jqPTQ4+XCpUGyXKHk5WweS+e05MBO4/y3WJ5RkmPXNKvX+bx1behVILVwr6JSQvZAku021CHPXG3Q==
dependencies:
duplexer "^0.1.2"
handlebars@^4.7.7:
version "4.7.7"
resolved "https://registry.npmjs.org/handlebars/-/handlebars-4.7.7.tgz"
@ -5091,6 +5115,11 @@ mime-types@^2.1.12, mime-types@~2.1.19:
dependencies:
mime-db "1.49.0"
mime@^2.3.1:
version "2.5.2"
resolved "https://registry.yarnpkg.com/mime/-/mime-2.5.2.tgz#6e3dc6cc2b9510643830e5f19d5cb753da5eeabe"
integrity sha512-tqkh47FzKeCPD2PUiPB6pkbMzsCasjxAfC62/Wap5qrUWcb+sFasXUC5I3gYM5iBM8v/Qpn4UK0x+j0iHyFPDg==
mimic-fn@^2.1.0:
version "2.1.0"
resolved "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz"
@ -5458,6 +5487,11 @@ onetime@^5.1.0, onetime@^5.1.2:
dependencies:
mimic-fn "^2.1.0"
opener@^1.5.2:
version "1.5.2"
resolved "https://registry.yarnpkg.com/opener/-/opener-1.5.2.tgz#5d37e1f35077b9dcac4301372271afdeb2a13598"
integrity sha512-ur5UIdyw5Y7yEj9wLzhqXiy6GZ3Mwx0yGI+5sMn2r0N0v3cKJvUmFH5yPP+WXh9e0xfyzyJX95D8l088DNFj7A==
optionator@^0.8.1:
version "0.8.3"
resolved "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz"
@ -6410,6 +6444,15 @@ simple-swizzle@^0.2.2:
dependencies:
is-arrayish "^0.3.1"
sirv@^1.0.7:
version "1.0.17"
resolved "https://registry.yarnpkg.com/sirv/-/sirv-1.0.17.tgz#86e2c63c612da5a1dace1c16c46f524aaa26ac45"
integrity sha512-qx9go5yraB7ekT7bCMqUHJ5jEaOC/GXBxUWv+jeWnb7WzHUFdcQPGWk7YmAwFBaQBrogpuSqd/azbC2lZRqqmw==
dependencies:
"@polka/url" "^1.0.0-next.20"
mime "^2.3.1"
totalist "^1.0.0"
sisteransi@^1.0.5:
version "1.0.5"
resolved "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz"
@ -6866,6 +6909,11 @@ toposort@^2.0.2:
version "2.0.2"
resolved "https://registry.npmjs.org/toposort/-/toposort-2.0.2.tgz"
totalist@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/totalist/-/totalist-1.1.0.tgz#a4d65a3e546517701e3e5c37a47a70ac97fe56df"
integrity sha512-gduQwd1rOdDMGxFG1gEvhV88Oirdo2p+KjoYFU7k2g+i7n6AFFbDQ5kMPUsW0pNbfQsB/cwXvT1i4Bue0s9g5g==
tough-cookie@^4.0.0:
version "4.0.0"
resolved "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.0.0.tgz"
@ -7204,6 +7252,21 @@ webidl-conversions@^6.1.0:
version "6.1.0"
resolved "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-6.1.0.tgz"
webpack-bundle-analyzer@4.3.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/webpack-bundle-analyzer/-/webpack-bundle-analyzer-4.3.0.tgz#2f3c0ca9041d5ee47fa418693cf56b4a518b578b"
integrity sha512-J3TPm54bPARx6QG8z4cKBszahnUglcv70+N+8gUqv2I5KOFHJbzBiLx+pAp606so0X004fxM7hqRu10MLjJifA==
dependencies:
acorn "^8.0.4"
acorn-walk "^8.0.0"
chalk "^4.1.0"
commander "^6.2.0"
gzip-size "^6.0.0"
lodash "^4.17.20"
opener "^1.5.2"
sirv "^1.0.7"
ws "^7.3.1"
whatwg-encoding@^1.0.5:
version "1.0.5"
resolved "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-1.0.5.tgz"
@ -7313,7 +7376,7 @@ write-file-atomic@^3.0.0:
signal-exit "^3.0.2"
typedarray-to-buffer "^3.1.5"
ws@^7.4.6:
ws@^7.3.1, ws@^7.4.6:
version "7.5.5"
resolved "https://registry.npmjs.org/ws/-/ws-7.5.5.tgz"