Skip to content

fix(akamai-edgeworker-sdk): reduce bundles with dual ESM and CJS output - #2171

Merged
joker23 merged 3 commits into
launchdarkly:mainfrom
jthorupp:akamai-bundle-size
Nov 6, 2026
Merged

joker23 merged 3 commits into
launchdarkly:mainfrom
jthorupp:akamai-bundle-size

Conversation

@jthorupp

@jthorupp jthorupp commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

Related bundle-size and ESM work: #1877, #1972, and #1885.

Describe the solution you've provided

Build @launchdarkly/akamai-edgeworker-sdk-common with tsup to publish both ESM and CommonJS JavaScript and declarations. Add conditional exports and sideEffects: false so ESM consumers, including the Akamai EdgeKV SDK's Rollup build, can analyze named imports instead of traversing CommonJS re-export wrappers. Retain the existing CommonJS dist/index.js entry and package type. No new runtime dependencies.

Add a build-specific TypeScript configuration using bundler resolution, and update clean to remove all generated outputs. Source maps retain mappings without embedding source contents, matching the server-common build pattern.

Make CryptoJS subpath imports explicitly include .js and access Akamai's crypto export through a namespace import. These compatibility fixes preserve the shared package's previously passing Node ESM import check without changing how random values are obtained on Akamai. Add a unit test verifying that random identifier generation uses the mocked Akamai crypto.getRandomValues export.

Rebuilding the Akamai EdgeKV SDK with the same locally installed dependencies before and after the change produced the following sizes. After sizes include the follow-up ESM compatibility fixes:

Artifact Before (bytes) After (bytes) Reduction
ESM raw 212,462 198,488 13,974 (6.6%)
ESM gzip (level 9) 60,452 57,327 3,125 (5.2%)
CJS raw 212,074 199,891 12,183 (5.7%)
CJS gzip (level 9) 60,225 57,703 2,522 (4.2%)

Downstream EdgeWorker measurements

A downstream Akamai EdgeWorker application was rebuilt using the locally built SDK packages in place of published SDK version 1.4.51. Application source and bundler settings were unchanged: tsup, ESM output, ES2022 target, minification and tree shaking enabled.

Worker artifact Published SDK (bytes) Local SDK build (bytes) Reduction
JavaScript bundle, raw 230,018 200,102 29,916 (13.0%)
JavaScript bundle, gzip (Node default compression) 67,996 59,535 8,461 (12.4%)
Deployment archive 68,427 59,954 8,473 (12.4%)

The published-SDK rebuild reproduced the baseline bundle byte-for-byte, and a repeat build with the local SDK produced the same JavaScript size. Archive sizes varied by a few bytes with metadata. These are measurements from one downstream application, not a guarantee of savings for every consumer. Initialization CPU time and Akamai runtime performance were not measured.

Describe alternatives you've considered

The Akamai EdgeKV SDK already minifies with Terser. Changing its public entry point or replacing SDK functionality in the worker would be broader changes; this experiment retains its existing bundled output and uses ESM at the shared-package boundary. Publishing ESM does not guarantee unused client methods can be removed, because functionality reachable through init still needs to be retained.

Additional context

Validation performed locally on Node v24.22.1:

  • yarn workspaces foreach -pR --topological-dev --from '@launchdarkly/akamai-server-edgekv-sdk' run build — passed.
  • yarn workspace @launchdarkly/akamai-edgeworker-sdk-common test — passed: 9 suites, 45 tests, including the new Akamai crypto regression test.
  • yarn workspace @launchdarkly/akamai-server-edgekv-sdk test — passed: 2 suites, 9 tests.
  • yarn workspace @launchdarkly/akamai-edgeworker-sdk-common lint — passed with existing test warnings.
  • yarn workspace @launchdarkly/akamai-edgeworker-sdk-common format:check — passed.
  • yarn workspace @launchdarkly/akamai-server-edgekv-sdk lint — passed with an existing unused catch-variable warning.
  • yarn workspace @launchdarkly/akamai-server-edgekv-sdk format:check — passed.
  • git diff --check — passed.
  • Packed-package compatibility: invoked the repository's scripts/package-config-tests/suites/types.js, runtime.js, and attw.js through a session-local helper against six relevant packed packages (Akamai shared and EdgeKV, common, server-common, Node server, and eventsource), installed into isolated consumer projects. All 144 TypeScript cases, 42 runtime/import/bundling cases, and 28 declaration-analysis cases matched their checked-in baselines. This includes TypeScript 5.0.4, 5.9.3, and 6.0.3. Baselines include known failures; matching the baseline does not mean every case passes. No baselines were changed. This was a targeted subset, not the full repository-wide package-config matrix.
  • Downstream application build and existing unit tests — passed. Those tests mock the LaunchDarkly client and do not establish real flag-evaluation equivalence.
  • Generated downstream bundles passed JavaScript syntax checks and loaded in a Node VM with mocked Akamai built-ins for a basic request smoke test.

