Skip to content

@polymarket/client's published bundle is not tree-shakable — needs sideEffects: false + per-module ESM (or a separate perps entry) #287

Description

@cucumber-sp

The published @polymarket/client ships as a tsup-prebundled dist/ where every import path — the root, /actions, /viem — funnels through one monolithic shared chunk (dist/chunk-*.js, ~147KB unminified) that contains perps, RFQ/combos and websocket-subscription logic alongside the auth/approvals code.

Measured in our production build (Vite/Rolldown, but the mechanism is bundler-independent): using only createSecureClient, credential handling and the trading-approvals actions, we still ship 162KB minified / 44KB gzip of the client — ~80% of that shared chunk — with perps identifiers (perpsDepositContract, perpsSubscriptions, ArmPerpsAutoCancelError, combo types, …) surviving dead-code elimination into the final bundle. Subpath imports don't help because the subpaths re-export from the same chunk; /actions is a flat 150+-name barrel resolving into it.

Ask: publish with sideEffects: false and real per-module ESM output (preserveModules or equivalent), and/or split perps/RFQ into their own entry point or package — so consumers touching only the auth/trading surface don't pay for the rest. Happy to provide the full byte-attribution breakdown if useful.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions