-
-
Notifications
You must be signed in to change notification settings - Fork 82
RE1-T114 Fix tf is not defined error by disabling esbuild minification #336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -17,6 +17,7 @@ export default defineConfig(({ mode }) => { | |||||
| target: 'es2022', | ||||||
| outDir: 'dist/core', | ||||||
| emptyOutDir: true, | ||||||
| minify: false, | ||||||
| sourcemap: mode !== 'production', | ||||||
| cssCodeSplit: false, | ||||||
| modulePreload: { | ||||||
|
|
@@ -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', | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
With Proposed fix- chunkFileNames: 'chunks/[name]-[hash].min.js',
+ chunkFileNames: 'chunks/[name]-[hash].js',📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| assetFileNames: (assetInfo) => { | ||||||
| if (assetInfo.name?.endsWith('.css')) { | ||||||
| return 'react-elements.css'; | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 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
#13727notes a fix in recent Vite versions.Citations:
🏁 Script executed:
Repository: Resgrid/Core
Length of output: 1667
🏁 Script executed:
Repository: Resgrid/Core
Length of output: 38
🏁 Script executed:
Repository: Resgrid/Core
Length of output: 242
🏁 Script executed:
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:
esbuild: { keepNames: true }to preserve identifier names without disabling compression entirely, orterserOptions: { mangle: { keep_classnames: true, keep_fnames: true } }At minimum, add an inline comment explaining why
minify: falseis 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