Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Web/Resgrid.Web/Areas/User/Apps/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default defineConfig(({ mode }) => {
target: 'es2022',
outDir: 'dist/core',
emptyOutDir: true,
minify: false,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

Vite 5 build.minify esbuild keepNames option to prevent identifier mangling

💡 Result:

In Vite 5 with build.minify set to 'esbuild' (the default), you can prevent esbuild from mangling identifiers including function/class names by configuring the top-level esbuild option in vite.config.js with keepNames: true. This passes esbuild options to both transform and minify phases. Example configuration: import { defineConfig } from 'vite' export default defineConfig({ esbuild: { keepNames: true }, build: { minify: 'esbuild' } }) Note that keepNames preserves all names, which may increase bundle size. For finer control (e.g., specific names), switch to Terser: build: { minify: 'terser', terserOptions: { mangle: { reserved: ['specificFunctionName'] } } } This works because Vite merges user-provided esbuild options into the minification step when using esbuild as minifier, as confirmed in Vite source code and community reports. There have been historical issues with keepNames in transform phases conflicting with tree-shaking, but user config overrides apply to minify. As of 2026, issue #13727 notes a fix in recent Vite versions.

Citations:


🏁 Script executed:

cat -n Web/Resgrid.Web/Areas/User/Apps/vite.config.ts

Repository: Resgrid/Core

Length of output: 1667


🏁 Script executed:

# Search for RE1-T114 references
rg "RE1-T114" --type ts --type js --type md --type txt

Repository: Resgrid/Core

Length of output: 38


🏁 Script executed:

# Search for any comments about minify or minification
rg "minify|minification" Web/Resgrid.Web/Areas/User/Apps/vite.config.ts -C 3

Repository: Resgrid/Core

Length of output: 242


🏁 Script executed:

# Search for related issues or TODOs in the config
rg "tf is not defined|Symbol.for|react.portal" -C 3

Repository: Resgrid/Core

Length of output: 50370


Add an explanatory comment clarifying why minification is disabled and link to the issue tracker.

Disabling minification globally ships much larger bundles — the root cause is esbuild's identifier mangling colliding with React's production bundle, but the current workaround significantly impacts performance (often 2–4× larger with slower parsing). Consider a more targeted fix instead:

  • Keep minification enabled with esbuild: { keepNames: true } to preserve identifier names without disabling compression entirely, or
  • Switch to Terser with terserOptions: { mangle: { keep_classnames: true, keep_fnames: true } }

At minimum, add an inline comment explaining why minify: false is set and reference the issue/PR (e.g., RE1-T114) so this temporary workaround doesn't get overlooked and can be re-enabled once upstream is fixed.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Web/Resgrid.Web/Areas/User/Apps/vite.config.ts` at line 20, Add an inline
comment above the minify: false setting in vite.config.ts explaining this is a
temporary workaround for esbuild identifier mangling that breaks React
production bundles and reference the tracker/PR (e.g., RE1-T114); then either
revert to enabling minification with esbuild: { keepNames: true } on the build
config or switch to using Terser with terserOptions: { mangle: {
keep_classnames: true, keep_fnames: true } } as a targeted fix—do not leave
minify: false undocumented so the workaround isn't forgotten.

sourcemap: mode !== 'production',
cssCodeSplit: false,
modulePreload: {
Expand All @@ -30,7 +31,7 @@ export default defineConfig(({ mode }) => {
rollupOptions: {
output: {
entryFileNames: 'react-elements.js',
chunkFileNames: 'chunks/[name]-[hash].js',
chunkFileNames: 'chunks/[name]-[hash].min.js',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

.min.js suffix is misleading now that minification is disabled.

With build.minify: false, chunks emitted as chunks/[name]-[hash].min.js are not actually minified. This will confuse anyone debugging asset sizes or cache headers, and some CDN/compression rules key off .min.js.

Proposed fix
-          chunkFileNames: 'chunks/[name]-[hash].min.js',
+          chunkFileNames: 'chunks/[name]-[hash].js',
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
chunkFileNames: 'chunks/[name]-[hash].min.js',
chunkFileNames: 'chunks/[name]-[hash].js',
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Web/Resgrid.Web/Areas/User/Apps/vite.config.ts` at line 34, The chunk
filename template in vite.config.ts currently hardcodes the ".min.js" suffix
(chunkFileNames: 'chunks/[name]-[hash].min.js') which is misleading when
build.minify is false; update the Vite config to generate chunk names without
the .min.js suffix or make the suffix conditional based on the build.minify
setting so filenames reflect whether files are actually minified—modify the
chunkFileNames template (and any related rollupOptions/output config) to use
'chunks/[name]-[hash].js' or an expression that appends '.min' only when
build.minify is true.

assetFileNames: (assetInfo) => {
if (assetInfo.name?.endsWith('.css')) {
return 'react-elements.css';
Expand Down
2 changes: 1 addition & 1 deletion Web/Resgrid.Web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ FROM mcr.microsoft.com/dotnet/sdk:9.0.202-noble-amd64 AS build
#COPY --from=node_base /usr/local/bin /usr/local/bin
RUN apt-get update
RUN apt-get install -y ca-certificates curl gnupg
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash -
RUN curl -sL https://deb.nodesource.com/setup_20.x | bash -
RUN apt-get -y install nodejs
ARG BUILD_VERSION
WORKDIR /src
Expand Down
Loading