fix(sdk-server-common): use subpath import for semver module - #1885
Conversation
|
@launchdarkly/browser size report |
|
@launchdarkly/js-sdk-common size report |
|
@launchdarkly/js-client-sdk size report |
|
@launchdarkly/js-client-sdk-common size report |
| */ | ||
| import type SemVer from 'semver/classes/semver'; | ||
| // eslint-disable-next-line @typescript-eslint/no-require-imports | ||
| import parse = require('semver/functions/parse'); |
There was a problem hiding this comment.
So, we have leaf-node packages that compile to ESM, this doesn't seem like a safe plan.
There was a problem hiding this comment.
yea this change does have a bad smell to it... it would probably be worth it to hold this off until we can produce shared ESM packages? I think we should head toward that direction so we can do tree-shaking.
63b54ba to
3ce2e3e
Compare
3ce2e3e to
78ded9f
Compare
| * package size for server SDKs. The `.js` extension is required: this package now | ||
| * compiles with `"module": "ESNext"` and `"moduleResolution": "bundler"`, and Node's own | ||
| * ESM resolver (unlike `require` or a bundler's resolution) does not probe for extensions | ||
| * on bare subpath specifiers, so the published ESM entry point fails to load without it. |
There was a problem hiding this comment.
This makes me pretty uneasy. So I am hoping for considerable exploration of how an end-2-end package behaves after this change.
78ded9f to
fcb7d11
Compare
fcb7d11 to
96e8ab3
Compare
| entry: { | ||
| index: 'src/index.ts', | ||
| }, | ||
| format: ['esm', 'cjs'], |
There was a problem hiding this comment.
🔴 Node 14 bundle fails to load
On Node 14, tsup-node can preserve ??= because no ES2017 target is configured. The supported runtime then rejects the bundle before SDK initialization.
Learn more
The old TypeScript build explicitly targeted ES2017, so syntax newer than Node 14 was downleveled. The new tsup build does not carry that target forward. tsup-node therefore uses its own newer default target and can retain logical nullish assignment from Evaluator. Node 14 cannot parse that syntax, although the Node SDK still declares Node 14 compatibility.
Example: A Node 14 service imports @launchdarkly/node-server-sdk. Loading its bundled server-common dependency reaches code containing state.events ??= []. Node throws a syntax error before the application can create a client.
Recommended fix: Set the tsup target to es2017, matching the replaced TypeScript build and the package's existing runtime contract. Add a smoke test that imports both published CJS and ESM outputs under the oldest supported Node version.
| format: ['esm', 'cjs'], | |
| format: ['esm', 'cjs'], | |
| target: 'es2017', |
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
This is a false positive - the final compilation happens in the leaf SDK and all of our builds are far past node 14
🤖 I have created a release *beep* *boop* --- <details><summary>akamai-edgeworker-sdk-common: 2.0.35</summary> ## [2.0.35](akamai-edgeworker-sdk-common-v2.0.34...akamai-edgeworker-sdk-common-v2.0.35) (2026-09-16) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-server-sdk-common bumped from ^2.21.3 to ^2.21.4 </details> <details><summary>akamai-server-base-sdk: 3.0.36</summary> ## [3.0.36](akamai-server-base-sdk-v3.0.35...akamai-server-base-sdk-v3.0.36) (2026-09-16) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/akamai-edgeworker-sdk-common bumped from ^2.0.34 to ^2.0.35 </details> <details><summary>akamai-server-edgekv-sdk: 1.4.38</summary> ## [1.4.38](akamai-server-edgekv-sdk-v1.4.37...akamai-server-edgekv-sdk-v1.4.38) (2026-09-16) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/akamai-edgeworker-sdk-common bumped from ^2.0.34 to ^2.0.35 * @launchdarkly/js-server-sdk-common bumped from ^2.21.3 to ^2.21.4 </details> <details><summary>client-testing-plugin: 1.0.17</summary> ## [1.0.17](client-testing-plugin-v1.0.16...client-testing-plugin-v1.0.17) (2026-09-16) ### Dependencies * The following workspace dependencies were updated * devDependencies * @launchdarkly/react-sdk bumped from 4.1.18 to 4.1.19 * peerDependencies * @launchdarkly/react-sdk bumped from ^4.1.4 to ^4.1.19 </details> <details><summary>cloudflare-server-sdk: 2.7.37</summary> ## [2.7.37](cloudflare-server-sdk-v2.7.36...cloudflare-server-sdk-v2.7.37) (2026-09-16) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-server-sdk-common-edge bumped from 2.6.32 to 2.6.33 </details> <details><summary>fastly-server-sdk: 0.2.27</summary> ## [0.2.27](fastly-server-sdk-v0.2.26...fastly-server-sdk-v0.2.27) (2026-09-16) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-server-sdk-common bumped from 2.21.3 to 2.21.4 </details> <details><summary>js-server-sdk-common: 2.21.4</summary> ## [2.21.4](js-server-sdk-common-v2.21.3...js-server-sdk-common-v2.21.4) (2026-09-16) ### Bug Fixes * **sdk-server-common:** use subpath import for `semver` module ([#1885](#1885)) ([2de6c8c](2de6c8c)) </details> <details><summary>js-server-sdk-common-edge: 2.6.33</summary> ## [2.6.33](js-server-sdk-common-edge-v2.6.32...js-server-sdk-common-edge-v2.6.33) (2026-09-16) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-server-sdk-common bumped from 2.21.3 to 2.21.4 </details> <details><summary>node-server-sdk: 9.13.6</summary> ## [9.13.6](node-server-sdk-v9.13.5...node-server-sdk-v9.13.6) (2026-09-16) ### Bug Fixes * **sdk-server-common:** use subpath import for `semver` module ([#1885](#1885)) ([2de6c8c](2de6c8c)) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-server-sdk-common bumped from 2.21.3 to 2.21.4 </details> <details><summary>node-server-sdk-dynamodb: 6.2.42</summary> ## [6.2.42](node-server-sdk-dynamodb-v6.2.41...node-server-sdk-dynamodb-v6.2.42) (2026-09-16) ### Dependencies * The following workspace dependencies were updated * devDependencies * @launchdarkly/node-server-sdk bumped from 9.13.5 to 9.13.6 * peerDependencies * @launchdarkly/node-server-sdk bumped from >=9.11.3 to >=9.13.6 </details> <details><summary>node-server-sdk-otel: 1.3.29</summary> ## [1.3.29](node-server-sdk-otel-v1.3.28...node-server-sdk-otel-v1.3.29) (2026-09-16) ### Dependencies * The following workspace dependencies were updated * devDependencies * @launchdarkly/node-server-sdk bumped from 9.13.5 to 9.13.6 * peerDependencies * @launchdarkly/node-server-sdk bumped from >=9.11.3 to >=9.13.6 </details> <details><summary>node-server-sdk-redis: 4.2.41</summary> ## [4.2.41](node-server-sdk-redis-v4.2.40...node-server-sdk-redis-v4.2.41) (2026-09-16) ### Dependencies * The following workspace dependencies were updated * devDependencies * @launchdarkly/node-server-sdk bumped from 9.13.5 to 9.13.6 * peerDependencies * @launchdarkly/node-server-sdk bumped from >=9.11.3 to >=9.13.6 </details> <details><summary>openfeature-cloudflare-server: 0.1.7</summary> ## [0.1.7](openfeature-cloudflare-server-v0.1.6...openfeature-cloudflare-server-v0.1.7) (2026-09-16) ### Dependencies * The following workspace dependencies were updated * devDependencies * @launchdarkly/cloudflare-server-sdk bumped from 2.7.36 to 2.7.37 * peerDependencies * @launchdarkly/cloudflare-server-sdk bumped from ^2.7.0 to ^2.7.37 </details> <details><summary>openfeature-node-server: 2.0.5</summary> ## [2.0.5](openfeature-node-server-v2.0.4...openfeature-node-server-v2.0.5) (2026-09-16) ### Dependencies * The following workspace dependencies were updated * devDependencies * @launchdarkly/node-server-sdk bumped from 9.13.5 to 9.13.6 * peerDependencies * @launchdarkly/node-server-sdk bumped from ^9.0.0 to ^9.13.6 </details> <details><summary>react-sdk: 4.1.19</summary> ## [4.1.19](react-sdk-v4.1.18...react-sdk-v4.1.19) (2026-09-16) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-server-sdk-common bumped from ^2.21.3 to ^2.21.4 </details> <details><summary>server-sdk-ai: 2.0.6</summary> ## [2.0.6](server-sdk-ai-v2.0.5...server-sdk-ai-v2.0.6) (2026-09-16) ### Dependencies * The following workspace dependencies were updated * devDependencies * @launchdarkly/js-server-sdk-common bumped from 2.21.3 to 2.21.4 * peerDependencies * @launchdarkly/js-server-sdk-common bumped from ^2.0.0 to ^2.21.4 </details> <details><summary>server-sdk-ai-langchain: 0.8.16</summary> ## [0.8.16](server-sdk-ai-langchain-v0.8.15...server-sdk-ai-langchain-v0.8.16) (2026-09-16) ### Dependencies * The following workspace dependencies were updated * devDependencies * @launchdarkly/server-sdk-ai bumped from ^2.0.5 to ^2.0.6 * peerDependencies * @launchdarkly/server-sdk-ai bumped from ^1.1.1 to ^2.0.6 </details> <details><summary>server-sdk-ai-openai: 0.7.16</summary> ## [0.7.16](server-sdk-ai-openai-v0.7.15...server-sdk-ai-openai-v0.7.16) (2026-09-16) ### Dependencies * The following workspace dependencies were updated * devDependencies * @launchdarkly/js-server-sdk-common bumped from 2.21.3 to 2.21.4 * @launchdarkly/server-sdk-ai bumped from ^2.0.5 to ^2.0.6 * peerDependencies * @launchdarkly/server-sdk-ai bumped from ^1.1.1 to ^2.0.6 </details> <details><summary>server-sdk-ai-vercel: 0.7.16</summary> ## [0.7.16](server-sdk-ai-vercel-v0.7.15...server-sdk-ai-vercel-v0.7.16) (2026-09-16) ### Dependencies * The following workspace dependencies were updated * devDependencies * @launchdarkly/server-sdk-ai bumped from ^2.0.5 to ^2.0.6 * peerDependencies * @launchdarkly/server-sdk-ai bumped from ^1.1.1 to ^2.0.6 </details> <details><summary>shopify-oxygen-sdk: 0.1.25</summary> ## [0.1.25](shopify-oxygen-sdk-v0.1.24...shopify-oxygen-sdk-v0.1.25) (2026-09-16) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-server-sdk-common bumped from 2.21.3 to 2.21.4 </details> <details><summary>vercel-server-sdk: 1.3.60</summary> ## [1.3.60](vercel-server-sdk-v1.3.59...vercel-server-sdk-v1.3.60) (2026-09-16) ### Bug Fixes * **sdk-server-common:** use subpath import for `semver` module ([#1885](#1885)) ([2de6c8c](2de6c8c)) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-server-sdk-common-edge bumped from 2.6.32 to 2.6.33 </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** > **Release Please** cut that publishes a coordinated monorepo release. The only functional change carried forward is **`@launchdarkly/js-server-sdk-common` 2.21.4**, which fixes **`semver` imports** to use subpath imports ([#1885](#1885)). > > Everything else in the diff is version propagation: patch bumps to **Node server SDK (9.13.6)**, **Vercel/Cloudflare/Fastly/Akamai/Shopify** edge SDKs, **React (4.1.19)**, **server AI** and **AI provider** packages, **OpenFeature** wrappers, **DynamoDB/Redis/OTEL** plugins, and matching **changelog**, **`package.json`**, **`x-release-please-version`** strings, example apps, and **`.release-please-manifest.json`**. Several AI provider changelogs also tighten **`@launchdarkly/server-sdk-ai` peer** ranges to **^2.0.6**. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 05435e0. 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>
This PR will use subpath imports for semver to reduce package size per suggestion from @jthorupp
Note
Overview
@launchdarkly/js-server-sdk-commonis republished as a dual ESM/CJS package (tsup instead oftsc), with conditionalexports,sideEffects: false, and TypeScript set toESNext/ bundler resolution.Semver usage is narrowed in
Operations.tsviasemver/functions/parse.jsandsemver/classes/semver(with an explicit.jsextension so Node’s ESM loader can resolve the subpath).Integration test helpers (
FileDataSourceFactory,TestData, builders) are re-exported by name from the common package root and fromserver-node’sintegrations.ts(direct re-export instead of destructuring). VercelEdgeFeatureStoretests mockreviveFullPayloadat module scope and assert call counts on that shared mock, with the real implementation restored inbeforeEachafterresetAllMocks.Reviewed by Cursor Bugbot for commit 96e8ab3. Bugbot is set up for automated code reviews on this repo. Configure here.