Skip to content

Maintenance: remove EnvironmentVariablesService class from Commons package #4247

@dreamorosi

Description

@dreamorosi

Summary

Important

This issue depends on #4116 and #4246 to be completed.

After the refactoring of all packages to use the new functional environment variable utilities, the EnvironmentVariablesService class in the Commons package is no longer used anywhere in the codebase. We should remove this class and its associated files to complete the migration to the new functional approach and reduce the overall codebase complexity.

The EnvironmentVariablesService class was the old class-based approach for reading environment variables that has been superseded by the zero-dependency functional utilities introduced in #3945.

Why is this needed?

With all Powertools packages migrated to use the new functional environment variable utilities, the EnvironmentVariablesService class serves no purpose and adds unnecessary complexity to the codebase. Removing it will:

  • Reduce bundle size - Eliminates unused code from the commons package
  • Simplify maintenance - Removes code that no longer needs to be maintained or tested
  • Complete the migration - Finishes the transition to the new functional approach
  • Improve consistency - Ensures all packages use the same modern approach for environment variables
  • Reduce cognitive load - Developers won't encounter the old deprecated pattern

Which area does this relate to?

Commons

Solution

Important

The following changes are included as reference to help you understand the refactoring. Before implementing, please make sure to check the codebase and ensure that they make sense and they are exhaustive.

The following files need to be removed or modified in the packages/commons package:

Files to Delete

1. Delete packages/commons/src/config/EnvironmentVariablesService.ts

This file contains the main EnvironmentVariablesService class implementation that is no longer used.

2. Delete packages/commons/tests/unit/EnvironmentVariablesService.test.ts

This file contains the unit tests for the EnvironmentVariablesService class that will no longer be needed.

Files to Modify

1. Update packages/commons/src/index.ts

Remove the export statement for EnvironmentVariablesService:

Current:

export { EnvironmentVariablesService } from './config/EnvironmentVariablesService.js';

After removal:

// Remove the above line entirely

Additional Considerations

  • The ConfigServiceInterface type should be evaluated to see if it's still needed after removing EnvironmentVariablesService

Acknowledgment

Future readers

Please react with 👍 and your use case to help us understand customer demand.

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    commonsThis item relates to the Commons Utilitygood-first-issueSomething that is suitable for those who want to start contributingon-holdThis item is on-hold and will be revisited in the future

    Type

    No type

    Projects

    Status

    On hold

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions