Skip to content

Introduce lazy loading as an optional config#3228

Open
stefannibrasil wants to merge 4 commits intolazy-loading-betafrom
sb/introduce-lazy-load
Open

Introduce lazy loading as an optional config#3228
stefannibrasil wants to merge 4 commits intolazy-loading-betafrom
sb/introduce-lazy-load

Conversation

@stefannibrasil
Copy link
Contributor

@stefannibrasil stefannibrasil commented Mar 11, 2026

Motivation / Background

Closes #3161

This Pull Request has been created because after running experiments documented in https://github.com/faker-ruby/faker/tree/main/experiments, we decided to go with lazy loading, and we want to release a beta version for users to report any issues using lazy loading.

Lazy loading is disabled by default and can be enabled by setting a config:

Faker::Config.lazy_loading = true

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug, refactor something, or add a feature.
  • Tests and Rubocop are passing before submitting your proposed changes.

@stefannibrasil stefannibrasil force-pushed the sb/introduce-lazy-load branch 3 times, most recently from 103500c to 0c9dc19 Compare March 11, 2026 21:53
stefannibrasil and others added 3 commits March 13, 2026 12:19
To keep this change backwards compatible, we introduce
lazy loading as a config option.

We need to load main classes
first for nested generators such as 'music' and
when lazy loading is not enabled. 'internet/http'.

This will avoid the need for renaming these generators.

Co-authored-by: Thiago Araujo <thd.araujo@gmail.com>
@stefannibrasil stefannibrasil force-pushed the sb/introduce-lazy-load branch from d4e9ddb to 4c06713 Compare March 13, 2026 18:21
@stefannibrasil stefannibrasil changed the title Sb/introduce lazy load Introduce lazy loading as an optional config Mar 13, 2026
@stefannibrasil stefannibrasil marked this pull request as ready for review March 13, 2026 18:27
@stefannibrasil stefannibrasil force-pushed the sb/introduce-lazy-load branch from 4c06713 to 1ca07ae Compare March 13, 2026 18:29

- name: Run tests
run: bundle exec rake test
test-with-lazy-loading:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think we need to run the tests for every ruby version. Just one is enough?

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.

1 participant