Skip to content

Commit bcd906e

Browse files
committed
add dependency optimizations automatically
1 parent 00352c2 commit bcd906e

File tree

1 file changed

+16
-1
lines changed
  • packages/analytics/modules/analytics

1 file changed

+16
-1
lines changed

packages/analytics/modules/analytics/index.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import 'wxt';
22
import 'wxt/sandbox';
3-
import { addAlias, addWxtPlugin, defineWxtModule } from 'wxt/modules';
3+
import {
4+
addAlias,
5+
addViteConfig,
6+
addWxtPlugin,
7+
defineWxtModule,
8+
} from 'wxt/modules';
49
import { relative, resolve } from 'node:path';
510
import type { AnalyticsConfig } from './types';
611

@@ -72,5 +77,15 @@ export default defineWxtModule({
7277
// Ensure analytics is initialized in every context, mainly the background.
7378
// TODO: Once there's a way to filter which entrypoints a plugin is applied to, only apply this to the background
7479
addWxtPlugin(wxt, pluginModuleId);
80+
81+
// Fix issues with dependencies
82+
addViteConfig(wxt, () => ({
83+
optimizeDeps: {
84+
// Ensure the "#analytics" import is processed by vite in the background plugin
85+
exclude: ['@wxt-dev/analytics'],
86+
// Ensure the CJS subdependency is preprocessed into ESM
87+
include: ['@wxt-dev/analytics > ua-parser-js'],
88+
},
89+
}));
7590
},
7691
});

0 commit comments

Comments
 (0)