fixing Trace Bullet

This commit is contained in:
2025-09-15 21:23:33 +02:00
parent ea560fc221
commit f81e52388c
17 changed files with 331 additions and 25 deletions
+11 -6
View File
@@ -3,6 +3,10 @@
// Enable bundle analysis based on environment variable
const enableAnalyzer = process.env.ANALYZE_BUNDLE === 'true';
// Ensure mutable config sections exist to avoid spread on undefined
config.plugins = config.plugins || [];
config.resolve = config.resolve || {};
config.module = config.module || {};
if (enableAnalyzer) {
console.log('📊 Bundle analyzer enabled - generating bundle report...');
@@ -14,7 +18,8 @@ if (enableAnalyzer) {
config.plugins.push({
apply: (compiler) => {
compiler.hooks.done.tap('BundleSizeLogger', (stats) => {
const assets = stats.toJson().assets;
const json = stats.toJson({ all: false, assets: true });
const assets = (json && json.assets) ? json.assets : [];
console.log('\n📦 WASM Bundle Analysis Report:');
console.log('=====================================');
@@ -68,14 +73,14 @@ if (enableAnalyzer) {
console.log('=====================================');
if (wasmAsset.size > 5 * 1024 * 1024) { // > 5MB
console.log('⚠️ WASM binary is large (${wasmSizeMB}MB). Consider:');
console.log(`⚠️ WASM binary is large (${wasmSizeMB}MB). Consider:`);
console.log(' - Reducing Compose UI components');
console.log(' - Lazy loading features');
console.log(' - Tree-shaking unused dependencies');
}
if (jsAsset.size > 500 * 1024) { // > 500KB
console.log('⚠️ JS bundle is large (${jsSizeKB}KB). Consider:');
console.log(`⚠️ JS bundle is large (${jsSizeKB}KB). Consider:`);
console.log(' - Code splitting');
console.log(' - Dynamic imports');
console.log(' - Removing unused imports');
@@ -95,7 +100,7 @@ if (enableAnalyzer) {
// Additional tree-shaking optimizations
config.resolve = {
...config.resolve,
...(config.resolve || {}),
// Prioritize ES6 modules for better tree-shaking
mainFields: ['module', 'browser', 'main'],
// Add extensions for better resolution
@@ -104,9 +109,9 @@ config.resolve = {
// Mark packages as side-effect-free for better tree-shaking
config.module = {
...config.module,
...(config.module || {}),
rules: [
...config.module.rules || [],
...(config.module && config.module.rules ? config.module.rules : []),
{
// Mark Kotlin-generated code as side-effect-free where possible
test: /\.js$/,
+6 -6
View File
@@ -5,7 +5,7 @@ const path = require('path');
// Bundle size optimization configuration
config.optimization = {
...config.optimization,
...(config.optimization || {}),
// Enable aggressive tree shaking
usedExports: true,
sideEffects: false,
@@ -64,7 +64,7 @@ config.optimization = {
// Performance optimization
config.performance = {
...config.performance,
...(config.performance || {}),
// Increase hint limits for WASM (which is naturally larger)
maxAssetSize: 2000000, // 2MB for individual assets
maxEntrypointSize: 2000000, // 2MB for entrypoints
@@ -73,7 +73,7 @@ config.performance = {
// Resolve optimization for faster builds
config.resolve = {
...config.resolve,
...(config.resolve || {}),
// Skip looking in these directories to speed up resolution
modules: ['node_modules'],
// Cache module resolution
@@ -82,7 +82,7 @@ config.resolve = {
// Module optimization
config.module = {
...config.module,
...(config.module || {}),
// Disable parsing for known pre-built modules
noParse: [
/kotlin\.js$/,
@@ -94,7 +94,7 @@ config.module = {
if (config.mode === 'production') {
// Production-specific optimizations
config.output = {
...config.output,
...(config.output || {}),
// Better file names for caching
filename: '[name].[contenthash:8].js',
chunkFilename: '[name].[contenthash:8].chunk.js'
@@ -102,7 +102,7 @@ if (config.mode === 'production') {
// Additional production optimizations
config.optimization = {
...config.optimization,
...(config.optimization || {}),
// Enable module concatenation (scope hoisting)
concatenateModules: true,
// Remove empty chunks