im trying to bundle aggrid-vue locally and use it in some of my pages where i require tables. I am not running a node.js server – My application is a python back-end with fastapi serving the endpoints and pages.
I have the following package.json and vite configurations that i use to bundle and try bundle aggrid for use in my pages.
package.json:
{
"name": "frontend",
"version": "1.0.0",
"main": "main.js",
"scripts": {
"build": "vite build"
},
"dependencies": {
"ag-grid-vue3": "^33.1.1"
},
"devDependencies": {
"vite": "^6.2.2"
}
}
vite.config.js
import { defineConfig } from 'vite';
import { resolve } from 'path';
export default defineConfig({
build: {
outDir: 'dist',
lib: {
entry: resolve(__dirname, 'dependencies/vite-entries/aggrid.js'),
name: 'AgGrid',
fileName: 'aggrid-bundle',
formats: ['umd']
},
rollupOptions: {
// Instead of making Vue external, we'll handle it differently
output: {
// Provide globals for UMD build
globals: {
vue: 'Vue'
}
}
}
},
resolve: {
// Ensure Vue is resolved correctly
alias: {
'vue': 'Vue'
}
},
define: {
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'production')
}
}
});
aggrid.js
import { AgGridVue } from 'ag-grid-vue3';
import { AllCommunityModule, ModuleRegistry } from 'ag-grid-community';
import 'ag-grid-community/styles/ag-grid.css';
import 'ag-grid-community/styles/ag-theme-alpine.css';
ModuleRegistry.registerModules([AllCommunityModule]);
if (typeof window !== 'undefined') {
window.AgGrid = {
AgGridVue
};
}
export {
AgGridVue
};
after doing this i run an npm run build
this generates two files for which i can now include in my page
<link rel="stylesheet" href="/libs/aggrid-bundle.css">
<script src="/libs/aggrid-bundle.umd.js" type="module"></script>
the folowing is my table.js component where im trying to use this grid
export const DTable = {
name: 'DataTable',
components: { 'ag-grid-vue': window.AgGridVue },
props: {
containerId: { type: String, default: null },
panelId: { type: String, default: null },
data: {
type: Object,
default: null
},
dataModelType: {
type: String,
default: 'datatable'
}
},
setup(props) {
const { ref, onMounted, onUnmounted, watch, inject } = Vue;
// Row Data: The data to be displayed.
// Simple test data
const rowData = ref([
{ make: "Tesla", model: "Model Y", price: 64950 },
{ make: "Ford", model: "F-Series", price: 33850 },
{ make: "Toyota", model: "Corolla", price: 29600 }
]);
const colDefs = ref([
{ field: "make" },
{ field: "model" },
{ field: "price" }
]);
// Add debugging
onMounted(() => {
console.log("AgGridVue component:", window.AgGrid.AgGridVue);
console.log("Test data:", rowData.value);
processData();
});
const gridOptions = ref({
defaultColDef: {
sortable: true,
filter: true,
resizable: true
}
});
return {
rowData,
colDefs,
};
},
template: `
<!-- The AG Grid component -->
<div style="height: 500px; width: 100%;" class="ag-theme-alpine">
<ag-grid-vue
style="height: 100%; width: 100%;"
:column-defs="colDefs"
:row-data="rowData">
</ag-grid-vue>
</div>
`
};
the problem im running into is that there are no errors and the logs from the onMounted looks good. but no table is actually rendered. When i loook at the DOM that is rendered, it looks like this
<ag-grid-vue
column-defs="[object Object],[object Object],[object Object]"
row-data="[object Object],[object Object],[object Object]"
style="height: 100%; width: 100%;">
</ag-grid-vue>
The bindings seem to show objects that are never really rendered properly.
If you are familiar with AgGrid – i could use your help here.