Fix __publicField polyfill via index.html instead of vite define

esbuild's define only accepts literals/identifiers, not arrow functions.
Inject the polyfill as a plain script tag before the module entry point
so it is available when any pre-compiled dependency uses it.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Daniel Pupius
2026-03-15 23:33:35 +00:00
parent 602a20cfc1
commit bd09beff40
2 changed files with 1 additions and 7 deletions

View File

@@ -15,6 +15,7 @@
<body>
<div id="root"></div>
<script>window.__publicField = function(a, b, c) { a[b] = c; return c; };</script>
<script type="module" src="/src/main.tsx"></script>
</body>

View File

@@ -20,13 +20,6 @@ export default defineConfig({
setupFiles: ['./src/test/setup.ts'],
css: true,
},
optimizeDeps: {
esbuildOptions: {
define: {
'__publicField': '(a,b,c)=>(a[b]=c,c)',
},
},
},
server: {
port: 5747,
proxy: {