dotCMS / dotCMS/core

[SDK][Experiments] Remove bundled core-js polyfills and reduce consumer bundle size

Open
#37,570 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

dotCMS : SDK javascript OKR : Application Performance
Dominant language
Java
Stars
970
Forks
486
Avg merge
3d 33m
Merged PRs (30d)
170

Description

Description

The published @dotcms/experiments package is a single large module exporting only withExperiments.

Current artifact observations:

  • core-web/dist/libs/sdk/experiments/index.esm.js: approximately 256 KB raw.
  • An isolated minified consumer import measured approximately 108 KB raw / 41.5 KB gzip.
  • The artifact contains many core-js fingerprints and global-patching code alongside the experiments/Jitsu implementation.

Because the package exposes one feature from one flat module, consumers cannot tree-shake the internal implementation. More importantly, adding sideEffects: false now may be unsafe: the bundled compatibility code appears to modify globals during module evaluation.

Relevant files:

  • core-web/libs/sdk/experiments/src/index.ts
  • core-web/libs/sdk/experiments/src/lib/components/withExperiments.tsx
  • core-web/libs/sdk/experiments/src/lib/dot-experiments.ts
  • core-web/libs/sdk/experiments/rollup.config.cjs
  • core-web/dist/libs/sdk/experiments/index.esm.js

Determine whether core-js is introduced by Jitsu, Babel/Rollup configuration, or another build-stage dependency. Remove the inlined polyfills rather than hiding them with side-effect metadata. Consider externalizing or lazily importing the analytics transport after the source is confirmed.

Acceptance Criteria

  • The build identifies and documents the exact source/build stage that introduces core-js compatibility code.
  • The published experiments artifact no longer contains bundled core-js global patches that modern supported consumers do not need.
  • Jitsu/analytics transport code is externalized, modernized, or loaded only when experiments require it.
  • sideEffects metadata is added only after verifying that shipped modules are side-effect safe.
  • A real consumer fixture records raw, minified, and gzip sizes before and after the change.
  • A bundle-size budget prevents reintroducing the current approximately 41.5 KB gzip cost.
  • Experiment assignment, persistence, redirects, click tracking, and analytics events continue to work.
  • Supported browser targets are documented and tested.

Priority

High

Additional Context

Do not solve this issue by setting sideEffects: false on the current artifact. That flag is a behavioral promise; it would be unsafe while module evaluation contains global-patching code.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with core-web/libs/sdk/experiments/rollup.config.cjs and the source entry points in src/index.ts, src/lib/components/withExperiments.tsx, and src/lib/dot-experiments.ts. Compare them with core-web/dist/libs/sdk/experiments/index.esm.js to trace the stage introducing core-js, then measure a real consumer fixture before and after. Done means the artifact avoids unwanted bundled global patches, required experiment behavior remains intact, and supported browsers and a size budget are documented and tested.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
build-system, frontend, performance
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.