Skip to content

Make phonelib an optional dependency - #675

Open
OughtPuts wants to merge 1 commit into
mainfrom
ho/make-phonelib-dependency-optional
Open

OughtPuts wants to merge 1 commit into
mainfrom
ho/make-phonelib-dependency-optional

Conversation

@OughtPuts

@OughtPuts OughtPuts commented Nov 6, 2026 •

Copy link
Copy Markdown

https://torrent.shopify.io/issues/DIET-122

What are you trying to accomplish?

Allow applications using Worldwide’s localization and address-formatting features to avoid installing and loading phonelib.

...

What approach did you choose and why?

Remove phonelib from the runtime dependencies and load it when a Worldwide::Phone is created. Keep it in the test bundle. Missing phonelib raises an actionable LoadError; unrelated loading errors propagate unchanged. This would be helpful for Shopify core as we use the worldwide gem but do not need the phonelib functionality as this is duplicated by GlobalPhone at present, so could be replaced in order to be more efficient with gem usage.

The subprocess test helper skips gemspec loads that return nil. Bundler can provide synthetic specifications whose paths point to directories rather than gemspec files; keeping those nil results caused the CI tests to crash during setup. A regression test covers this case.
...

What should reviewers focus on?

The loading boundary and error handling.

...

The impact of these changes

Applications using phone parsing or address normalization/validation must explicitly add gem "phonelib", "~> 0.8" to their Gemfile. Other features, including address formatting, work without it.

...

Testing

  • All 1,496 tests pass locally on Ruby 3.4.9; RuboCop passes.
  • Tests cover deferred loading, missing and incompatible phonelib versions, and preservation of errors raised inside phonelib.
  • The new Bundler regression test reproduced the exact CI error before the helper fix and passes afterward.
  • Manual tophatting in the local console confirms deferred loading and identical sample phone output.

Run bundle exec rake test, or just bundle exec ruby -Itest test/worldwide/phonelib_dependency_test.rb.

...

Checklist

  • I have added a CHANGELOG entry for this change (or determined that it isn't needed)

@OughtPuts
OughtPuts requested a review from a team as a code owner November 6, 2026 13:17
Comment thread lib/worldwide/phone.rb Resolved
@OughtPuts
OughtPuts force-pushed the ho/make-phonelib-dependency-optional branch from 740c520 to 01197b1 Compare November 9, 2026 10:50
@OughtPuts
OughtPuts force-pushed the ho/make-phonelib-dependency-optional branch from 01197b1 to a9a1441 Compare November 9, 2026 12:26
@SeriouslyAwesome
SeriouslyAwesome requested review from rochlefebvre and removed request for SeriouslyAwesome November 12, 2026 18:10

This branch has not been deployed

No deployments
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