nuxt-modules / ionic

Batteries-included, zero-config Ionic integration for Nuxt
https://ionic.nuxtjs.org
MIT License
369 stars 38 forks source link

Nuxt 3.13.1+ breaks Ionic styles #616

Open jakubkoje opened 3 weeks ago

jakubkoje commented 3 weeks ago

🐛 The bug

After upgrading Nuxt to 3.13.1+, I noticed that Ionic components have a class of "undefined" instead of the correct Ionic classes. This causes the entire app to break due to incorrect CSS styles. (This can be observed for example on <ion-app> and <ion-tab-bar>).

🛠ī¸ To reproduce

https://stackblitz.com/edit/github-qjn2d7?file=package.json

🌈 Expected behaviour

Classes should not be undefined.

ℹī¸ Additional context

jakubkoje commented 2 weeks ago

I was able to dirty fix this issue by editing @ionic/vue/dist/index.js.

The fix is to move every defineCustomElement(); outside the defineComponent(). Not sure what could be causing this.

Rizzato95 commented 1 week ago

I've the same issue, I tried @jakubkoje fix but it doesn't work.

jakubkoje commented 1 week ago

I've the same issue, I tried @jakubkoje fix but it doesn't work.

Weird, this is example of my edited IonBackButton. Do not forget to remove node_modules/.cache after editing the module and restart server afterward.

Also, do not forget that the node modules are refreshed every install. I am currently handling this using patch-package library, even though forking ionic package might be the better way.

defineCustomElement$19(); // PUT THE LINE HERE
const IonBackButton = /*@__PURE__*/ defineComponent((_, { attrs, slots }) => {
    defineCustomElement$19(); // MOVE THIS LINE ABOVE THIS FUNCTION
    // TODO(FW-2969): type
    const ionRouter = inject("navManager");
    const onClick = () => {
Rizzato95 commented 1 week ago

I did it for every component but it doesn't work. However I found a valid workaround for me:

1) Force the Nuxt version to 3.12.4 in the package.json

- "nuxt": "^3.13.1",
+ "nuxt": "3.12.4",

2) Delete node_modules folder 3) Delete package-lock.json (or pnpm-lock.yaml) 4) Reinstall packages

danielroe commented 1 week ago

This is likely to be linked to Vue 3.5+. Can you reproduce on an earlier Nuxt with the latest Vue version?

fanckush commented 5 days ago

@danielroe here's a repro

as you can see, things work just fine, it's unlikely to be vue imo