Skip to content

refactor!: only use FakerCore in modules - #4081

Open
ST-DDT wants to merge 8 commits into
nextfrom
feat/smf/module-cleanup
Open

ST-DDT wants to merge 8 commits into
nextfrom
feat/smf/module-cleanup

Conversation

@ST-DDT

@ST-DDT ST-DDT commented Sep 9, 2026

Copy link
Copy Markdown
Member

Continuation of #3748


  • Replace all references to Faker and SimpleFaker inside modules with FakerCore.
    • The HelpersModule is the only module, that retains a reference to Faker as it needs it for the module tree.
  • The modules are now initialized inside the Faker constructor, as they require a reference to the FakerCore instance, that is passed as constructor parameter.
  • This is breaking for JS users, that previously could access the Faker instances via faker.airline.faker.

@ST-DDT ST-DDT added this to the v11.0 milestone Sep 9, 2026
@ST-DDT ST-DDT self-assigned this Sep 9, 2026
@ST-DDT
ST-DDT requested a review from a team as a code owner September 9, 2026 19:46
@ST-DDT ST-DDT added p: 1-normal Nothing urgent c: refactor PR that affects the runtime behavior, but doesn't add new features or fixes bugs breaking change Cannot be merged when next version is not a major release labels Sep 9, 2026
@ST-DDT
ST-DDT added this pull request to stack #4078 September 9, 2026 19:46
@netlify

netlify Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for fakerjs ready!

Name Link
🔨 Latest commit a718c18
🔍 Latest deploy log https://app.netlify.com/projects/fakerjs/deploys/6ab7a0ac6d93140008fa8544
😎 Deploy Preview https://deploy-preview-4081.fakerjs.dev
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.17%. Comparing base (b4b7305) to head (a718c18).

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #4081      +/-   ##
==========================================
- Coverage   99.17%   99.17%   -0.01%     
==========================================
  Files        1172     1172              
  Lines        3888     3884       -4     
  Branches      693      693              
==========================================
- Hits         3856     3852       -4     
  Misses         28       28              
  Partials        4        4              
Files with missing lines Coverage Δ
src/faker.ts 100.00% <100.00%> (ø)
src/internal/module-base.ts 100.00% <100.00%> (ø)
src/modules/airline/module.ts 100.00% <100.00%> (ø)
src/modules/animal/module.ts 100.00% <100.00%> (ø)
src/modules/book/module.ts 100.00% <100.00%> (ø)
src/modules/color/module.ts 100.00% <100.00%> (ø)
src/modules/commerce/module.ts 100.00% <100.00%> (ø)
src/modules/company/module.ts 100.00% <100.00%> (ø)
src/modules/database/module.ts 100.00% <100.00%> (ø)
src/modules/datatype/module.ts 100.00% <100.00%> (ø)
... and 21 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ST-DDT
ST-DDT force-pushed the feat/smf/module-cleanup branch from 9f5be3d to 791933f Compare September 9, 2026 22:25
@ST-DDT
ST-DDT force-pushed the feat/smf/module-cleanup branch from 791933f to 578e7d6 Compare September 19, 2026 21:37
Shinigami92
Shinigami92 previously approved these changes Sep 21, 2026

@Shinigami92 Shinigami92 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I talked to my AI and we agree: this is an acceptable breaking change and would not affect an end-user. The only affected users by this breaking change are meta-framework contributors which extends for one of the abstract classes, but even then these are not made public through dist/index.ts and therefore would require a (theoretically not officially supported) deep import.

@xDivisionByZerox

xDivisionByZerox commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

I talked to my AI and we agree: this is an acceptable breaking change and would not affect an end-user. The only affected users by this breaking change are meta-framework contributors which extends for one of the abstract classes, but even then these are not made public through dist/index.ts and therefore would require a (theoretically not officially supported) deep import.

It is a breaking change because the faker property has an access level of protected. Simply extending any module (or the module base) and accessing faker (which is normal to do prior to SMF) would now break.

const AirlineModuleCtor = faker.airline.constructor.prototype as { new (): AirlineModule }
class MyCustomAirlineModule extends AirlineModuleCtor {
  abc() {
    return this.faker.string.sample(); // error: faker is not defined
  }
}

@Shinigami92

Copy link
Copy Markdown
Member

It is a breaking change because the faker property has an access level of protected. Simply extending any module (or the module base) and accessing faker (which is normal to do prior to SMF) would now break.

const AirlineModuleCtor = faker.airline.constructor.prototype as { new (): AirlineModule }
class MyCustomAirlineModule extends AirlineModuleCtor {
  abc() {
    return this.faker.string.sample(); // error: faker is not defined
  }
}

You don't even need to go that far, already myModule instanceof SimpleModuleBase is not possible anymore

@ST-DDT

ST-DDT commented Sep 21, 2026

Copy link
Copy Markdown
Member Author

Should we write a migration guide for this?
If yes, what do we say in there. "Dear JS user, if you relied on an internal/non-api field field or constructor, then that is no longer possible/it has been renamed to fakerCore." (Just more polite)?

@Shinigami92

Copy link
Copy Markdown
Member

Should we write a migration guide for this? If yes, what do we say in there. "Dear JS user, if you relied on an internal/non-api field field or constructor, then that is no longer possible/it has been renamed to fakerCore." (Just more polite)?

If @matthewmayer says no to that, I think we are safe to merge without a migration guide here.

@ST-DDT
ST-DDT added this pull request to the merge queue Sep 26, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 26, 2026
Base automatically changed from feat/standalone-module-functions to next September 26, 2026 09:38
@ST-DDT
ST-DDT force-pushed the feat/smf/module-cleanup branch from 578e7d6 to 2ce138a Compare September 26, 2026 09:38
@ST-DDT
ST-DDT force-pushed the feat/smf/module-cleanup branch from 2ce138a to a718c18 Compare September 26, 2026 10:38

@matthewmayer matthewmayer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm ok with no migration guide for this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Cannot be merged when next version is not a major release c: refactor PR that affects the runtime behavior, but doesn't add new features or fixes bugs p: 1-normal Nothing urgent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants