Is it possible to expose Rollup library in a variable like this one:
var libName=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};[...]
I'm trying to port some legacy webpack app (ejected create-react-app with output.library.type = 'var') to Rollup, but I can't find appropriate option in rollup docs.
My Rollup/Vite config looks like this:
export default defineConfig(({ mode }) => {
process.env = {
...process.env,
...loadEnv(mode, process.cwd())
};
return {
base: process.env.VITE_BASE_URL,
build: {
rollupOptions: {
preserveEntrySignatures: 'strict',
input: {
[Entry.ENTRY_1]: path.resolve(__dirname, `src/${Entry.ENTRY_1}.ts`),
[Entry.ENTRY_2]: path.resolve(__dirname, `src/${Entry.ENTRY_2}.ts`)
},
output: [
{
format: 'system',
entryFileNames
},
{
format: 'module',
entryFileNames
},
// any of these expose as var moduleName = ... like webpack does
{
format: 'amd',
name: 'moduleName',
entryFileNames
},
{
format: 'commonjs',
name: 'moduleName',
entryFileNames
}
]
}
},
plugins: [react(), mode === 'production' && viteExternalsPlugin(sharedDependency)]
};
});