CommonJS and ESM imports of the packed shared Akamai package now match the passing runtime baseline, and all conditional export targets exist. The EdgeKV Rollup build successfully consumes the new ESM entry. No Akamai runtime deployment or full supported-platform matrix was exercised. The PR's package-config workflow requires maintainer approval before it can run on this fork.


Note

Overview
Replaces tsc with tsup so @launchdarkly/akamai-edgeworker-sdk-common ships ESM and CJS (dist/index.mjs / dist/index.js) plus conditional exports, module, and sideEffects: false so ESM consumers can tree-shake instead of pulling the whole CommonJS surface.

Adds tsconfig.build.json (bundler resolution) and tsup.config.ts (dual format, DTS, source maps without embedded sources). Clean now wipes dist entirely.

Crypto compatibility for the new bundle: CryptoJS imports use explicit .js subpaths, and Akamai’s runtime crypto is read via a namespace import as AkamaiCrypto.crypto.getRandomValues (same random-ID behavior). A Jest mock + unit test locks that path.

Reviewed by Cursor Bugbot for commit 0e971c8. Bugbot is set up for automated code reviews on this repo. Configure here.

@jthorupp

jthorupp commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

A few items to verify before merging:

  • Approve and run the full PR CI, especially the published-package compatibility matrix. The targeted local checks matched the existing baselines, but do not replace the full matrix.
  • Confirm whether deep imports into this package are supported. Adding the root exports map restricts previously accessible subpaths; if consumers rely on them, we should preserve the supported paths or handle this as a compatibility change.
  • Verify the built SDK in the Akamai runtime, covering initialization, EdgeKV reads, flag evaluation (including rollouts and segments), and flushing when events are enabled. The local tests and mocked downstream smoke test do not establish real Akamai runtime equivalence.

The measured bundle-size reduction looks useful; these checks are about confirming packaging and runtime compatibility before landing it.

@jthorupp
jthorupp marked this pull request as ready for review November 5, 2026 09:58
@jthorupp
jthorupp requested a review from a team as a code owner November 5, 2026 09:58

@joker23 joker23 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jthorupp for the contribution! I just have a few minor comments.

@jthorupp
jthorupp requested a review from joker23 November 6, 2026 15:47

@joker23 joker23 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again @jthorupp - your fix should be live in the next release batch

@joker23
joker23 merged commit 1504e6c into launchdarkly:main Nov 6, 2026
65 checks passed
@github-actions github-actions Bot mentioned this pull request Nov 6, 2026
joker23 pushed a commit that referenced this pull request Nov 6, 2026
🤖 I have created a release *beep* *boop*
---


<details><summary>akamai-edgeworker-sdk-common: 2.0.49</summary>

##
[2.0.49](akamai-edgeworker-sdk-common-v2.0.48...akamai-edgeworker-sdk-common-v2.0.49)
(2026-11-06)


### Bug Fixes

