Skip to content

Conversation

@jsonbailey
Copy link
Contributor

@jsonbailey jsonbailey commented Nov 19, 2025

The dynamic loading of packages was failing in Next.js applications due to treeshaking. Even if you had the package installed, it would be excluded at runtime because it determined it was not needed. Instead of dynamically requiring a package, we explicitly import the package name which helps the process identify packages to include.


Note

Migrates server AI SDK and provider packages to ESM with tsup-built dual outputs, replaces require with dynamic imports for provider loading, and adds sdkInfo/version wiring with config updates.

  • Build/System
    • Switch all AI packages to ESM with dual outputs (module ESM, main CJS) and explicit exports maps; include files: ["dist"].
    • Replace tsc builds with tsup and add tsup.config.ts per package.
    • Update tsconfig targets/modules (ES2020/ESNext), module resolution, and ESLint includes.
    • Update release-please to track packages/sdk/server-ai/src/sdkInfo.ts and example dependencies.
  • Server AI SDK (packages/sdk/server-ai)
    • Replace CJS require flow with dynamic import in AIProviderFactory and enhance debug/warn logging.
    • Add src/sdkInfo.ts and use aiSdkName/aiSdkVersion throughout (tests and tracker); stop importing from package.json.
    • Adjust index.ts to export LDLogger type via namespace import for CJS compatibility.
    • Normalize Mustache imports to default import in LDAIClientImpl and api/judge/Judge.
  • Provider packages (server-ai-openai, server-ai-langchain, server-ai-vercel)
    • Update package metadata for dual ESM/CJS, add tsup build, and modernize TS configs.

Written by Cursor Bugbot for commit 0d9b6ac. This will update automatically on new commits. Configure here.

@jsonbailey jsonbailey requested a review from a team as a code owner November 19, 2025 14:53
@github-actions
Copy link
Contributor

@launchdarkly/browser size report
This is the brotli compressed size of the ESM build.
Compressed size: 169118 bytes
Compressed size limit: 200000
Uncompressed size: 789399 bytes

@github-actions
Copy link
Contributor

@launchdarkly/js-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 24988 bytes
Compressed size limit: 26000
Uncompressed size: 122411 bytes

@github-actions
Copy link
Contributor

@launchdarkly/js-client-sdk size report
This is the brotli compressed size of the ESM build.
Compressed size: 21981 bytes
Compressed size limit: 25000
Uncompressed size: 75580 bytes

@github-actions
Copy link
Contributor

@launchdarkly/js-client-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 17636 bytes
Compressed size limit: 20000
Uncompressed size: 90259 bytes

