Skip to content

Commit

Permalink
add dependency optimizations automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
aklinker1 committed Jan 7, 2025
1 parent 00352c2 commit bcd906e
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion packages/analytics/modules/analytics/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import 'wxt';
import 'wxt/sandbox';
import { addAlias, addWxtPlugin, defineWxtModule } from 'wxt/modules';
import {
addAlias,
addViteConfig,
addWxtPlugin,
defineWxtModule,
} from 'wxt/modules';
import { relative, resolve } from 'node:path';
import type { AnalyticsConfig } from './types';

Expand Down Expand Up @@ -72,5 +77,15 @@ export default defineWxtModule({
// Ensure analytics is initialized in every context, mainly the background.
// TODO: Once there's a way to filter which entrypoints a plugin is applied to, only apply this to the background
addWxtPlugin(wxt, pluginModuleId);

// Fix issues with dependencies
addViteConfig(wxt, () => ({
optimizeDeps: {
// Ensure the "#analytics" import is processed by vite in the background plugin
exclude: ['@wxt-dev/analytics'],
// Ensure the CJS subdependency is preprocessed into ESM
include: ['@wxt-dev/analytics > ua-parser-js'],
},
}));
},
});

0 comments on commit bcd906e

Please sign in to comment.