capacitor-community / sqlite

⚡Capacitor plugin for native & electron SQLite databases.
MIT License
507 stars 122 forks source link

Cant run web version #340

Closed Nickolas- closed 2 years ago

Nickolas- commented 2 years ago

Describe the bug Cant make it run on quasar SPA with vite

image

Expected behavior Web version works as ios/android

Quasar latest

image
jepiqueau commented 2 years ago

@Nickolas- can you share the main.ts and the app.ts files

Nickolas- commented 2 years ago

@jepiqueau thanks , for quick response! Quasar framework do not have a main.ts it uses a boot files.

App.vue

image

database.ts

image
jepiqueau commented 2 years ago

@Nickolas- can you share appDataSource

jepiqueau commented 2 years ago

@Nickolas- the openModes must be RW or RO or both read-write RW, read-only RO. Open does not exist

Nickolas- commented 2 years ago

@jepiqueau FYI

image

I do no think the issue , in wrong open modes, becuase as I said everything works on ios/android

I read something about stencil components to experimental import

image

I did add that too

jepiqueau commented 2 years ago

@Nickolas- the checkConsistency is mainly used for live reload . Any how the 'open' mode clearly does not exist. I do not know if you have a vue.config.js file look at what i put in to have typeOrm working in https://github.com/jepiqueau/vue-typeorm-app. That could help you. I am away from my computer for the next 3 weeks so i cannot run your app. Tell me if s'éteint the vue.config.js help in solving your issue

Nickolas- commented 2 years ago

@jepiqueau vue.config.js just store some info for webpack and im using vite. I do no think they are related ?

jepiqueau commented 2 years ago

@Nickolas- there is nothing more i can do for the next 3 week-end so you are on your own

Nickolas- commented 2 years ago

Hi @jepiqueau , I found an issue at stencil github about dynamic loads and Vite. https://github.com/ionic-team/stencil/issues/2827 What do you think , could be it related ? I will try today add this flag to stencil config and rebuild a package. Let's see

jepiqueau commented 2 years ago

@Nickolas- i remember for vite app the way to import the Stencil component is different. Look at https://github.com/gepiqueau/vuevite-app this should solve your issue

jepiqueau commented 2 years ago

@Nickolas- Did that help you to solve the issue ?

Nickolas- commented 2 years ago

@jepiqueau I didnt test actually , do not have a time right now to play around. Will do maybe on weekeneds. For right now I did a workaround to make it work

image
Nickolas- commented 2 years ago

@jepiqueau btw your link does not work for me. I got 404.

jepiqueau commented 2 years ago

@Nickolas- you get a 404 as you certainly did not copy the sql-wasm.wasm file from sql.js installed into the public/assets folder of the app as mentioned in the doc

Nickolas- commented 2 years ago

@jepiqueau I got 404 on your link , not in app :) https://github.com/gepiqueau/vuevite-app this one not works :)

Nickolas- commented 2 years ago

@jepiqueau about sql-wasm.wasm I try in to different ways, one is load from static files , other to load from sqljs.org at runtime

jepiqueau commented 2 years ago

@Nickolas- sorry https://github.com/jepiqueau/vuevite-app

jepiqueau commented 2 years ago

@Nickolas- to have it working with capacitor 4 you have to follow the instructions from ionic capacitor 3 to 4

jepiqueau commented 2 years ago

@Nickolas- have you had time to try?

Nickolas- commented 2 years ago

Not yet , maybe on weekends.

jepiqueau commented 2 years ago

@Nickolas- OK good luck

Nickolas- commented 2 years ago

@jepiqueau so after of ton wasted time , i would not recommend anyone to work with typeorm and vite. Its just not ready , to many things fail in runtime.

With webpack everything work like a charm. No extra coded need.

Have a good day :)

jepiqueau commented 2 years ago

@Nickolas- thanks for your painfull work sorry that you cannot succeed but at least it is a good feedback for other developers

jepiqueau commented 2 years ago

@Nickolas- i close the issue

SechinAndrey commented 1 year ago

@jepiqueau so after of ton wasted time , i would not recommend anyone to work with typeorm and vite. Its just not ready , to many things fail in runtime.

I also tried to develop project vite + vue3 + capacitor + @capacitor-community/sqlite and ran into a project build problem when connecting typeorm. I will leave a link to the issue for those who will look for information in the future (unfortunately this method did not help me, but maybe this method will work for you or a solution will be found that works for everyone).


I also had problems when generating typeorm migrations with dataSource type 'capacitor', but maybe I missed something in this case.

Nickolas- commented 1 year ago

Hi @jepiqueau, coming back with a good news. To run sqlite typeorm and Vite was a challenge but I did it successfully. First of all do not use

image

Vite do not know how to resolve all required dynamic dependencies. Use:

image image

This will solve the issue in production mode related to

image

Second is to solve all typeorm issues with Vite in production. Here a github issue from typeorm repository. Maybe later I can create a demo with Vite sqlite typeorm quasar. Have a good day

mmouterde commented 1 year ago

Same issue here (vite+quasar+vue3+capacitor+sqlite). I can confirm the workaround calling customElements.define('jeep-sqlite',JeepSqlite); before jeepSqlite(window) (not after)

jepiqueau commented 1 year ago

@mmouterde look at https://jepiqueau.github.io/2023/09/05/Ionic7Vue-SQLite-CRUD-App.html you will see how it is done for vite vue app