Skip to content

Update hello-js to use @launchdarkly/js-client-sdk v4#14

Open
joker23 wants to merge 1 commit intomainfrom
devin/SDK-1991-1772751399
Open

Update hello-js to use @launchdarkly/js-client-sdk v4#14
joker23 wants to merge 1 commit intomainfrom
devin/SDK-1991-1772751399

Conversation

@joker23
Copy link

@joker23 joker23 commented Mar 5, 2026

Summary

Migrates the hello-js example application from launchdarkly-js-client-sdk@3 to @launchdarkly/js-client-sdk@4.

Key changes:

  • Module loading: Replaced the global <script src="...@3"> tag with a <script type="module"> using an ESM import from unpkg
  • Initialization API: Replaced LDClient.initialize(clientSideID, context) with createClient(clientSideID, context) + await client.start()
  • Init handling: Replaced event-based initialization (on('initialized'), on('failed'), on('ready')) with the promise-based start() result pattern
  • Live updates: Preserved on('change', render) for reacting to flag changes
  • Also fixes minor indentation inconsistency in the render() function that existed in the original

Review & Testing Checklist for Human

  • Open index.html in a browser with a real clientSideID set and verify the SDK initializes, evaluates the flag, and displays the result. This was not tested during development.
  • Verify live flag updates work: Toggle the flag value in LaunchDarkly and confirm the page updates without a refresh (the on('change', render) listener).
  • Verify the ESM import from unpkg resolves correctly in target browsers — <script type="module"> with a bare unpkg URL. Confirm no CORS or module resolution issues.
  • Confirm start() behavior on failure: Set an invalid clientSideID and verify the "SDK failed to initialize" message appears (the else branch).

Notes

  • The v4 SDK (@launchdarkly/js-client-sdk) only ships ESM and CJS bundles (no UMD/IIFE), so the example now requires <script type="module"> instead of a classic script tag. This means it won't work in very old browsers that don't support ES modules.
  • Link to Devin session: https://app.devin.ai/sessions/c889568b4c3b4e96bfedd880004c9291
  • Requested by: @joker23

Open with Devin

- Replace launchdarkly-js-client-sdk@3 with @launchdarkly/js-client-sdk@4
- Use ES module import instead of global script tag
- Use createClient() + client.start() instead of LDClient.initialize()
- Handle initialization via start() promise result
- Update README to reference v4 SDK

Co-Authored-By: Steven Zhang <szhang@launchdarkly.com>
@devin-ai-integration
Copy link

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@devin-ai-integration devin-ai-integration bot added the devin-pr PR created by Devin label Mar 5, 2026
@joker23 joker23 marked this pull request as ready for review March 6, 2026 00:42
Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

@joker23 joker23 requested a review from a team March 6, 2026 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devin-pr PR created by Devin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant