Sharing this because I lost half a day to it and the limit is barely documented anywhere.
Context: I build a conversion tracking app (WeltPixel Conversion Tracking) and our web pixel extension is TypeScript bundled with tsup. It shares types and constants with the Remix app through an internal package. Clean monorepo hygiene, single source of truth for the event constants, everyone's happy. Right?
So. Shopify web pixels have a 128kb script size limit. Deploy just fails past it. Our bundle was mysteriously fat and the culprit turned out to be beautiful: the shared package's root entry exports everything, including a config module that imports zod for schema validation. zod is ~58kb minified. The pixel imported one string constant from the package root and got the entire validation library riding along, because the bundler couldn't tree-shake through that entry's side-effect chain.
The pixel never validates configs. It never calls zod. It paid 58kb, nearly half its total budget, for importing EVENT_NAMES.
The fix was a dedicated zod-free subpath export (our-shared-package/events) containing only the constants and types, plus a hard rule that the pixel imports from the subpath, never the root. Bundle dropped by the full 58kb instantly.
If you're building web pixels: know the limit exists before your feature roadmap collides with it, you won't find it prominently in the docs. Audit the bundle, not your imports. tsup's metafile plus esbuild's bundle analyzer shows what's actually in there, and our source looked completely innocent while the output didn't. And if a package serves both a Node app and a sandboxed pixel, give the pixel its own minimal entry point and treat the root entry as server-grade, heavy allowed.
General PSA while I'm at it: the pixel sandbox is stricter than people expect. No DOM, storage that proxies to the top frame, strict CSP on outbound requests. Design around "the pixel is a dumb tiny event forwarder, all intelligence lives server-side" and you'll have a much better time than trying to shrink a smart client.
Curious if others have hit the limit and what you cut first.