@jsonbailey jsonbailey changed the title fix! Change to ES Modules to improve support of dynamic loading fix!: Change to ES Modules to improve support of dynamic loading Nov 19, 2025
"typescript": "5.1.6"
},
"peerDependencies": {
"@langchain/community": "^0.2.0 || ^0.3.0",
Copy link
Contributor Author

@jsonbailey jsonbailey Nov 19, 2025

Choose a reason for hiding this comment

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

The community packages are nested (@langchain/community/chat_models/fireworks vs @langchain/aws) which causes runtime compile errors in Next.js when trying to load our langchain package. It's possible when we upgrade to langchain v1 this issue might go away but I was not able to get it to load without this additional dependency, even if it is not being used.

@jsonbailey jsonbailey merged commit 11de076 into main Nov 21, 2025
36 checks passed
@jsonbailey jsonbailey deleted the jb/sdk-1634/fix-dynamic-provider branch November 21, 2025 14:55
@github-actions github-actions bot mentioned this pull request Nov 21, 2025
jsonbailey added a commit that referenced this pull request Nov 21, 2025
🤖 I have created a release *beep* *boop*
---


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

##
[3.0.11](akamai-server-base-sdk-v3.0.10...akamai-server-base-sdk-v3.0.11)
(2025-11-21)


### Bug Fixes

* Use release-please to update SDK versions
([#1013](#1013))
([d1d11f1](d1d11f1))
</details>

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

##
[1.4.13](akamai-server-edgekv-sdk-v1.4.12...akamai-server-edgekv-sdk-v1.4.13)
(2025-11-21)


### Bug Fixes

* Use release-please to update SDK versions
([#1013](#1013))
([d1d11f1](d1d11f1))
</details>

<details><summary>browser-telemetry: 1.0.12</summary>

##
[1.0.12](browser-telemetry-v1.0.11...browser-telemetry-v1.0.12)
(2025-11-21)


### Dependencies

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

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

##
[0.2.2](fastly-server-sdk-v0.2.1...fastly-server-sdk-v0.2.2)
(2025-11-21)


### Bug Fixes

* Use release-please to update SDK versions
([#1013](#1013))
([d1d11f1](d1d11f1))
</details>

<details><summary>jest: 0.1.13</summary>

##
[0.1.13](jest-v0.1.12...jest-v0.1.13)
(2025-11-21)


### Dependencies

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

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

##
[0.9.0](js-client-sdk-v0.8.1...js-client-sdk-v0.9.0)
(2025-11-21)


### ⚠ BREAKING CHANGES

* Only support identify with result.
([#1000](#1000))

### Features

* Only support identify with result.
([#1000](#1000))
([7163adf](7163adf))
</details>

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

##
[9.10.3](node-server-sdk-v9.10.2...node-server-sdk-v9.10.3)
(2025-11-21)


### Bug Fixes

* Use release-please to update SDK versions
([#1013](#1013))
([d1d11f1](d1d11f1))
</details>

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

##
[6.2.15](node-server-sdk-dynamodb-v6.2.14...node-server-sdk-dynamodb-v6.2.15)
(2025-11-21)


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @launchdarkly/node-server-sdk bumped from 9.10.2 to 9.10.3
  * peerDependencies
    * @launchdarkly/node-server-sdk bumped from >=9.4.3 to >=9.10.3
</details>

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

##
[1.3.3](node-server-sdk-otel-v1.3.2...node-server-sdk-otel-v1.3.3)
(2025-11-21)


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @launchdarkly/node-server-sdk bumped from 9.10.2 to 9.10.3
  * peerDependencies
    * @launchdarkly/node-server-sdk bumped from >=9.4.3 to >=9.10.3
</details>

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

##
[4.2.15](node-server-sdk-redis-v4.2.14...node-server-sdk-redis-v4.2.15)
(2025-11-21)


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @launchdarkly/node-server-sdk bumped from 9.10.2 to 9.10.3
  * peerDependencies
    * @launchdarkly/node-server-sdk bumped from >=9.4.3 to >=9.10.3
</details>

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

##
[10.12.1](react-native-client-sdk-v10.12.0...react-native-client-sdk-v10.12.1)
(2025-11-21)


### Bug Fixes

* Use release-please to update SDK versions
([#1013](#1013))
([d1d11f1](d1d11f1))
</details>

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

##
[0.15.0](server-sdk-ai-v0.14.1...server-sdk-ai-v0.15.0)
(2025-11-21)


### ⚠ BREAKING CHANGES

* Change to ES Modules to improve support of dynamic loading
([#1011](#1011))

### Bug Fixes

* Change to ES Modules to improve support of dynamic loading
([#1011](#1011))
([11de076](11de076))
</details>

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

##
[0.4.0](server-sdk-ai-langchain-v0.3.1...server-sdk-ai-langchain-v0.4.0)
(2025-11-21)


### ⚠ BREAKING CHANGES

* Change to ES Modules to improve support of dynamic loading
([#1011](#1011))

### Bug Fixes

* Change to ES Modules to improve support of dynamic loading
([#1011](#1011))
([11de076](11de076))


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @launchdarkly/server-sdk-ai bumped from ^0.14.1 to ^0.15.0
  * peerDependencies
    * @launchdarkly/server-sdk-ai bumped from ^0.14.0 to ^0.15.0
</details>

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

##
[0.4.0](server-sdk-ai-openai-v0.3.1...server-sdk-ai-openai-v0.4.0)
(2025-11-21)


### ⚠ BREAKING CHANGES

* Change to ES Modules to improve support of dynamic loading
([#1011](#1011))

### Bug Fixes

* Change to ES Modules to improve support of dynamic loading
([#1011](#1011))
([11de076](11de076))


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @launchdarkly/server-sdk-ai bumped from ^0.14.1 to ^0.15.0
  * peerDependencies
    * @launchdarkly/server-sdk-ai bumped from ^0.14.0 to ^0.15.0
</details>

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

##
[0.4.0](server-sdk-ai-vercel-v0.3.1...server-sdk-ai-vercel-v0.4.0)
(2025-11-21)


### ⚠ BREAKING CHANGES

* Change to ES Modules to improve support of dynamic loading
([#1011](#1011))

### Bug Fixes

* Change to ES Modules to improve support of dynamic loading
([#1011](#1011))
([11de076](11de076))


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @launchdarkly/server-sdk-ai bumped from ^0.14.1 to ^0.15.0
  * peerDependencies
    * @launchdarkly/server-sdk-ai bumped from ^0.14.0 to ^0.15.0
</details>

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

##
[1.3.35](vercel-server-sdk-v1.3.34...vercel-server-sdk-v1.3.35)
(2025-11-21)


### Bug Fixes

* Use release-please to update SDK versions
([#1013](#1013))
([d1d11f1](d1d11f1))
</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]
> Bumps versions across SDKs and providers, migrates AI providers to ES
modules, releases browser SDK 0.9.0 with a breaking identify API change,
and updates examples/tests and dependent packages accordingly.
> 
> - **AI Providers (server)**
> - **ESM migration (breaking)**:
`@launchdarkly/server-sdk-ai-{openai,langchain,vercel}` to `0.4.0`;
peer/dev deps updated to `@launchdarkly/server-sdk-ai@^0.15.0`.
> - **AI SDK**: `@launchdarkly/server-sdk-ai` to `0.15.0`; version
constant updated in `sdkInfo.ts`.
> - **Browser SDK**
> - **0.9.0 (breaking)**: only support identify with result; version
wired into `BrowserInfo.ts` and tests now read name/version from
`package.json`.
> - **Telemetry**: `@launchdarkly/browser-telemetry` to `1.0.12` (devDep
on browser SDK `0.9.0`).
> - **Edge/Server SDKs**
> - Akamai base to `3.0.11` and EdgeKV to `1.4.13`; version constants
and examples updated.
>   - Fastly to `0.2.2`; version constants and example updated.
>   - Vercel to `1.3.35`; version constant updated.
>   - Node server SDK to `9.10.3`; version constant updated.
> - **Stores/Telemetry tooling**
> - DynamoDB store to `6.2.15`, Redis store to `4.2.15`, OTEL to `1.3.3`
(devDeps bumped to Node SDK `9.10.3`).
>   - Jest tooling to `0.1.13` (dep on RN SDK `~10.12.1`).
> - **React Native**
>   - RN SDK to `10.12.1`; version constant updated.
> - **Manifest**
>   - `.release-please-manifest.json` updated for all version bumps.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
6a0e582. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: jsonbailey <jbailey@launchdarkly.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.

4 participants