mirror of
https://github.com/dpup/meshstream.git
synced 2026-03-28 17:42:37 +01:00
Fix __publicField error with esnext esbuild target
maplibre-gl v5 bundles reference __publicField and other esbuild class-field helpers without defining them — a known upstream bug (maplibre-gl-js issue #6680). Setting esbuildOptions.target and build.target to 'esnext' tells esbuild to emit native class fields instead of helper-based transforms, eliminating the missing symbol. Remove all previous workaround attempts (define rewrite, globalThis polyfill in index.html). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -15,13 +15,6 @@
|
||||
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script>
|
||||
globalThis.__publicField = function(obj, key, value) {
|
||||
Object.defineProperty(obj, typeof key !== 'symbol' ? key + '' : key, {
|
||||
configurable: true, enumerable: true, writable: true, value: value
|
||||
});
|
||||
};
|
||||
</script>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
|
||||
|
||||
@@ -5,12 +5,6 @@ import { resolve } from 'path';
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
define: {
|
||||
// Some pre-compiled npm packages use __publicField (a TypeScript/esbuild helper)
|
||||
// without bundling it. Rewrite bare references to a globalThis property that
|
||||
// we polyfill in index.html before any module code runs.
|
||||
'__publicField': 'globalThis.__publicField',
|
||||
},
|
||||
plugins: [
|
||||
react(),
|
||||
TanStackRouterVite(),
|
||||
@@ -26,6 +20,16 @@ export default defineConfig({
|
||||
setupFiles: ['./src/test/setup.ts'],
|
||||
css: true,
|
||||
},
|
||||
optimizeDeps: {
|
||||
esbuildOptions: {
|
||||
// maplibre-gl v5 distributes bundles that reference __publicField and
|
||||
// other esbuild class-field helpers without defining them. Setting
|
||||
// target to esnext tells esbuild to emit native class fields instead
|
||||
// of helper-based transforms, which avoids the missing-symbol error.
|
||||
// See: https://github.com/maplibre/maplibre-gl-js/issues/6680
|
||||
target: 'esnext',
|
||||
},
|
||||
},
|
||||
server: {
|
||||
port: 5747,
|
||||
proxy: {
|
||||
@@ -36,7 +40,8 @@ export default defineConfig({
|
||||
},
|
||||
},
|
||||
build: {
|
||||
target: 'esnext',
|
||||
outDir: 'dist',
|
||||
emptyOutDir: true,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user