forked from jsnbuchanan/crowd-funder-for-time-pwa
# Commit Message for SharedArrayBuffer Platform Exclusion
fix: eliminate SharedArrayBuffer checks on non-web platforms * Add platform guard in AbsurdSqlDatabaseService to only initialize on web * Change singleton pattern from eager to lazy instantiation * Update worker import to use lazy singleton pattern * Prevents absurd-sql initialization on Electron/Capacitor platforms * Reduces console noise and memory footprint on desktop/mobile * Maintains full web platform functionality and performance Resolves SharedArrayBuffer-related console output on Electron platform while preserving all web features and maintaining clean architecture.
This commit is contained in:
@@ -14,14 +14,15 @@ const __dirname = path.dirname(__filename);
|
||||
export async function createBuildConfig(mode: string): Promise<UserConfig> {
|
||||
const appConfig = await loadAppConfig();
|
||||
const isCapacitor = mode === "capacitor";
|
||||
const isNative = isCapacitor;
|
||||
const isElectron = mode === "electron";
|
||||
const isNative = isCapacitor || isElectron;
|
||||
|
||||
// Set platform and disable PWA for native platforms
|
||||
process.env.VITE_PLATFORM = mode;
|
||||
process.env.VITE_PWA_ENABLED = isCapacitor ? 'false' : 'true';
|
||||
process.env.VITE_DISABLE_PWA = isCapacitor ? 'true' : 'false';
|
||||
process.env.VITE_PWA_ENABLED = isNative ? 'false' : 'true';
|
||||
process.env.VITE_DISABLE_PWA = isNative ? 'true' : 'false';
|
||||
|
||||
if (isCapacitor) {
|
||||
if (isNative) {
|
||||
process.env.VITE_PWA_ENABLED = 'false';
|
||||
}
|
||||
|
||||
@@ -108,7 +109,7 @@ export async function createBuildConfig(mode: string): Promise<UserConfig> {
|
||||
assetsDir: 'assets',
|
||||
chunkSizeWarningLimit: 1000,
|
||||
rollupOptions: {
|
||||
external: isCapacitor
|
||||
external: isNative
|
||||
? ['@capacitor/app']
|
||||
: [],
|
||||
output: {
|
||||
@@ -127,10 +128,11 @@ export async function createBuildConfig(mode: string): Promise<UserConfig> {
|
||||
define: {
|
||||
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
|
||||
'process.env.VITE_PLATFORM': JSON.stringify(mode),
|
||||
'process.env.VITE_PWA_ENABLED': JSON.stringify(!isCapacitor),
|
||||
'process.env.VITE_DISABLE_PWA': JSON.stringify(isCapacitor),
|
||||
'process.env.VITE_PWA_ENABLED': JSON.stringify(!isNative),
|
||||
'process.env.VITE_DISABLE_PWA': JSON.stringify(isNative),
|
||||
__dirname: JSON.stringify(process.cwd()),
|
||||
__IS_MOBILE__: JSON.stringify(isCapacitor),
|
||||
__IS_ELECTRON__: JSON.stringify(isElectron),
|
||||
__USE_QR_READER__: JSON.stringify(!isCapacitor),
|
||||
'process.platform': JSON.stringify('browser'),
|
||||
'process.version': JSON.stringify('v16.0.0'),
|
||||
@@ -158,7 +160,7 @@ export async function createBuildConfig(mode: string): Promise<UserConfig> {
|
||||
'@nostr/tools',
|
||||
'@nostr/tools/nip06',
|
||||
],
|
||||
exclude: isCapacitor ? [
|
||||
exclude: isNative ? [
|
||||
'register-service-worker',
|
||||
'workbox-window',
|
||||
'web-push',
|
||||
|
||||
Reference in New Issue
Block a user