From 889b9256c630e9fc7ad9df8a24382a90e74a105b Mon Sep 17 00:00:00 2001 From: Rizumu Ayaka Date: Wed, 15 Oct 2025 14:01:38 +0800 Subject: [PATCH 1/3] wip: test the tree shaking and minify --- eslint.config.ts | 5 +---- package.json | 1 + pnpm-lock.yaml | 34 ++++++++++++++++++++++++++++++++++ pnpm-workspace.yaml | 7 ++++--- vite.config.mts | 34 ++++++++++++++++++++++++---------- 5 files changed, 64 insertions(+), 17 deletions(-) diff --git a/eslint.config.ts b/eslint.config.ts index 4e19eba2e4..23036dbd1e 100644 --- a/eslint.config.ts +++ b/eslint.config.ts @@ -67,11 +67,8 @@ export default defineConfig([ ...commonParserOptions, projectService: { allowDefaultProject: [ - 'vite.config.mts', 'vite.electron.config.mts', - 'vite.types.config.mts', - 'playwright.config.ts', - 'playwright.i18n.config.ts' + 'vite.types.config.mts' ] } } diff --git a/package.json b/package.json index 0fca0e59e0..2c60b9f789 100644 --- a/package.json +++ b/package.json @@ -88,6 +88,7 @@ "nx": "catalog:", "postcss-html": "catalog:", "prettier": "catalog:", + "rollup-plugin-visualizer": "catalog:", "storybook": "catalog:", "stylelint": "catalog:", "tailwindcss": "catalog:", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3b362bc15b..de05d7d7e2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -201,6 +201,9 @@ catalogs: primevue: specifier: ^4.2.5 version: 4.2.5 + rollup-plugin-visualizer: + specifier: ^6.0.4 + version: 6.0.4 storybook: specifier: ^9.1.6 version: 9.1.6 @@ -591,6 +594,9 @@ importers: prettier: specifier: 'catalog:' version: 3.3.2 + rollup-plugin-visualizer: + specifier: 'catalog:' + version: 6.0.4(rollup@4.22.4) storybook: specifier: 'catalog:' version: 9.1.6(@testing-library/dom@10.4.1)(prettier@3.3.2)(vite@5.4.19(@types/node@20.14.10)(lightningcss@1.30.1)(terser@5.39.2)) @@ -6668,6 +6674,19 @@ packages: rfdc@1.4.1: resolution: {integrity: sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==} + rollup-plugin-visualizer@6.0.4: + resolution: {integrity: sha512-q8Q7J/6YofkmaGW1sH/fPRAz37x/+pd7VBuaUU7lwvOS/YikuiiEU9jeb9PH8XHiq50XFrUsBbOxeAMYQ7KZkg==} + engines: {node: '>=18'} + hasBin: true + peerDependencies: + rolldown: 1.x || ^1.0.0-beta + rollup: 2.x || 3.x || 4.x + peerDependenciesMeta: + rolldown: + optional: true + rollup: + optional: true + rollup@4.22.4: resolution: {integrity: sha512-vD8HJ5raRcWOyymsR6Z3o6+RzfEPCnVLMFJ6vRslO1jt4LO6dUo5Qnpg7y4RkZFM2DMe3WUirkI5c16onjrc6A==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} @@ -6822,6 +6841,10 @@ packages: resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} engines: {node: '>=0.10.0'} + source-map@0.7.6: + resolution: {integrity: sha512-i5uvt8C3ikiWeNZSVZNWcfZPItFQOsYTUAOkcUPGd8DqDy1uOUikjt5dG+uRlwyvR108Fb9DOd4GvXfT0N2/uQ==} + engines: {node: '>= 12'} + speakingurl@14.0.1: resolution: {integrity: sha512-1POYv7uv2gXoyGFpBCmpDVSNV74IfsWlDW216UPjbWufNf+bSU6GdbDsxdcxtfwb4xlI3yxzOTKClUosxARYrQ==} engines: {node: '>=0.10.0'} @@ -14733,6 +14756,15 @@ snapshots: rfdc@1.4.1: {} + rollup-plugin-visualizer@6.0.4(rollup@4.22.4): + dependencies: + open: 8.4.2 + picomatch: 4.0.3 + source-map: 0.7.6 + yargs: 17.7.2 + optionalDependencies: + rollup: 4.22.4 + rollup@4.22.4: dependencies: '@types/estree': 1.0.5 @@ -14924,6 +14956,8 @@ snapshots: source-map@0.6.1: {} + source-map@0.7.6: {} + speakingurl@14.0.1: {} sprintf-js@1.0.3: {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index f3b1ce3763..c6a80655f9 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -68,6 +68,7 @@ catalog: prettier: ^3.3.2 primeicons: ^7.0.0 primevue: ^4.2.5 + rollup-plugin-visualizer: ^6.0.4 storybook: ^9.1.6 stylelint: ^16.24.0 tailwindcss: ^4.1.12 @@ -97,9 +98,6 @@ catalog: cleanupUnusedCatalogs: true -overrides: - '@types/eslint': '-' - ignoredBuiltDependencies: - '@firebase/util' - protobufjs @@ -114,3 +112,6 @@ onlyBuiltDependencies: - esbuild - nx - oxc-resolver + +overrides: + '@types/eslint': '-' diff --git a/vite.config.mts b/vite.config.mts index c68f386f1e..aa13f368d2 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -1,6 +1,7 @@ import tailwindcss from '@tailwindcss/vite' import vue from '@vitejs/plugin-vue' import dotenv from 'dotenv' +import { visualizer } from 'rollup-plugin-visualizer' import { FileSystemIconLoader } from 'unplugin-icons/loaders' import IconsResolver from 'unplugin-icons/resolver' import Icons from 'unplugin-icons/vite' @@ -15,7 +16,8 @@ import { comfyAPIPlugin, generateImportMapPlugin } from './build/plugins' dotenv.config() const IS_DEV = process.env.NODE_ENV === 'development' -const SHOULD_MINIFY = process.env.ENABLE_MINIFY === 'true' +// 🧪 TEST: Temporarily disabled SHOULD_MINIFY - using full optimization +// const SHOULD_MINIFY = process.env.ENABLE_MINIFY === 'true' // vite dev server will listen on all addresses, including LAN and public addresses const VITE_REMOTE_DEV = process.env.VITE_REMOTE_DEV === 'true' const DISABLE_TEMPLATES_PROXY = process.env.DISABLE_TEMPLATES_PROXY === 'true' @@ -163,25 +165,37 @@ export default defineConfig({ deep: true, extensions: ['vue'], directoryAsNamespace: true - }) + }), + + // Bundle analyzer - generates stats.html after build + ...(!IS_DEV + ? [ + visualizer({ + filename: 'dist/stats.html', + open: false, + gzipSize: true, + brotliSize: true, + template: 'treemap' // or 'sunburst', 'network' + }) + ] + : []) ], build: { - minify: SHOULD_MINIFY ? 'esbuild' : false, + minify: 'esbuild', // 🧪 TEST: Force enable minification target: 'es2022', sourcemap: true, rollupOptions: { - // Disabling tree-shaking - // Prevent vite remove unused exports - treeshake: false + // 🧪 TEST: Enable tree-shaking to see maximum optimization + treeshake: true } }, esbuild: { - minifyIdentifiers: false, - keepNames: true, - minifySyntax: SHOULD_MINIFY, - minifyWhitespace: SHOULD_MINIFY + minifyIdentifiers: true, // 🧪 TEST: Enable identifier minification + keepNames: false, // 🧪 TEST: Don't preserve names + minifySyntax: true, // 🧪 TEST: Enable syntax minification + minifyWhitespace: true // 🧪 TEST: Enable whitespace minification }, test: { From 9d998e2c3b002e54b847f1a3df5b4121283307e3 Mon Sep 17 00:00:00 2001 From: Rizumu Ayaka Date: Wed, 15 Oct 2025 16:47:35 +0800 Subject: [PATCH 2/3] tree shaking and minify --- vite.config.mts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/vite.config.mts b/vite.config.mts index aa13f368d2..47a734cc60 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -16,8 +16,7 @@ import { comfyAPIPlugin, generateImportMapPlugin } from './build/plugins' dotenv.config() const IS_DEV = process.env.NODE_ENV === 'development' -// 🧪 TEST: Temporarily disabled SHOULD_MINIFY - using full optimization -// const SHOULD_MINIFY = process.env.ENABLE_MINIFY === 'true' +const SHOULD_MINIFY = process.env.ENABLE_MINIFY === 'true' // vite dev server will listen on all addresses, including LAN and public addresses const VITE_REMOTE_DEV = process.env.VITE_REMOTE_DEV === 'true' const DISABLE_TEMPLATES_PROXY = process.env.DISABLE_TEMPLATES_PROXY === 'true' @@ -167,7 +166,7 @@ export default defineConfig({ directoryAsNamespace: true }), - // Bundle analyzer - generates stats.html after build + // Bundle analyzer - generates dist/stats.html after build ...(!IS_DEV ? [ visualizer({ @@ -182,20 +181,19 @@ export default defineConfig({ ], build: { - minify: 'esbuild', // 🧪 TEST: Force enable minification + minify: SHOULD_MINIFY ? 'esbuild' : false, target: 'es2022', sourcemap: true, rollupOptions: { - // 🧪 TEST: Enable tree-shaking to see maximum optimization treeshake: true } }, esbuild: { - minifyIdentifiers: true, // 🧪 TEST: Enable identifier minification - keepNames: false, // 🧪 TEST: Don't preserve names - minifySyntax: true, // 🧪 TEST: Enable syntax minification - minifyWhitespace: true // 🧪 TEST: Enable whitespace minification + minifyIdentifiers: SHOULD_MINIFY, + keepNames: true, + minifySyntax: SHOULD_MINIFY, + minifyWhitespace: SHOULD_MINIFY }, test: { From 75d397aa121197d1cd6cfcb563ccd71f21120831 Mon Sep 17 00:00:00 2001 From: Rizumu Ayaka Date: Wed, 15 Oct 2025 16:59:17 +0800 Subject: [PATCH 3/3] remove rollup-plugin-visualizer --- package.json | 1 - pnpm-lock.yaml | 34 ---------------------------------- pnpm-workspace.yaml | 1 - vite.config.mts | 16 +--------------- 4 files changed, 1 insertion(+), 51 deletions(-) diff --git a/package.json b/package.json index 2c60b9f789..0fca0e59e0 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,6 @@ "nx": "catalog:", "postcss-html": "catalog:", "prettier": "catalog:", - "rollup-plugin-visualizer": "catalog:", "storybook": "catalog:", "stylelint": "catalog:", "tailwindcss": "catalog:", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index de05d7d7e2..3b362bc15b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -201,9 +201,6 @@ catalogs: primevue: specifier: ^4.2.5 version: 4.2.5 - rollup-plugin-visualizer: - specifier: ^6.0.4 - version: 6.0.4 storybook: specifier: ^9.1.6 version: 9.1.6 @@ -594,9 +591,6 @@ importers: prettier: specifier: 'catalog:' version: 3.3.2 - rollup-plugin-visualizer: - specifier: 'catalog:' - version: 6.0.4(rollup@4.22.4) storybook: specifier: 'catalog:' version: 9.1.6(@testing-library/dom@10.4.1)(prettier@3.3.2)(vite@5.4.19(@types/node@20.14.10)(lightningcss@1.30.1)(terser@5.39.2)) @@ -6674,19 +6668,6 @@ packages: rfdc@1.4.1: resolution: {integrity: sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==} - rollup-plugin-visualizer@6.0.4: - resolution: {integrity: sha512-q8Q7J/6YofkmaGW1sH/fPRAz37x/+pd7VBuaUU7lwvOS/YikuiiEU9jeb9PH8XHiq50XFrUsBbOxeAMYQ7KZkg==} - engines: {node: '>=18'} - hasBin: true - peerDependencies: - rolldown: 1.x || ^1.0.0-beta - rollup: 2.x || 3.x || 4.x - peerDependenciesMeta: - rolldown: - optional: true - rollup: - optional: true - rollup@4.22.4: resolution: {integrity: sha512-vD8HJ5raRcWOyymsR6Z3o6+RzfEPCnVLMFJ6vRslO1jt4LO6dUo5Qnpg7y4RkZFM2DMe3WUirkI5c16onjrc6A==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} @@ -6841,10 +6822,6 @@ packages: resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} engines: {node: '>=0.10.0'} - source-map@0.7.6: - resolution: {integrity: sha512-i5uvt8C3ikiWeNZSVZNWcfZPItFQOsYTUAOkcUPGd8DqDy1uOUikjt5dG+uRlwyvR108Fb9DOd4GvXfT0N2/uQ==} - engines: {node: '>= 12'} - speakingurl@14.0.1: resolution: {integrity: sha512-1POYv7uv2gXoyGFpBCmpDVSNV74IfsWlDW216UPjbWufNf+bSU6GdbDsxdcxtfwb4xlI3yxzOTKClUosxARYrQ==} engines: {node: '>=0.10.0'} @@ -14756,15 +14733,6 @@ snapshots: rfdc@1.4.1: {} - rollup-plugin-visualizer@6.0.4(rollup@4.22.4): - dependencies: - open: 8.4.2 - picomatch: 4.0.3 - source-map: 0.7.6 - yargs: 17.7.2 - optionalDependencies: - rollup: 4.22.4 - rollup@4.22.4: dependencies: '@types/estree': 1.0.5 @@ -14956,8 +14924,6 @@ snapshots: source-map@0.6.1: {} - source-map@0.7.6: {} - speakingurl@14.0.1: {} sprintf-js@1.0.3: {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index c6a80655f9..98d7a3c48d 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -68,7 +68,6 @@ catalog: prettier: ^3.3.2 primeicons: ^7.0.0 primevue: ^4.2.5 - rollup-plugin-visualizer: ^6.0.4 storybook: ^9.1.6 stylelint: ^16.24.0 tailwindcss: ^4.1.12 diff --git a/vite.config.mts b/vite.config.mts index 47a734cc60..2f8b7ac7a3 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -1,7 +1,6 @@ import tailwindcss from '@tailwindcss/vite' import vue from '@vitejs/plugin-vue' import dotenv from 'dotenv' -import { visualizer } from 'rollup-plugin-visualizer' import { FileSystemIconLoader } from 'unplugin-icons/loaders' import IconsResolver from 'unplugin-icons/resolver' import Icons from 'unplugin-icons/vite' @@ -164,20 +163,7 @@ export default defineConfig({ deep: true, extensions: ['vue'], directoryAsNamespace: true - }), - - // Bundle analyzer - generates dist/stats.html after build - ...(!IS_DEV - ? [ - visualizer({ - filename: 'dist/stats.html', - open: false, - gzipSize: true, - brotliSize: true, - template: 'treemap' // or 'sunburst', 'network' - }) - ] - : []) + }) ], build: {