refactor: improve type safety and browser compatibility - Replace any types with SqlValue[] in migration system - Add browser-compatible implementations of Node.js modules (crypto, fs, path) - Update Vite config to handle Node.js module polyfills - Remove outdated migration documentation files

This commit is contained in:
Matt Raymer
2025-05-25 23:37:08 -04:00
parent 9492018fd6
commit 152499a34f
7 changed files with 1035 additions and 206 deletions

View File

@@ -36,7 +36,15 @@ export async function createBuildConfig(mode: string) {
assetsDir: 'assets',
chunkSizeWarningLimit: 1000,
rollupOptions: {
external: isCapacitor ? ['@capacitor/app'] : []
external: isCapacitor
? ['@capacitor/app']
: [],
output: {
format: 'es',
generatedCode: {
preset: 'es2015'
}
}
}
},
define: {
@@ -46,11 +54,22 @@ export async function createBuildConfig(mode: string) {
__dirname: isElectron ? JSON.stringify(process.cwd()) : '""',
__IS_MOBILE__: JSON.stringify(isCapacitor),
__USE_QR_READER__: JSON.stringify(!isCapacitor),
'process.platform': JSON.stringify('browser'),
'process.version': JSON.stringify('v16.0.0'),
'process.env.NODE_DEBUG': JSON.stringify(false),
'global.process': JSON.stringify({
platform: 'browser',
version: 'v16.0.0',
env: { NODE_DEBUG: false }
})
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
...appConfig.aliasConfig,
'path': path.resolve(__dirname, './src/utils/node-modules/path.js'),
'fs': path.resolve(__dirname, './src/utils/node-modules/fs.js'),
'crypto': path.resolve(__dirname, './src/utils/node-modules/crypto.js'),
'nostr-tools/nip06': mode === 'development'
? 'nostr-tools/nip06'
: path.resolve(__dirname, 'node_modules/nostr-tools/nip06'),
@@ -62,7 +81,13 @@ export async function createBuildConfig(mode: string) {
}
},
optimizeDeps: {
include: ['nostr-tools', 'nostr-tools/nip06', 'nostr-tools/core', 'dexie-export-import'],
include: [
'nostr-tools',
'nostr-tools/nip06',
'nostr-tools/core',
'dexie-export-import',
'@jlongster/sql.js'
],
exclude: isElectron ? [
'register-service-worker',
'workbox-window',