I have this Vue (Vite) that after build will be packaged with Vercel PKG. One of the ESModule library must be kept external, (not in the Vue production build).
The purpose of it is that after pkg package, this external lib can be updated without the need of the rebuild of the PKG package.
I have tried everything Vite docs says about external vue build. This is my last approach to make it happen:
export default defineConfig({
build: {
rollupOptions: {
external: ["../custom/custom.es.js"],
},
},
plugins: [
vue()
]
});
Here is where I use the library - (vue main.ts)
import { createApp } from 'vue';
const App from './App.vue';
const app = createApp(App);
import CustomComponents from '../custom/custom.es.js';
app.use(CustomComponents);
app.mount('#app');
The problem is that Vite build keeps including this external lib into the production bundle file and loading not from the external library, but the context in the production code.