I’m using Vite
In my index.js
entrypoint file I have a bunch of imports like:
import { truncate } from './utils';
But these are only visible to other code that is imported in index.js
The truncate
function is not visible to code in the HTML page unless I also do:
window.truncate = truncate;
// or
globalThis.truncate = truncate;
I sort of get why this is but it feels cumbersome. I have a whole bunch of functions I want to expose.
Is there any way to configure Vite/Rollup to automatically expose imported symbols to the global object? Or some other way to achieve this?