diff --git a/packages/vite/LICENSE.md b/packages/vite/LICENSE.md index 4f4fce0f20bf52..39b2190d9a680b 100644 --- a/packages/vite/LICENSE.md +++ b/packages/vite/LICENSE.md @@ -25,7 +25,7 @@ SOFTWARE. # Licenses of bundled dependencies The published Vite artifact additionally contains code with the following licenses: -Apache-2.0, BSD-2-Clause, BSD-3-Clause, CC0-1.0, ISC, MIT, (BSD-3-Clause OR GPL-2.0), (MIT) +Apache-2.0, BSD-2-Clause, BSD-3-Clause, CC0-1.0, ISC, MIT, (BSD-3-Clause OR GPL-2.0) # Bundled dependencies: ## @ampproject/remapping @@ -1016,35 +1016,6 @@ Repository: micromatch/braces --------------------------------------- -## brotli-size -License: MIT -By: Erwin Mombay -Repository: erwinmombay/brotli-size - -> The MIT License (MIT) -> -> Copyright (c) Erwin Mombay -> -> Permission is hereby granted, free of charge, to any person obtaining a copy of -> this software and associated documentation files (the "Software"), to deal in -> the Software without restriction, including without limitation the rights to -> use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -> of the Software, and to permit persons to whom the Software is furnished to do -> so, subject to the following conditions: -> -> The above copyright notice and this permission notice shall be included in all -> copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -> SOFTWARE. - ---------------------------------------- - ## builtin-modules License: MIT By: Sindre Sorhus @@ -1703,13 +1674,6 @@ By: motdotla --------------------------------------- -## duplexer -License: (MIT) -By: Raynos, Jake Verbaten -Repository: git://github.com/Raynos/duplexer.git - ---------------------------------------- - ## ee-first License: MIT By: Jonathan Ong, Douglas Christopher Wilson diff --git a/packages/vite/package.json b/packages/vite/package.json index 029df402b43ca4..49a43f01a2cb0e 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -80,7 +80,6 @@ "acorn": "^8.5.0", "acorn-class-fields": "^1.0.0", "acorn-static-class-features": "^1.0.0", - "brotli-size": "^4.0.0", "builtin-modules": "^3.2.0", "cac": "^6.7.3", "chalk": "^4.1.2", diff --git a/packages/vite/src/node/build.ts b/packages/vite/src/node/build.ts index da1a80664c7e8e..465efee7e2a21e 100644 --- a/packages/vite/src/node/build.ts +++ b/packages/vite/src/node/build.ts @@ -184,9 +184,15 @@ export interface BuildOptions { * directives in production. */ ssrManifest?: boolean + /** + * Set to false to disable reporting compressed chunk sizes. + * Can slightly improve build speed. + */ + reportCompressedSize?: boolean /** * Set to false to disable brotli compressed size reporting for build. * Can slightly improve build speed. + * @deprecated use `build.reportCompressedSize` instead. */ brotliSize?: boolean /** @@ -211,7 +217,11 @@ export interface LibraryOptions { export type LibraryFormats = 'es' | 'cjs' | 'umd' | 'iife' export type ResolvedBuildOptions = Required< - Omit + Omit< + BuildOptions, + // make deprecated options optional + 'base' | 'cleanCssOptions' | 'polyfillDynamicImport' | 'brotliSize' + > > export function resolveBuildOptions(raw?: BuildOptions): ResolvedBuildOptions { @@ -242,7 +252,8 @@ export function resolveBuildOptions(raw?: BuildOptions): ResolvedBuildOptions { lib: false, ssr: false, ssrManifest: false, - brotliSize: true, + reportCompressedSize: true, + // brotliSize: true, chunkSizeWarningLimit: 500, watch: null, ...raw diff --git a/packages/vite/src/node/plugins/reporter.ts b/packages/vite/src/node/plugins/reporter.ts index c55deb9c5caa79..d16aec2e564491 100644 --- a/packages/vite/src/node/plugins/reporter.ts +++ b/packages/vite/src/node/plugins/reporter.ts @@ -1,8 +1,9 @@ import path from 'path' import chalk from 'chalk' +import { gzip } from 'zlib' +import { promisify } from 'util' import { Plugin } from 'rollup' import { ResolvedConfig } from '../config' -import size from 'brotli-size' import { normalizePath } from '../utils' import { LogLevels } from '../logger' @@ -23,6 +24,7 @@ const writeColors = { } export function buildReporterPlugin(config: ResolvedConfig): Plugin { + const compress = promisify(gzip) const chunkLimit = config.build.chunkSizeWarningLimit function isLarge(code: string | Uint8Array): boolean { @@ -31,14 +33,16 @@ export function buildReporterPlugin(config: ResolvedConfig): Plugin { } async function getCompressedSize(code: string | Uint8Array): Promise { - if (config.build.ssr || !config.build.brotliSize) { + if ( + config.build.ssr || + !config.build.reportCompressedSize || + config.build.brotliSize === false + ) { return '' } - if (isLarge(code)) { - return ' / brotli: skipped (large chunk)' - } - return ` / brotli: ${( - (await size(typeof code === 'string' ? code : Buffer.from(code))) / 1024 + return ` / gzip: ${( + (await compress(typeof code === 'string' ? code : Buffer.from(code))) + .length / 1024 ).toFixed(2)} KiB` } diff --git a/yarn.lock b/yarn.lock index e6e886a58cd88b..1fb0f7be97db81 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1116,6 +1116,7 @@ "@symlinks/moduleA@link:./packages/playground/preserve-symlinks/moduleA": version "0.0.0" + uid "" "@tootallnate/once@1": version "1.1.2" @@ -2040,13 +2041,6 @@ braces@^3.0.1, braces@~3.0.2: dependencies: fill-range "^7.0.1" -brotli-size@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/brotli-size/-/brotli-size-4.0.0.tgz#a05ee3faad3c0e700a2f2da826ba6b4d76e69e5e" - integrity sha512-uA9fOtlTRC0iqKfzff1W34DXUA3GyVqbUaeo3Rw3d4gd1eavKVCETXrn3NzO74W+UVkG3UHu8WxUi+XvKI/huA== - dependencies: - duplexer "0.1.1" - browser-process-hrtime@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-1.0.0.tgz#3c9b4b7d782c8121e56f10106d84c0d0ffc94626" @@ -2757,7 +2751,8 @@ css-color-names@^1.0.1: integrity sha512-/loXYOch1qU1biStIFsHH8SxTmOseh1IJqFvy8IujXOm1h+QjUdDhkzOrR5HG8K8mlxREj0yfi8ewCHx0eMxzA== "css-dep@link:./packages/playground/css/css-dep": - version "1.0.0" + version "0.0.0" + uid "" css-parse@~2.0.0: version "2.0.0" @@ -2945,19 +2940,19 @@ denque@^1.1.0: "dep-esbuild-plugin-transform@link:./packages/playground/optimize-deps/dep-esbuild-plugin-transform": version "0.0.0" + uid "" "dep-import-type@link:./packages/playground/ssr-vue/dep-import-type": version "0.0.0" + uid "" "dep-linked-include@link:./packages/playground/optimize-deps/dep-linked-include": version "0.0.0" - dependencies: - react "17.0.0" + uid "" "dep-linked@link:./packages/playground/optimize-deps/dep-linked": version "0.0.0" - dependencies: - lodash-es "^4.17.20" + uid "" depd@~1.1.2: version "1.1.2" @@ -3063,11 +3058,6 @@ dotenv@^8.2.0: resolved "https://registry.npmjs.org/dotenv/-/dotenv-8.6.0.tgz#061af664d19f7f4d8fc6e4ff9b584ce237adcb8b" integrity sha512-IrPdXQsk2BbzvCBGBOTmmSH5SodmqZNt4ERAZDmW4CT+tL8VtvinqywuANaFu4bOMWki16nqf0e4oC0QIaDr/g== -duplexer@0.1.1: - version "0.1.1" - resolved "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1" - integrity sha1-rOb/gIwc5mtX0ev5eXessCM0z8E= - ee-first@1.1.1: version "1.1.1" resolved "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" @@ -3387,6 +3377,9 @@ eventemitter3@^4.0.0: resolved "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f" integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw== +"example-external-component@file:packages/playground/ssr-vue/example-external-component": + version "0.0.0" + execa@^0.8.0: version "0.8.0" resolved "https://registry.npmjs.org/execa/-/execa-0.8.0.tgz#d8d76bbc1b55217ed190fd6dd49d3c774ecfc8da" @@ -5645,9 +5638,8 @@ neo-async@^2.6.0: integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw== "nested-exclude@link:./packages/playground/optimize-deps/nested-exclude": - version "1.0.0" - dependencies: - nested-include "file:./packages/playground/optimize-deps/nested-exclude/nested-include" + version "0.0.0" + uid "" "nested-include@file:./packages/playground/optimize-deps/nested-exclude/nested-include": version "1.0.0" @@ -6744,13 +6736,16 @@ reserved-words@^0.1.2: integrity sha1-AKCUD5jNUBrqqsMWQR2a3FKzGrE= "resolve-browser-field@link:./packages/playground/resolve/browser-field": - version "1.0.0" + version "0.0.0" + uid "" "resolve-custom-condition@link:./packages/playground/resolve/custom-condition": - version "1.0.0" + version "0.0.0" + uid "" "resolve-custom-main-field@link:./packages/playground/resolve/custom-main-field": - version "1.0.0" + version "0.0.0" + uid "" resolve-cwd@^3.0.0: version "3.0.0" @@ -6760,10 +6755,12 @@ resolve-cwd@^3.0.0: resolve-from "^5.0.0" "resolve-exports-env@link:./packages/playground/resolve/exports-env": - version "1.0.0" + version "0.0.0" + uid "" "resolve-exports-path@link:./packages/playground/resolve/exports-path": - version "1.0.0" + version "0.0.0" + uid "" resolve-from@^4.0.0: version "4.0.0" @@ -7530,21 +7527,24 @@ test-exclude@^6.0.0: minimatch "^3.0.4" "test-package-a@link:./packages/playground/nested-deps/test-package-a": - version "2.0.0" + version "0.0.0" + uid "" "test-package-b@link:./packages/playground/nested-deps/test-package-b": - version "1.0.0" + version "0.0.0" + uid "" "test-package-c@link:./packages/playground/nested-deps/test-package-c": - version "1.0.0" + version "0.0.0" + uid "" "test-package-d-nested@link:./packages/playground/nested-deps/test-package-d/test-package-d-nested": - version "1.0.0" + version "0.0.0" + uid "" "test-package-d@link:./packages/playground/nested-deps/test-package-d": - version "1.0.0" - dependencies: - test-package-d-nested "link:./packages/playground/nested-deps/test-package-d/test-package-d-nested" + version "0.0.0" + uid "" text-extensions@^1.0.0: version "1.9.0" @@ -7790,6 +7790,7 @@ typedarray-to-buffer@^3.1.5: "types@link:./packages/vite/types": version "0.0.0" + uid "" typescript@^4.3.4: version "4.4.3"