How do you stop duplicate dependencies from sneaking into a bundle?

Hey folks, I’m trying to lock down our frontend bundle because we keep shipping two copies of the same library after a minor dependency bump, and it’s a real risk for subtle state bugs (two singletons) plus a bigger payload.

// Vite/Rollup build snippet
export default {
  resolve: {
    dedupe: ["react", "zustand"],
    alias: {
      "zustand": require.resolve("zustand"),
    },
  },
};

What’s the most reliable way you’ve found to enforce a single instance across transitive deps in real projects without breaking installs or spending all day chasing lockfile edge cases?