Skip to content

Conversation

@joker23
Copy link
Contributor

@joker23 joker23 commented Jan 21, 2026

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

SDK-1705

Describe the solution you've provided

This PR replaces the ConfigurationImpl class with a createConfiguration() factory function following the CONTRIBUTING.md guidelines for preferring interfaces over classes. The factory function returns a Configuration interface object instead of instantiating a class, which results in better bundle size and minification potential.

Key changes:

  • Replaced ConfigurationImpl class with createConfiguration() factory function in Configuration.ts
  • Validation logic is inlined directly in the factory function for reduced bundle size
  • Uses object spread to construct the return value, excluding internal URI properties
  • Updated LDClientImpl to use createConfiguration() instead of new ConfigurationImpl()
  • Updated exports in configuration/index.ts to export createConfiguration (removed ConfigurationImpl)
  • Updated all test files to use createConfiguration() and verify properties through the public Configuration interface

Important for reviewers:

  1. The test assertions for baseUri, eventsUri, streamUri were changed to check serviceEndpoints.polling, serviceEndpoints.streaming, serviceEndpoints.events respectively - these internal URI properties are not part of the public Configuration interface
  2. Similarly, payloadFilterKey tests now check serviceEndpoints.payloadFilterKey since that's where the value is stored in the public interface
  3. ConfigurationImpl was removed entirely - this is a breaking change if any external consumers were using it directly (internal usage only expected)

Bundle size impact:

  • js-client-sdk-common: -762 bytes raw (-0.77%), -89 bytes brotli (-0.46%)
  • js-client-sdk: -196 bytes raw (-0.24%), +4 bytes brotli (+0.02%)

Human review checklist:

  • Verify validation logic behavior is preserved (type coercion for booleans, minimum value enforcement, error logging)
  • Confirm no external consumers depend on ConfigurationImpl export
  • Check that object spread doesn't leak internal properties (baseUri, eventsUri, streamUri, payloadFilterKey are destructured out)

Describe alternatives you've considered

Could have kept ConfigurationImpl for backwards compatibility, but since it's internal-only usage, removing it entirely provides cleaner code and better bundle size.

Additional context

Link to Devin run: https://app.devin.ai/sessions/608a317f9f334f38ab018c4b83ed3b4c

Requested by: Steven Zhang (@joker23)


Note

Medium Risk
Touches core config construction/validation and exported API surface; behavior should be equivalent but any subtle differences in option coercion or unknown-option handling could affect SDK initialization.

Overview
Refactors SDK configuration creation by removing the ConfigurationImpl class and introducing a createConfiguration() factory that builds a plain Configuration object, inlining option validation/coercion and constructing ServiceEndpoints while omitting internal URI fields from the returned shape.

Updates LDClientImpl and unit tests to use createConfiguration(), and adjusts assertions to validate endpoint defaults and payloadFilterKey via config.serviceEndpoints rather than internal baseUri/streamUri/eventsUri properties; updates configuration/index.ts exports accordingly.

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

…iguration factory function

SDK-1705: Refactor ConfigurationImpl to follow factory function pattern

- Add createConfiguration() factory function that returns Configuration interface
- Update LDClientImpl to use createConfiguration() instead of new ConfigurationImpl()
- Update exports in configuration/index.ts to include createConfiguration
- Keep ConfigurationImpl class for backwards compatibility
- Update test files to use createConfiguration()
- Update tests to check serviceEndpoints properties instead of internal class properties

This change follows the CONTRIBUTING.md guidelines for preferring interfaces
over classes, which results in better bundle size and minification potential.

Co-Authored-By: Steven Zhang <zhangksteven@gmail.com>
@joker23 joker23 requested a review from a team as a code owner January 21, 2026 21:56
@devin-ai-integration
Copy link
Contributor

🤖 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 PRs created by Devin AI label Jan 21, 2026
@github-actions
Copy link
Contributor

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

@github-actions
Copy link
Contributor

github-actions bot commented Jan 21, 2026

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

@github-actions
Copy link
Contributor

github-actions bot commented Jan 21, 2026

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

@github-actions
Copy link
Contributor

github-actions bot commented Jan 21, 2026

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

SDK-1705: Complete removal of ConfigurationImpl class

- Remove ConfigurationImpl class from Configuration.ts
- Update exports in index.ts to remove ConfigurationImpl
- All usages now use createConfiguration() factory function

This completes the refactoring to follow the CONTRIBUTING.md guidelines
for preferring interfaces over classes.

Co-Authored-By: Steven Zhang <zhangksteven@gmail.com>
@joker23 joker23 marked this pull request as draft January 21, 2026 23:10
@joker23 joker23 force-pushed the devin/1769032110-sdk-1705-configuration-factory branch from 54c0dde to efe9fac Compare January 23, 2026 17:51
joker23 and others added 3 commits January 23, 2026 15:15
Use object spread instead of explicit property mapping in the return
statement to reduce the generated JavaScript code size.

Before optimization: +716 bytes raw, +86 bytes brotli
After optimization: -319 bytes raw, -35 bytes brotli (vs main)

Co-Authored-By: Steven Zhang <zhangksteven@gmail.com>
Co-Authored-By: Steven Zhang <zhangksteven@gmail.com>
devin-ai-integration bot and others added 2 commits January 27, 2026 17:00
Removes the separate validateTypesAndNames function and inlines the
validation logic directly into createConfiguration since it's only
used in one place. This further reduces the bundle size.

Additional savings: ~443 bytes raw, ~54 bytes brotli

Co-Authored-By: Steven Zhang <zhangksteven@gmail.com>
@joker23 joker23 marked this pull request as ready for review January 28, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devin-pr PRs created by Devin AI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants