Skip to content

Commit

Permalink
bundles managed
Browse files Browse the repository at this point in the history
  • Loading branch information
0age committed Dec 11, 2024
1 parent b24979a commit dc9cebd
Showing 1 changed file with 97 additions and 6 deletions.
103 changes: 97 additions & 6 deletions frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,35 @@ export default defineConfig(({ mode }) => {
pure_getters: true,
unsafe: true,
unsafe_comps: true,
unsafe_math: true,
unsafe_methods: true,
unsafe_proto: true,
unsafe_regexp: true,
passes: 3,
module: true,
toplevel: true
toplevel: true,
reduce_vars: true,
reduce_funcs: true,
keep_infinity: true,
collapse_vars: true,
dead_code: true,
evaluate: true,
hoist_props: true,
join_vars: true
},
mangle: {
properties: false,
module: true,
toplevel: true
toplevel: true,
keep_classnames: false,
keep_fnames: false
},
format: {
comments: false,
preserve_annotations: false,
ascii_only: true,
beautify: false,
indent_level: 0
}
},
chunkSizeWarningLimit: 500,
Expand All @@ -63,6 +84,47 @@ export default defineConfig(({ mode }) => {
rollupOptions: {
output: {
manualChunks(id) {
// WalletConnect split into very granular chunks
if (id.includes('node_modules/@walletconnect/core')) {
return 'walletconnect-core';
}
if (id.includes('node_modules/@walletconnect/ethereum-provider')) {
return 'walletconnect-ethereum';
}
if (id.includes('node_modules/@walletconnect/jsonrpc')) {
return 'walletconnect-jsonrpc';
}
if (id.includes('node_modules/@walletconnect/keyvaluestorage')) {
return 'walletconnect-storage';
}
if (id.includes('node_modules/@walletconnect/types')) {
return 'walletconnect-types';
}
if (id.includes('node_modules/@walletconnect/utils')) {
return 'walletconnect-utils';
}
if (id.includes('node_modules/@walletconnect')) {
return 'walletconnect-misc';
}

// RPC and provider related
if (id.includes('node_modules/json-rpc-engine')) {
return 'rpc-engine';
}
if (id.includes('node_modules/eth-rpc-errors')) {
return 'rpc-errors';
}

// Encoding/decoding libraries
if (id.includes('node_modules/cbor') ||
id.includes('node_modules/cborg')) {
return 'encoding-cbor';
}
if (id.includes('node_modules/bs58') ||
id.includes('node_modules/base64-js')) {
return 'encoding-utils';
}

// Split crypto into smaller chunks
if (id.includes('node_modules/@noble')) {
return 'crypto-noble';
Expand All @@ -73,50 +135,79 @@ export default defineConfig(({ mode }) => {
if (id.includes('node_modules/elliptic')) {
return 'crypto-elliptic';
}

// Common utilities that might be shared
if (id.includes('node_modules/bn.js') ||
id.includes('node_modules/buffer') ||
id.includes('node_modules/events')) {
return 'common-utils';
}
// Ethers split into core and utils

// Ethers split into smaller chunks
if (id.includes('node_modules/ethers/lib/utils')) {
return 'ethers-utils';
}
if (id.includes('node_modules/ethers/lib/providers')) {
return 'ethers-providers';
}
if (id.includes('node_modules/ethers/lib/transaction')) {
return 'ethers-transaction';
}
if (id.includes('node_modules/ethers')) {
return 'ethers-core';
}

// Split wagmi into smaller chunks
if (id.includes('node_modules/@wagmi/core/connectors')) {
return 'wagmi-connectors';
}
if (id.includes('node_modules/@wagmi/core/providers')) {
return 'wagmi-providers';
}
if (id.includes('node_modules/@wagmi/core')) {
return 'wagmi-core';
}
if (id.includes('node_modules/wagmi') ||
id.includes('node_modules/@wagmi')) {
if (id.includes('node_modules/wagmi')) {
return 'wagmi-extra';
}

// React and related packages
if (id.includes('node_modules/react/') ||
id.includes('node_modules/react-dom/')) {
return 'react-vendor';
}

// UI related dependencies
if (id.includes('node_modules/@headlessui') ||
id.includes('node_modules/@heroicons')) {
return 'ui-vendor';
}

// State management
if (id.includes('node_modules/zustand') ||
id.includes('node_modules/immer')) {
return 'state-management';
}
},
compact: true,
minifyInternalExports: true,
generatedCode: {
preset: 'es2015',
symbols: false
symbols: false,
constBindings: true
}
}
}
},
optimizeDeps: {
include: ['react', 'react-dom'],
exclude: ['@noble/hashes', '@noble/secp256k1']
},
esbuild: {
legalComments: 'none',
ignoreAnnotations: true,
treeShaking: true,
target: 'esnext'
}
};
});

0 comments on commit dc9cebd

Please sign in to comment.