storesafe / cordova-sqlite-storage

A Cordova/PhoneGap plugin to open and use sqlite databases on Android, iOS and Windows with HTML5/Web SQL API
Other
2.14k stars 713 forks source link

Plugin breaks electron builds (cordova.js:1171 Uncaught Error: Module cordova-sqlite-storage.sql does not exist.) #985

Open aidanas opened 2 years ago

aidanas commented 2 years ago

If the plugin is added to project it breaks electron builds with the following errors printed to console:

cordova.js:1171 Uncaught Error: Module cordova-sqlite-storage.sql does not exist.
Uncaught Error: Module cordova-sqlite-storage.sql does not exist.
    at addEntry (cordova.js:1171)
    at Object.exports.runs (cordova.js:1193)
    at onScriptLoadingComplete (cordova.js:1331)
    at scriptLoadedCallback (cordova.js:1352)
    at HTMLScriptElement.<anonymous> (cordova.js:1306)

I understand that the plugin does not support electron platform but it used to not actively break it either. The issue can be recreated using basic "HelloWorld". Steps to recreate:

  1. cordova create helloworld com.example.hello HelloWorld
  2. cordova platform add electron@2.0.0
  3. cordova plugin add cordova-sqlite-storage
  4. cordova build electron --debug
  5. Install pkg generated at ./platforms/electron/build/
  6. Run installed app.
  7. Observe errors within devtools.

This appears to have been introduced in plugin version 5.1.0 as it still works fine on 5.0.0

Those are additional version comparisons:

| Electron version | Plugin version | result |
 ____________________________________________
|      1.0.0       |      6.0.0     |  ERROR  | 
 ____________________________________________
|      2.0.0       |      6.0.0     |  ERROR  | 
 ____________________________________________
|  3.0.0@nightly   |      6.0.0     |  ERROR  | 
 ____________________________________________
|      2.0.0       |      -         |  ERROR  | 
 ____________________________________________
|      2.0.0       |      5.1.0     |  ERROR  | 
 ____________________________________________
|      1.0.0       |      5.1.0     |  ERROR  | 
 ____________________________________________
|      2.0.0       |      5.0.0     |     OK  | 
 ____________________________________________
brodybits commented 2 years ago

I hope to test this in the near future, adding a bug label for now. Thanks.

afelipelli commented 2 years ago

Anyone found a solution to this? Or maybe a workaround? I'm getting the same issue doing:

ionic cordova build browser

after adding this version of the plugin

Murthrag commented 2 years ago

Anything new regarding this issue? I would really love to us this plugin for electron

rexx-org commented 2 years ago

I also just came across this problem. Effectively you can't build for Electron that doesn't use sqlite and for iOS that does use sqlite plugin on the same machine. Any workaround available? Thanks

rexx-org commented 2 years ago

I have a workaround but it is not pretty.

1) Remove the cordova-sqlite-storage plugin % cordova plugin remove cordova-sqlite-storage

2) Edit the following files and remove all JSON objects that have a pluginId: "cordova-sqlite-storage"

./platforms/electron/www/cordova_plugins.js ./platforms/electron/electron.json ./platforms/electron/platform_www/cordova_plugins.js

eg: { "file": "plugins/cordova-sqlite-storage/src/browser/SQLiteProxy.js", "id": "cordova-sqlite-storage.SQLiteProxy", "pluginId": "cordova-sqlite-storage", "runs": true }

These JSON objects in these files should be removed by the removal of the plugin. That is another bug I guess. It may be possible to only have to edit 1 of these files, but I don't know the relationship between these files.

3) Build the Electron platform % cordova build electron

If you want to build another platform that uses cordova-sqlite-storage plugin, then you will need to add the plugin again