Conversation
- Add minify: false to vite.config.ts to prevent esbuild from renaming
React variables, which caused a naming collision where React's Component
constructor was renamed to 'tf' - the same name already used for
Symbol.for('react.portal') in React's production bundle.
- Upgrade Dockerfile Node.js from 18.x (EOL) to 20.x LTS.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
📝 WalkthroughWalkthroughThe pull request updates two configuration files: the Vite build configuration to disable minification and modify chunk naming patterns, and the Dockerfile to upgrade Node.js from version 18.x to 20.x. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
Web/Resgrid.Web/Dockerfile (1)
20-20: Node 20.x upgrade looks good; minor cleanup available.Upgrading from EOL Node 18 to Node 20 LTS is appropriate and compatible with
@types/node@^20.16.11and Vite 5 inpackage.json. Two small nits on this line:
- There is a stray double space in the URL (
setup_20.x | bash -). Harmless to the shell, but worth tidying.- Piping the NodeSource setup script directly into
bashis the legacy flow. NodeSource now recommends the keyring +aptsource approach, which is more auditable and cache-friendly for Docker layers. Optional, not blocking.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@Web/Resgrid.Web/Dockerfile` at line 20, The RUN line "RUN curl -sL https://deb.nodesource.com/setup_20.x | bash -" has a stray double space and uses the legacy curl|bash install; fix by removing the extra space in the URL and replace the piped installer with NodeSource's recommended keyring + apt source flow: download and install the NodeSource GPG keyring into /usr/share/keyrings, add the deb source entry for Node 20 to apt sources referencing that keyring, run apt-get update, then apt-get install -y nodejs (update the Dockerfile step that currently contains the RUN curl... | bash - to use this keyring+apt approach for better layer caching and auditability).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@Web/Resgrid.Web/Areas/User/Apps/vite.config.ts`:
- 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.
- 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.
---
Nitpick comments:
In `@Web/Resgrid.Web/Dockerfile`:
- Line 20: The RUN line "RUN curl -sL https://deb.nodesource.com/setup_20.x |
bash -" has a stray double space and uses the legacy curl|bash install; fix by
removing the extra space in the URL and replace the piped installer with
NodeSource's recommended keyring + apt source flow: download and install the
NodeSource GPG keyring into /usr/share/keyrings, add the deb source entry for
Node 20 to apt sources referencing that keyring, run apt-get update, then
apt-get install -y nodejs (update the Dockerfile step that currently contains
the RUN curl... | bash - to use this keyring+apt approach for better layer
caching and auditability).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: a9c9a98b-380c-4519-ba8f-2e8d4e0e18e8
📒 Files selected for processing (2)
Web/Resgrid.Web/Areas/User/Apps/vite.config.tsWeb/Resgrid.Web/Dockerfile
| target: 'es2022', | ||
| outDir: 'dist/core', | ||
| emptyOutDir: true, | ||
| minify: false, |
There was a problem hiding this comment.
🧩 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:
- 1: https://stackoverflow.com/questions/75236041/vite-use-keep-names-esbuild-flag-for-production-build
- 2: esbuild keepNames not respected vitejs/vite#13727
- 3: optimizeDeps.esbuildOptions.keepNames doesn't seems to be working vitejs/vite#9895
- 4: Add options for esbuild minifier vitejs/vite#5489
🏁 Script executed:
cat -n Web/Resgrid.Web/Areas/User/Apps/vite.config.tsRepository: Resgrid/Core
Length of output: 1667
🏁 Script executed:
# Search for RE1-T114 references
rg "RE1-T114" --type ts --type js --type md --type txtRepository: 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 3Repository: 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 3Repository: 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.
| output: { | ||
| entryFileNames: 'react-elements.js', | ||
| chunkFileNames: 'chunks/[name]-[hash].js', | ||
| chunkFileNames: 'chunks/[name]-[hash].min.js', |
There was a problem hiding this comment.
.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.
| 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.
|
Approve |
Summary by CodeRabbit