Skip to content

feat: introduce FakerCore#2838

Merged
ST-DDT merged 24 commits intonextfrom
feat/samfn/faker-core
Apr 9, 2026
Merged

feat: introduce FakerCore#2838
ST-DDT merged 24 commits intonextfrom
feat/samfn/faker-core

Conversation

@ST-DDT
Copy link
Copy Markdown
Member

@ST-DDT ST-DDT commented Apr 20, 2024

First part of the standalone module function feature #2667

Overview

  1. Introduce FakerCore feat: introduce FakerCore #2838
  2. De-proxy locale access feat: de-proxy locale access #3189
  3. De-class config function feat: standalone module functions #3748 (seed, setDefaultRefDate, ...)
  4. De-module functions feat: standalone module functions #3748 (airline, ...)

Description

Create the fakerCore container object.

@ST-DDT ST-DDT added c: feature Request for new feature p: 1-normal Nothing urgent labels Apr 20, 2024
@ST-DDT ST-DDT added this to the v9.0 milestone Apr 20, 2024
@ST-DDT ST-DDT requested review from a team April 20, 2024 14:11
@ST-DDT ST-DDT self-assigned this Apr 20, 2024
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 20, 2024

Deploy Preview for fakerjs ready!

Name Link
🔨 Latest commit e659674
🔍 Latest deploy log https://app.netlify.com/sites/fakerjs/deploys/671018639e657d00089dc08d
😎 Deploy Preview https://deploy-preview-2838.fakerjs.dev
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

Copy link
Copy Markdown
Member

@Shinigami92 Shinigami92 left a comment

Choose a reason for hiding this comment

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

I know the PR is still in draft but I would like to provide some early-feedback

  1. I think the refDate should still be named something like default or fallback or base, so the intent is more clear and there might be no variable naming conflict when using an option's refDate + the ...RefDate
  2. I suggest to not do something like super({ fakerCore: fakerCore ?? { locale, randomizer, config: {} } }) but only pass the locale and randomizer so the config get's set like every other method call to a default internally. Or is there something special about that I currently overlook? 👀

@ST-DDT
Copy link
Copy Markdown
Member Author

ST-DDT commented Apr 22, 2024

  1. Done
  2. Changed slightly to improve readability.

@ST-DDT
Copy link
Copy Markdown
Member Author

ST-DDT commented Apr 22, 2024

Does anybody know why this test is failing with that particular error message?

❯ test/simple-faker.spec.ts > simpleFaker > should not log anything on startup
→ Unexpected token ','

It seems to happen only with vitest/CJS.

@ST-DDT ST-DDT requested a review from Shinigami92 April 22, 2024 21:53
@Shinigami92
Copy link
Copy Markdown
Member

Shinigami92 commented Apr 23, 2024

Does anybody know why this test is failing with that particular error message?

❯ test/simple-faker.spec.ts > simpleFaker > should not log anything on startup
→ Unexpected token ','

It seems to happen only with vitest/CJS.

If I set minify: false in tsup.config.ts everything runs fine. Please report a bug-issue to https://github.com/egoist/tsup

Or it is related to https://github.com/egoist/tsup/issues/1091

@ST-DDT
Copy link
Copy Markdown
Member Author

ST-DDT commented May 14, 2024

The error is caused by this part:

_class.prototype.__init23.call(this);,this.definitions=_chunkWAQHUEHTcjs.d.call(void 0, this.rawDefinitions)
                                     ^

Which is equivalent to this source code:

faker/src/faker.ts

Lines 195 to 197 in e4da2f5

super({ fakerCore });
this.definitions = createLocaleProxy(this.rawDefinitions);

@ST-DDT
Copy link
Copy Markdown
Member Author

ST-DDT commented May 14, 2024

I created an issue in tsup with a minimal reproduction:

And it has reeeaaally specific conditions, check the issue for more details.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 14, 2024

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.89%. Comparing base (d17c0f1) to head (0c2e3de).
⚠️ Report is 1 commits behind head on next.

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #2838   +/-   ##
=======================================
  Coverage   98.89%   98.89%           
=======================================
  Files         893      894    +1     
  Lines        3082     3087    +5     
  Branches      546      548    +2     
=======================================
+ Hits         3048     3053    +5     
  Misses         30       30           
  Partials        4        4           
Files with missing lines Coverage Δ
src/core.ts 100.00% <100.00%> (ø)
src/faker.ts 100.00% <100.00%> (ø)
src/modules/helpers/eval.ts 95.65% <100.00%> (ø)
src/modules/number/index.ts 100.00% <100.00%> (ø)
src/modules/person/index.ts 94.11% <100.00%> (+0.08%) ⬆️
src/simple-faker.ts 100.00% <100.00%> (ø)
🚀 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.

Comment thread src/faker.ts
@ST-DDT ST-DDT marked this pull request as ready for review May 14, 2024 20:48
Shinigami92
Shinigami92 previously approved these changes May 30, 2024
Copy link
Copy Markdown
Member

@Shinigami92 Shinigami92 left a comment

Choose a reason for hiding this comment

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

LGTM

ejcheng
ejcheng previously approved these changes May 31, 2024
Copy link
Copy Markdown
Contributor

@matthewmayer matthewmayer left a comment

Choose a reason for hiding this comment

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

see my comment at #2667 (comment) - would it make sense to delay merging this?

@ST-DDT ST-DDT marked this pull request as ready for review March 23, 2026 13:56
@ST-DDT
Copy link
Copy Markdown
Member Author

ST-DDT commented Mar 23, 2026

is there a reason why it is still in draft? have you anything planned to change in this PR?

Only discussions regarding names, behaviour, API and PR contents.

Comment thread src/faker.ts
@xDivisionByZerox xDivisionByZerox removed the s: needs decision Needs team/maintainer decision label Mar 28, 2026
@xDivisionByZerox
Copy link
Copy Markdown
Member

Team Decision

We take this regardless of whether we also take the standalone modules PR (#3748)


@ST-DDT Please rebase/merge this branch against origin/next.

@xDivisionByZerox xDivisionByZerox added the needs rebase There is a merge conflict label Mar 28, 2026
@ST-DDT ST-DDT added s: accepted Accepted feature / Confirmed bug and removed needs rebase There is a merge conflict labels Mar 28, 2026
@ST-DDT ST-DDT requested review from a team March 28, 2026 17:29
Shinigami92
Shinigami92 previously approved these changes Mar 28, 2026
Comment thread src/core.ts Outdated
Comment thread src/config.ts
Comment thread src/simple-faker.ts Outdated
@ST-DDT ST-DDT dismissed stale reviews from xDivisionByZerox and Shinigami92 via 54add10 March 29, 2026 18:30
@ST-DDT ST-DDT requested review from a team April 5, 2026 22:35
Comment thread src/core.ts Outdated
@ST-DDT ST-DDT added this pull request to the merge queue Apr 9, 2026
Merged via the queue into next with commit 68e15d7 Apr 9, 2026
23 checks passed
@ST-DDT ST-DDT deleted the feat/samfn/faker-core branch April 9, 2026 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: feature Request for new feature p: 1-normal Nothing urgent s: accepted Accepted feature / Confirmed bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants