Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Nuxt 3 #5527

Open
chuckn0rris opened this issue Nov 3, 2022 · 12 comments
Open

Support Nuxt 3 #5527

chuckn0rris opened this issue Nov 3, 2022 · 12 comments
Assignees
Labels
feature request forum Issues from forum high-priority Urgent to have fixed

Comments

@chuckn0rris
Copy link

Forum post

bryntum-nuxt3-main.zip

@chuckn0rris chuckn0rris added feature request forum Issues from forum labels Nov 3, 2022
@Abdulla1995
Copy link

I reported this also on Nuxt. And there was known issue.
My issue - #5527
Fix issue - nuxt/nuxt#13471
My fix: in nuxt.config.js file add this to disable transition which break things:

app: {
    pageTransition: false
}

If you want to disable for only this problematic routes:

definePageMeta({
  pageTransition: false
  //layoutTransition: false
})

@matsbryntse matsbryntse added the high-priority Urgent to have fixed label May 9, 2023
@chuckn0rris
Copy link
Author

Another request

@awacode21
Copy link

awacode21 commented Nov 13, 2023

Not much happening here since one year?

My problem: https://forum.bryntum.com/viewtopic.php?t=26907

The described "workaround" with disabling the page transitions does not work at all. The related upstream issue in vue got fixed 3 weeks ago, see here: vuejs/core#9388 and here: nuxt/nuxt#13471

So if this was really the problem, we should expect it to work, but it is still not working!
I am on latest Nuxt 3 version 3.8.1

As soon as i do import { BryntumGrid } from "@bryntum/grid-vue-3"; it breaks the page and every link to that page.

Bildschirmfoto 2023-11-13 um 15 34 08

@awacode21
Copy link

awacode21 commented Nov 13, 2023

Looks like the upstream issue in vue and nuxt already got fixed! But i still get this error when trying to use bryntum with nuxt. So there must be an issue within the bryntum code. Or maybe @bryntum/grid-vue-3 is not using correct vue version? Is anyone working on it? Cause this issue here seems stale for quite a while?

@awacode21
Copy link

i found a working workaround by myself. Adding this to nuxt.config file:

export default defineNuxtConfig({
  vite: {
    optimizeDeps : {
      include : ['@bryntum/grid', '@bryntum/grid-vue-3']
  }
  },
})

fixes the "500 - The Bryntum Grid bundle was loaded multiple times by the application" issue for me. This actually has nothing to do with nuxt as this is about the vite configuration. It looks like you have an issue with your dependency management, or how you export things or how you handle mjs vs cjs.. whatever that leads to the problem of multiple loading. The optimizeDeps cleans that up for me so i can progress with my work, But you should have a look on this thing.

@matsbryntse
Copy link
Member

Thanks for sharing your findings, we'll dig into this asap! 🙏

@SergeyMaltsev
Copy link
Contributor

@awacode21
It is required for dev server which uses esbuild and it sometimes splits code into wrong chunks. Thay have a note in their docs that code splitting may have problems https://esbuild.github.io/api/#splitting + opened issue.
That config helps esbuild with correct chunk splitting.
The same config is required for vite application and already included in all our demos.

@marciogurka
Copy link

+1

@SergeyMaltsev
Copy link
Contributor

@marciogurka
Our components are not compatible with SSR
We have a guide for React Next.js
https://bryntum.com/products/grid/docs/guide/Grid/integration/react/guide#loading-components-dynamically-with-next-js

Most likely same approach can be for NUXT.
Please check if that works.
https://javascript.plainenglish.io/crank-up-auto-import-for-dynamic-nuxt-js-components-54e7f198fc16

@buettse
Copy link

buettse commented May 7, 2024

is a nuxt "fix" done soon? we need it !

@khattakdev khattakdev self-assigned this May 13, 2024
@jsakalos
Copy link

As @SergeyMaltsev said "Our components are not compatible with SSR" and that has no immediate "fix." Our components do need a browser environment to work. Therefore, if you can prevent the page with grid (or other component) from being server side rendered, all should work as expected.

The problem and solution is same or similar to Next.js for which we have a section in the guide (the link is above). Although the details of disabling SSR may be different in NUXT, the principle is same.

@SergeyMaltsev
Copy link
Contributor

There's no bug in Grid component.
You need to setup it to work at client side (no ssr).

This is how to do this:

Create basic Nuxt app

npm install nuxi
npx nuxi init my-nuxt3-app
cd my-nuxt3-app

Install Bryntum Grid

npm install @bryntum/grid@5.6.10
npm install @bryntum/grid-vue-3@5.6.10

Register Grid as plugin

plugins/bryntum-grid.js

import { defineNuxtPlugin } from '#app';
import { BryntumGrid } from '@bryntum/grid-vue-3';
import '@bryntum/grid/grid.stockholm.css';

export default defineNuxtPlugin((nuxtApp) => {
    nuxtApp.vueApp.component('BryntumGrid', BryntumGrid);
});

Add to nuxt Config

nuxt.config.ts

// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
    devtools : { enabled : true },
    plugins: [
        { src: '~/plugins/bryntum-grid.js', mode: 'client' }
    ],
    vite     : {
        optimizeDeps : {
            // Specify dependencies for optimization
            include : ['@bryntum/grid', '@bryntum/grid-vue-3']
        }
    }
});

Note: Vite optimizeDeps setting is required to fix esbuild code-splitting bug when you run app with dev server.

Create Grid client-only Component

components/BryntumGridComponent.vue

<template>
    <client-only>
        <BryntumGrid
            :columns="columns"
            :data="data">
        </BryntumGrid>
    </client-only>
</template>

<script setup>
import { ref } from 'vue';

const columns = ref([
    { field: 'name', text: 'Name' },
    { field: 'age', text: 'Age' }
]);

const data = ref([
    { name: 'John', age: 30 },
    { name: 'Jane', age: 25 }
]);
</script>

<style scoped>
/* Add any necessary styles for your grid component */
.b-grid {
    /* Set the height to 100% of the viewport height */
    height: 100vh;
}
</style>

Add Grid client-only Component

app.vue

<template>
    <div>
        <h1>My Nuxt App with BryntumGrid</h1>
        <BryntumGridComponent/>
    </div>
</template>

<script setup>
import BryntumGridComponent from '~/components/BryntumGridComponent.vue';
</script>

<style scoped>
/* Add your styles here */
</style>

Run application.

npm run dev

Please see attached zip.
Readme.MD is inside.
vue-3-nuxt-grid-app.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request forum Issues from forum high-priority Urgent to have fixed
Projects
None yet
Development

No branches or pull requests

9 participants