-
Notifications
You must be signed in to change notification settings - Fork 148
Closed
Labels
bug/fixSomething isn't workingSomething isn't workingneeds: triageplatform: webWeb platformWeb platform
Description
Plugin version:
"@capacitor-community/sqlite": "^6.0.2"
Platform(s):
Web (Angular app inside NX monorepo)
Current behavior:
Using sqlite plugin with jeep-sqlite in an Angular app inside an NX monorepo results in the following WebAssembly errors when loading in the browser:
Expected behavior:
The SQLite WebAssembly module should initialize without errors, allowing database access in the browser as expected.
Steps to reproduce:
- Create a new Ionic app with Angular inside an NX monorepo
- Install capacitor-community/sqlite plugin and sql-wasm.wasm file from "node_modules/sql.js/dist/sql-wasm.wasm" to "apps//src/assets"
- Initialize the component using jeepSqlite(window)
- Append the element to the DOM
- Load the app in the browser
- Check the console for WebAssembly error
Related code:
Here is how I load the plugin for browser into the main.ts file. This configuration is loaded before the app initializes
if (Capacitor.getPlatform() === 'web') {
jeepSqlite(window);
window.addEventListener('DOMContentLoaded', async () => {
const jeepEl = document.createElement('jeep-sqlite');
jeepEl.autoSave = true;
// Also tried: jeepEl.setAttribute('wasm-path', 'assets/sql-wasm.wasm');
document.body.appendChild(jeepEl);
await customElements.whenDefined('jeep-sqlite');
});
}
By the other side, the app is initialized with the following methods and the error occurs after executing the database initialization
async initPlugin(): Promise<void> {
this.dbConnection = new SQLiteConnection(CapacitorSQLite);
if (Capacitor.getPlatform() === 'web') {
await CapacitorSQLite.initWebStore();
} else {
const isDevEncrypt = await this.isDeviceEncryption();
if (isDevEncrypt) {
await this.setEncryptionPassphrase('<passphrase>');
}
}
await this.initDatabase();
}
async initDatabase() {
await CapacitorSQLite.addUpgradeStatement({
database: this.dbName,
upgrade: this.versionUpgrades,
});
this.db = await this.openDatabase(this.dbName, this.loadToVersion, false);
if (Capacitor.getPlatform() === 'web') {
await this.dbConnection.saveToStore(this.dbName);
}
}
Other information:
Capacitor doctor:
💊 Capacitor Doctor 💊
Latest Dependencies:
@capacitor/cli: 7.2.0
@capacitor/core: 7.2.0
@capacitor/android: 7.2.0
@capacitor/ios: 7.2.0
Installed Dependencies:
@capacitor/cli: 6.2.0
@capacitor/ios: 6.1.2
@capacitor/core: 6.2.0
@capacitor/android: 6.1.2
Metadata
Metadata
Assignees
Labels
bug/fixSomething isn't workingSomething isn't workingneeds: triageplatform: webWeb platformWeb platform