[node-core-library] Refactor Text static class to module namespace object for tree-shaking#5435
Draft
[node-core-library] Refactor Text static class to module namespace object for tree-shaking#5435
Conversation
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Replace static classes with exported module namespace objects
Refactor Text static class to module namespace object for tree-shaking
Nov 6, 2025
dmichon-msft
requested changes
Nov 7, 2025
… restore function.name in tests Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Copilot
AI
changed the title
Refactor Text static class to module namespace object for tree-shaking
[node-core-library] Refactor Text static class to module namespace object for tree-shaking
Nov 7, 2025
dmichon-msft
reviewed
Nov 7, 2025
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Comment on lines
-86
to
-94
| /** | ||
| * Operations for working with strings that contain text. | ||
| * | ||
| * @remarks | ||
| * The utilities provided by this class are intended to be simple, small, and very | ||
| * broadly applicable. | ||
| * | ||
| * @public | ||
| */ |
Contributor
There was a problem hiding this comment.
@copilot preserve this comment in Text/index.ts and give it the @module JSDoc tag to indicate that it should be treated as documentation for the module.
Contributor
Author
There was a problem hiding this comment.
Added the documentation comment to text/index.ts with the @module JSDoc tag. The comment preserves the original Text class documentation describing operations for working with strings. (commit 236df5b)
Note: There's a TSDoc linting warning about @module not being defined in the configuration, but this is expected as @module is a standard JSDoc tag for documenting modules. The build and all tests pass successfully.
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
✅ Refactor Text static class to module namespace object pattern
This PR successfully refactors the
Textstatic class to use the module namespace object pattern (similar to existingDisposables,Objects, andUser) for better tree-shaking support by modern bundlers.Completed Work
Text Refactoring (COMPLETE):
text/directory with 13 individual function filesText.tsto re-export fromtext/indexusing module namespace patternEncoding,NewlineKind,IReadLinesFromIterableOptions) remain accessiblefunction.namefor synchronized test titlesSymbol.matchAllfor proper regex iterationtext/index.tswith@moduleJSDoc tagAPI Compatibility
✅ Backward compatibility maintained - All consumers continue to use the same API:
Tree-Shaking Benefits
With this refactoring, bundlers can now tree-shake unused Text functions:
Recent Updates
_newlineHelpers.tsto factor out common NEWLINE_REGEX and replace logicconvertTo,convertToCrLf,convertToLfto use shared helperreadLinesFromIterable.tsto useNEWLINE_REGEX[Symbol.matchAll]instead of.matchAll()Text.functionName.namein tests for synchronized test titlesfileSystem/errorChecks.tsto keep PR focused on Text API onlytext/index.tswith@moduletag for module-level documentationOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.