Skip to content

Extraction of the majority of the utilities from the config singleton#816

Merged
jdmarshall merged 8 commits intonode-config:masterfrom
jdmarshall:loadConfigs
May 29, 2025
Merged

Extraction of the majority of the utilities from the config singleton#816
jdmarshall merged 8 commits intonode-config:masterfrom
jdmarshall:loadConfigs

Conversation

@jdmarshall
Copy link
Copy Markdown
Collaborator

@jdmarshall jdmarshall commented May 18, 2025

This PR contains a good deal of code to maintain feature and bug parity with the existing Config.util behavior while also extracting code that can be run either statically or as part of a separate workflow.

This is designed with elements of #569 in mind in addition to a number of other issues

Providing workarounds for some and fixing a few outright.

This PR also includes code from #808 which this PR leverages.

These changes also include:

  • almost 80 new unit tests
    • including for functions that had no unit tests in Config.util such as getOption()
    • ordered to ensure that bugs in helper functions are reported before errors that use those functions
  • some performance improvements
  • a number of legibility/trace debugging ergonomic improvements for people investigating config issues
  • a way to load a config directory with 0 side effects on Config
  • careful support for calling this code recursively during a require('config') call - which substantially complicated the plumbing and necessitated the LoadInfo vs Env split.
  • defer functionality pulled out, hopefully making it easier for someone to debug Deferred values can't be referenced by sub-modules #687
  • support for CI/CD well-formedness checks enumerated across all environments

To the best of my knowledge this contains no breaking changes, But it contains a number of TODOs that would be good candidates for a 4.1

Note that these commits also include git mv trickery to maintain commit history on both sides of the split files, to support forensics on future bug-vs-feature triage.

This will simplify some work to split up lib/config.js
This is to make space for unravelling the mess that is the singleton
into some functional components that may be useful individually.

This also deprecates some functions that probably should never
have been exposed.

This refactor is as commit-history-preserving as I could manage.
Subsequent commits will involve rearranging more of the code to
extricate things from config.js
This will preserve edit history on both original files.
Also contains workaround for node-config#815 - which pops up due to running
extendDeep in strict mode.
@jdmarshall jdmarshall requested a review from markstos May 18, 2025 20:56
@jdmarshall
Copy link
Copy Markdown
Collaborator Author

In retrospect we should have perhaps called 4.0.0 3.5.0 as this change is more of a 4.x change than the deprecations we removed.

@jdmarshall
Copy link
Copy Markdown
Collaborator Author

config.js can shrink by around 400 lines once we start removing Config.util methods that are marked deprecated and have trampolines to lib/util.js. The duplicate jsdoc entries are about 40% of the moved code and are retained for documentation purposes.

Copy link
Copy Markdown
Collaborator

@markstos markstos left a comment

Choose a reason for hiding this comment

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

Makes sense to me.

QA Log

  • Noted that the PR seems to pass existing tests, while adding more test coverage.

@jdmarshall jdmarshall merged commit 0927c7d into node-config:master May 29, 2025
1 check passed
@jdmarshall jdmarshall deleted the loadConfigs branch January 18, 2026 20:06
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