Skip to content

Conversation

@onairmarc
Copy link
Member

This pull request introduces a custom dependency injection (DI) system to the codebase, refactors the formatter rules to leverage this DI container, and adds a custom Vite plugin to transform generic method calls for compatibility with compiled JavaScript. It also updates the build process to use Vite, reorganizes exports, and makes related adjustments to configuration and scripts.

Dependency Injection System and Refactoring:

  • Introduced a new DI container (Container) and service registration system (ServiceRegistration) in src/core/di, enabling automatic dependency resolution and singleton management for services and formatting rules. ([[1]](https://github.com/EncoreDigitalGroup/tsfmt/pull/84/files#diff-e0cfb749b35f472cec2b3e7ce0252ebe46144799fac73e1d86930cbe054d69e3R1-R241), [[2]](https://github.com/EncoreDigitalGroup/tsfmt/pull/84/files#diff-9b6ac34670c12d84be455a42fdc64b8eb91d448463aea6879f8221bfd21cb26fR1-R36), [[3]](https://github.com/EncoreDigitalGroup/tsfmt/pull/84/files#diff-72d6a009a92f58436c78302c67159017ba656e77dda2cf1979413ebd40ea05d3R1-R5))
  • Refactored the formatter rule base class to BaseFormattingRule, providing container access and configuration helpers for all rules. Updated rules (e.g., ClassMemberSortingRule) to extend this base class and use injected configuration. ([[1]](https://github.com/EncoreDigitalGroup/tsfmt/pull/84/files#diff-6fcfbe86570f4173d3d506bdda506e7df7cbd3b54712464bfc3a5b06e0d1a0b0R1-R62), [[2]](https://github.com/EncoreDigitalGroup/tsfmt/pull/84/files#diff-9f780b370206c13aece8cbd9d75b710e2693bbb0db0917530beb7e5d7c422febR4), [[3]](https://github.com/EncoreDigitalGroup/tsfmt/pull/84/files#diff-891d7486bdf3d932b174ff7c39cd1893aeb245c9c0baebb15a03c193321729dbL9-R9), [[4]](https://github.com/EncoreDigitalGroup/tsfmt/pull/84/files#diff-891d7486bdf3d932b174ff7c39cd1893aeb245c9c0baebb15a03c193321729dbL56-L61), [[5]](https://github.com/EncoreDigitalGroup/tsfmt/pull/84/files#diff-891d7486bdf3d932b174ff7c39cd1893aeb245c9c0baebb15a03c193321729dbL138-R135))
  • Updated the CLI entry point (src/cli.ts) to use the DI container for resolving the formatter pipeline and registering services, instead of direct instantiation. ([[1]](https://github.com/EncoreDigitalGroup/tsfmt/pull/84/files#diff-fa8d4e24d8399e8350f1c8bad05df53e8032ea995835bf911507015e2db61cddR4-R16), [[2]](https://github.com/EncoreDigitalGroup/tsfmt/pull/84/files#diff-fa8d4e24d8399e8350f1c8bad05df53e8032ea995835bf911507015e2db61cddL31-R37))

Build Process and Plugin Enhancements:

  • Added a custom Vite plugin (transformGenericsPlugin) in src/build-plugins to transform generic addRule calls into explicit string-based calls, ensuring correct operation after TypeScript generics are stripped in compiled JS. ([[1]](https://github.com/EncoreDigitalGroup/tsfmt/pull/84/files#diff-08dea0082f21f16e583b1158de6026d2325d7d8583ba653372591da4818a944aR1-R120), [[2]](https://github.com/EncoreDigitalGroup/tsfmt/pull/84/files#diff-a47d06b8354caaf1b1b96d3ad3faddda32e1155f2b0511d4c18cc09384e54e82R1-R5))
  • Switched the build process to use Vite, updating scripts and main entry points in package.json to output to dist/, and adjusted the CLI and binary paths accordingly. ([[1]](https://github.com/EncoreDigitalGroup/tsfmt/pull/84/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519R16-R35), [[2]](https://github.com/EncoreDigitalGroup/tsfmt/pull/84/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519L41-R44))

Export Organization:

  • Added and reorganized auto-generated export files for new and existing modules to streamline imports and maintainability. ([[1]](https://github.com/EncoreDigitalGroup/tsfmt/pull/84/files#diff-72d6a009a92f58436c78302c67159017ba656e77dda2cf1979413ebd40ea05d3R1-R5), [[2]](https://github.com/EncoreDigitalGroup/tsfmt/pull/84/files#diff-9f780b370206c13aece8cbd9d75b710e2693bbb0db0917530beb7e5d7c422febR4), [[3]](https://github.com/EncoreDigitalGroup/tsfmt/pull/84/files#diff-a47d06b8354caaf1b1b96d3ad3faddda32e1155f2b0511d4c18cc09384e54e82R1-R5))

These changes collectively modernize the codebase, improve extensibility and maintainability, and ensure compatibility with modern build tooling and dependency management.

onairmarc and others added 15 commits January 13, 2026 11:32
… constructor dependencies and refactoring service registration
@onairmarc onairmarc merged commit 06a5d36 into main Jan 13, 2026
@onairmarc onairmarc deleted the di branch January 13, 2026 20:14
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.

2 participants