* **akamai-edgeworker-sdk:** reduce bundles with dual ESM and CJS output
([#2171](#2171))
([1504e6c](1504e6c))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-server-sdk-common bumped from ^2.26.3 to ^2.26.4
</details>

<details><summary>akamai-server-base-sdk: 3.0.50</summary>

##
[3.0.50](akamai-server-base-sdk-v3.0.49...akamai-server-base-sdk-v3.0.50)
(2026-11-06)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
* @launchdarkly/akamai-edgeworker-sdk-common bumped from ^2.0.48 to
^2.0.49
</details>

<details><summary>akamai-server-edgekv-sdk: 1.4.52</summary>

##
[1.4.52](akamai-server-edgekv-sdk-v1.4.51...akamai-server-edgekv-sdk-v1.4.52)
(2026-11-06)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
* @launchdarkly/akamai-edgeworker-sdk-common bumped from ^2.0.48 to
^2.0.49
    * @launchdarkly/js-server-sdk-common bumped from ^2.26.3 to ^2.26.4
</details>

<details><summary>client-testing-plugin: 1.0.31</summary>

##
[1.0.31](client-testing-plugin-v1.0.30...client-testing-plugin-v1.0.31)
(2026-11-06)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-client-sdk-common bumped from 1.35.1 to 1.35.2
  * devDependencies
    * @launchdarkly/js-client-sdk bumped from 4.14.1 to 4.14.2
    * @launchdarkly/react-sdk bumped from 4.2.1 to 4.2.2
  * peerDependencies
    * @launchdarkly/js-client-sdk bumped from ^4.9.1 to ^4.14.2
    * @launchdarkly/react-sdk bumped from ^4.1.4 to ^4.2.2
</details>

<details><summary>cloudflare-server-sdk: 2.7.51</summary>

##
[2.7.51](cloudflare-server-sdk-v2.7.50...cloudflare-server-sdk-v2.7.51)
(2026-11-06)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
* @launchdarkly/js-server-sdk-common-edge bumped from 2.6.46 to 2.6.47
</details>

<details><summary>eventsource: 0.2.4</summary>

##
[0.2.4](eventsource-v0.2.3...eventsource-v0.2.4)
(2026-11-06)


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @launchdarkly/js-sdk-common bumped from 2.32.1 to 2.32.2
</details>

<details><summary>fastly-server-sdk: 0.2.41</summary>

##
[0.2.41](fastly-server-sdk-v0.2.40...fastly-server-sdk-v0.2.41)
(2026-11-06)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-server-sdk-common bumped from 2.26.3 to 2.26.4
</details>

<details><summary>jest: 1.0.41</summary>

##
[1.0.41](jest-v1.0.40...jest-v1.0.41)
(2026-11-06)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
* @launchdarkly/react-native-client-sdk bumped from ~10.23.3 to ~10.23.4
</details>

<details><summary>js-client-sdk: 4.14.2</summary>

##
[4.14.2](js-client-sdk-v4.14.1...js-client-sdk-v4.14.2)
(2026-11-06)


### Bug Fixes

* Keep JSDoc in sdk-client declarations and show inherited LDClient docs
([#2181](#2181))
([09b5f99](09b5f99))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-client-sdk-common bumped from 1.35.1 to 1.35.2
  * optionalDependencies
    * @launchdarkly/eventsource bumped from 0.2.3 to 0.2.4
</details>

<details><summary>js-client-sdk-common: 1.35.2</summary>

##
[1.35.2](js-client-sdk-common-v1.35.1...js-client-sdk-common-v1.35.2)
(2026-11-06)


### Bug Fixes

* Keep JSDoc in sdk-client declarations and show inherited LDClient docs
([#2181](#2181))
([09b5f99](09b5f99))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-sdk-common bumped from 2.32.1 to 2.32.2
</details>

<details><summary>js-sdk-common: 2.32.2</summary>

##
[2.32.2](js-sdk-common-v2.32.1...js-sdk-common-v2.32.2)
(2026-11-06)


### Bug Fixes

* Handle flag keys that are names of built-in object members
([#2170](#2170))
([4a18699](4a18699))
</details>

<details><summary>js-server-sdk-common: 2.26.4</summary>

##
[2.26.4](js-server-sdk-common-v2.26.3...js-server-sdk-common-v2.26.4)
(2026-11-06)


### Bug Fixes

* Avoid querying a persistent store on every evaluation of an unknown
flag ([#2169](#2169))
([da1cd35](da1cd35))
* Handle flag keys that are names of built-in object members
([#2170](#2170))
([4a18699](4a18699))
* Keep a flag named __proto__ in file data, change events and persistent
store reads
([#2174](#2174))
([1ffb29b](1ffb29b))
* Make TestData valueForAll return its value when targeting is off
([#2177](#2177))
([fc8c1f6](fc8c1f6))
* Prevent TestData from throwing for a flag named constructor or
toString ([#2173](#2173))
([4e58d1d](4e58d1d))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-sdk-common bumped from 2.32.1 to 2.32.2
</details>

<details><summary>js-server-sdk-common-edge: 2.6.47</summary>

##
[2.6.47](js-server-sdk-common-edge-v2.6.46...js-server-sdk-common-edge-v2.6.47)
(2026-11-06)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-server-sdk-common bumped from 2.26.3 to 2.26.4
</details>

<details><summary>node-client-sdk: 4.4.3</summary>

##
[4.4.3](node-client-sdk-v4.4.2...node-client-sdk-v4.4.3)
(2026-11-06)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/eventsource bumped from 0.2.3 to 0.2.4
    * @launchdarkly/js-client-sdk-common bumped from 1.35.1 to 1.35.2
</details>

<details><summary>node-server-sdk: 9.16.4</summary>

##
[9.16.4](node-server-sdk-v9.16.3...node-server-sdk-v9.16.4)
(2026-11-06)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/eventsource bumped from 0.2.3 to 0.2.4
    * @launchdarkly/js-server-sdk-common bumped from 2.26.3 to 2.26.4
</details>

<details><summary>node-server-sdk-dynamodb: 6.4.7</summary>

##
[6.4.7](node-server-sdk-dynamodb-v6.4.6...node-server-sdk-dynamodb-v6.4.7)
(2026-11-06)


### Bug Fixes

* Avoid querying a persistent store on every evaluation of an unknown
flag ([#2169](#2169))
([da1cd35](da1cd35))


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @launchdarkly/node-server-sdk bumped from 9.16.3 to 9.16.4
  * peerDependencies
    * @launchdarkly/node-server-sdk bumped from >=9.14.1 to >=9.16.4
</details>

<details><summary>node-server-sdk-otel: 1.3.43</summary>

##
[1.3.43](node-server-sdk-otel-v1.3.42...node-server-sdk-otel-v1.3.43)
(2026-11-06)


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @launchdarkly/node-server-sdk bumped from 9.16.3 to 9.16.4
  * peerDependencies
    * @launchdarkly/node-server-sdk bumped from >=9.11.3 to >=9.16.4
</details>

<details><summary>node-server-sdk-redis: 4.4.7</summary>

##
[4.4.7](node-server-sdk-redis-v4.4.6...node-server-sdk-redis-v4.4.7)
(2026-11-06)


### Bug Fixes

* Avoid querying a persistent store on every evaluation of an unknown
flag ([#2169](#2169))
([da1cd35](da1cd35))


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @launchdarkly/node-server-sdk bumped from 9.16.3 to 9.16.4
  * peerDependencies
    * @launchdarkly/node-server-sdk bumped from >=9.14.1 to >=9.16.4
</details>

<details><summary>openfeature-cloudflare-server: 1.2.0</summary>

##
[1.2.0](openfeature-cloudflare-server-v1.1.3...openfeature-cloudflare-server-v1.2.0)
(2026-11-06)


### Features

* Add an initialization timeout option to the OpenFeature Cloudflare
provider ([#2182](#2182))
([ba6ee3a](ba6ee3a))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
* @launchdarkly/openfeature-js-server-common bumped from 2.2.2 to 2.2.3
  * devDependencies
    * @launchdarkly/cloudflare-server-sdk bumped from 2.7.50 to 2.7.51
  * peerDependencies
    * @launchdarkly/cloudflare-server-sdk bumped from ^2.7.0 to ^2.7.51
</details>

<details><summary>openfeature-js-server-common: 2.2.3</summary>

##
[2.2.3](openfeature-js-server-common-v2.2.2...openfeature-js-server-common-v2.2.3)
(2026-11-06)


### Bug Fixes

* Align OpenFeature context conversion log levels with the provider spec
([#2183](#2183))
([c356b22](c356b22))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-sdk-common bumped from 2.32.1 to 2.32.2
</details>

<details><summary>openfeature-node-server: 2.1.7</summary>

##
[2.1.7](openfeature-node-server-v2.1.6...openfeature-node-server-v2.1.7)
(2026-11-06)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
* @launchdarkly/openfeature-js-server-common bumped from 2.2.2 to 2.2.3
  * devDependencies
    * @launchdarkly/node-server-sdk bumped from 9.16.3 to 9.16.4
  * peerDependencies
    * @launchdarkly/node-server-sdk bumped from ^9.0.0 to ^9.16.4
</details>

<details><summary>react-native-client-sdk: 10.23.4</summary>

##
[10.23.4](react-native-client-sdk-v10.23.3...react-native-client-sdk-v10.23.4)
(2026-11-06)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-client-sdk-common bumped from 1.35.1 to 1.35.2
</details>

<details><summary>react-sdk: 4.2.2</summary>

##
[4.2.2](react-sdk-v4.2.1...react-sdk-v4.2.2)
(2026-11-06)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-client-sdk bumped from 4.14.1 to 4.14.2
    * @launchdarkly/js-server-sdk-common bumped from 2.26.3 to 2.26.4
</details>

<details><summary>server-sdk-ai: 2.0.20</summary>

##
[2.0.20](server-sdk-ai-v2.0.19...server-sdk-ai-v2.0.20)
(2026-11-06)


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @launchdarkly/js-server-sdk-common bumped from 2.26.3 to 2.26.4
  * peerDependencies
    * @launchdarkly/js-server-sdk-common bumped from ^2.0.0 to ^2.26.4
</details>

<details><summary>server-sdk-ai-langchain: 0.8.31</summary>

##
[0.8.31](server-sdk-ai-langchain-v0.8.30...server-sdk-ai-langchain-v0.8.31)
(2026-11-06)


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @launchdarkly/server-sdk-ai bumped from ^2.0.19 to ^2.0.20
  * peerDependencies
* @launchdarkly/server-sdk-ai bumped from ^1.1.1 || ^2.0.0 to ^2.0.20
</details>

<details><summary>server-sdk-ai-openai: 0.7.31</summary>

##
[0.7.31](server-sdk-ai-openai-v0.7.30...server-sdk-ai-openai-v0.7.31)
(2026-11-06)


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @launchdarkly/js-server-sdk-common bumped from 2.26.3 to 2.26.4
    * @launchdarkly/server-sdk-ai bumped from ^2.0.19 to ^2.0.20
  * peerDependencies
* @launchdarkly/server-sdk-ai bumped from ^1.1.1 || ^2.0.0 to ^2.0.20
</details>

<details><summary>server-sdk-ai-vercel: 0.7.31</summary>

##
[0.7.31](server-sdk-ai-vercel-v0.7.30...server-sdk-ai-vercel-v0.7.31)
(2026-11-06)


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @launchdarkly/server-sdk-ai bumped from ^2.0.19 to ^2.0.20
  * peerDependencies
* @launchdarkly/server-sdk-ai bumped from ^1.1.1 || ^2.0.0 to ^2.0.20
</details>

<details><summary>shopify-oxygen-sdk: 0.2.6</summary>

##
[0.2.6](shopify-oxygen-sdk-v0.2.5...shopify-oxygen-sdk-v0.2.6)
(2026-11-06)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-server-sdk-common bumped from 2.26.3 to 2.26.4
</details>

<details><summary>vercel-server-sdk: 1.3.74</summary>

##
[1.3.74](vercel-server-sdk-v1.3.73...vercel-server-sdk-v1.3.74)
(2026-11-06)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
* @launchdarkly/js-server-sdk-common-edge bumped from 2.6.46 to 2.6.47
</details>

<details><summary>vue-client-sdk: 3.0.11</summary>

##
[3.0.11](vue-client-sdk-v3.0.10...vue-client-sdk-v3.0.11)
(2026-11-06)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-client-sdk bumped from 4.14.1 to 4.14.2
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Overview**
> Cuts the Release Please rollout that bumps every published workspace
package, refreshes `.release-please-manifest.json`, and backfills
changelog entries with the new semver tags.
> 
> Functional follow-ups ride along in the version drift:
`js-sdk-common`/`js-server-sdk-common` pick up the flag-key edge-case
fixes, persistent-store short-circuit, and TestData corrections called
out in their notes; `openfeature-cloudflare-server` graduates to `1.2.0`
with an explicit initialization timeout knob wired through
`LaunchDarklyProvider`, while the Akamai common SDK emits slimmer dual
ESM/CJS bundles. Client surfaces (`js-client-sdk`, React/Vue/React
Native wrappers, testing plugin, etc.) absorb the refreshed common
packages so generated typings keep inherited JSDoc.
> 
> Everywhere else is mechanical—AI provider peers now pin
`@launchdarkly/server-sdk-ai` `^2.0.20`, Cloudflare/Fastly/Vercel edge
SDKs advance `js-server-sdk-common-edge`, Redis/Dynamo/OTEL integrations
raise their `node-server-sdk` floor, and sample apps mirror the new
dependency graph.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
52dbf7b. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants