Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 24, 2026

Plan: Drop CommonJS support from @fast-check/worker

Based on PR #6476 for the ava package, apply the same changes to the worker package:

  • Remove package.cjs-template.json file
  • Update package.json:
    • Remove CommonJS-related exports
    • Simplify exports to ESM only
    • Add typesVersions configuration
    • Update build scripts to remove CJS build steps
    • Update main, module, and types fields
  • Update tsconfig.json to use module: "node20"
  • Update tsconfig.publish.json to use module: "node20"
  • Update tsconfig.publish.types.json to use module: "node20"
  • Update README.md to reflect new Node version requirement (≥20.19.0 for require(esm) support)
  • Update .github/workflows/build-status.yml to exclude worker from TypeScript checks for versions 5.0 and 5.7
  • Create changeset for the breaking change
  • Build and test the package to verify changes work correctly
  • Merge main branch and resolve conflicts
Original prompt

do the same as #6476 but for the worker part


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@changeset-bot
Copy link

changeset-bot bot commented Jan 24, 2026

🦋 Changeset detected

Latest commit: d4f9b4e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@fast-check/worker Minor
@fast-check/jest Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Co-authored-by: dubzzz <5300235+dubzzz@users.noreply.github.com>
Copilot AI changed the title [WIP] Add worker functionality to improve performance 💥(worker) Drop CommonJS support Jan 24, 2026
Copilot AI requested a review from dubzzz January 24, 2026 13:51
@dubzzz dubzzz marked this pull request as ready for review January 24, 2026 17:45
@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 24, 2026

@fast-check/ava

npm i https://pkg.pr.new/@fast-check/ava@6488

fast-check

npm i https://pkg.pr.new/fast-check@6488

@fast-check/jest

npm i https://pkg.pr.new/@fast-check/jest@6488

@fast-check/packaged

npm i https://pkg.pr.new/@fast-check/packaged@6488

@fast-check/poisoning

npm i https://pkg.pr.new/@fast-check/poisoning@6488

@fast-check/vitest

npm i https://pkg.pr.new/@fast-check/vitest@6488

@fast-check/worker

npm i https://pkg.pr.new/@fast-check/worker@6488

commit: a911e1c

@github-actions
Copy link
Contributor

👋 A preview of the new documentation is available at: http://6975056287e5dc0509fdc421--dubzzz-fast-check.netlify.app

@dubzzz
Copy link
Owner

dubzzz commented Jan 27, 2026

@copilot pull main and solve merge conflicts

Co-authored-by: dubzzz <5300235+dubzzz@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 27, 2026

@copilot pull main and solve merge conflicts

Done! Merged main and resolved conflicts in .github/workflows/build-status.yml. The workflow now excludes both @fast-check/poisoning and @fast-check/worker from TypeScript 5.0/5.7 checks. Build and tests pass. (f74c657)

Copilot AI requested a review from dubzzz January 27, 2026 22:47
@dubzzz
Copy link
Owner

dubzzz commented Jan 27, 2026

@copilot please use the tricks described at faker-js/faker#3606 (comment) (see below for content) to fix the cjs runs of packages/jest/test-bundle and the tests in packages/jest/test when they require to use worker. Also update the doc of jest package to make it clear for users that they need to tweak their configs for jest to run with the worker thing

Here is what the post says (adapt to our setup):

Fix Steps; ✅

yarn add --dev babel-jest @babel/core @babel/preset-env

jest.config.json

"transform": {
"^.+\.(js|jsx|ts|tsx)$": "babel-jest"
},
"transformIgnorePatterns": [
"/node_modules/(?!@faker-js/faker)",
"\.pnp\.[^\\/]+$"
],

babel.config.js

module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: { node: 'current' },
modules: 'auto'
}
]
]
}

@github-actions
Copy link
Contributor

👋 A preview of the new documentation is available at: http://6979423e2eeca99164b74d5e--dubzzz-fast-check.netlify.app

Co-authored-by: dubzzz <5300235+dubzzz@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 27, 2026

@copilot please use the tricks described at faker-js/faker#3606 (comment) (see below for content) to fix the cjs runs of packages/jest/test-bundle and the tests...

I've added the Babel configuration as described in the Faker.js issue:

What's working:

  • ✅ Added babel-jest, @babel/core, @babel/preset-env dependencies
  • ✅ Created babel.config.cjs with commonjs module transformation
  • ✅ Updated jest.config.cjs with transform and transformIgnorePatterns
  • ✅ Updated README.md with configuration instructions for users
  • ✅ The ESM tests (worker.spec.mjs) work fine

What's still failing:

  • ❌ The CJS test (worker.spec.cjs) still fails with "Must use import to load ES Module"

The issue:
The error occurs when lib/cjs/jest-fast-check-worker.js tries to require('@fast-check/worker'). Node.js rejects this at the module resolution level (before Babel can transform) because worker's package.json has "type": "module".

The transformIgnorePatterns approach works for Faker because their files are in node_modules, but our worker package is symlinked outside node_modules, so the pattern doesn't apply.

Next steps:
I need guidance on how to make Jest's babel-jest actually transform the worker package files. Is there a specific Jest configuration or do we need to modify how the CJS build of jest-fast-check-worker imports the worker package (maybe using dynamic import instead of require)? (6e781d3)

Copilot AI changed the title 💥(worker) Drop CommonJS support 💥(worker) Drop CommonJS support + 🔧(jest) Add Babel configuration for ESM worker support Jan 27, 2026
@dubzzz
Copy link
Owner

dubzzz commented Jan 27, 2026

@copilot revert your last change playing with jest

Co-authored-by: dubzzz <5300235+dubzzz@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 27, 2026

@copilot revert your last change playing with jest

Done! Reverted all Jest-related changes from the last commit. Removed:

  • packages/jest/babel.config.cjs
  • packages/jest/test-bundle/resolver.cjs
  • Babel dependencies from packages/jest/package.json
  • README updates about Babel configuration
  • jest.config.cjs changes

The PR now only contains the worker package CommonJS removal changes. (d4b41b6)

Copilot AI changed the title 💥(worker) Drop CommonJS support + 🔧(jest) Add Babel configuration for ESM worker support 💥(worker) Drop CommonJS support Jan 27, 2026
@dubzzz dubzzz enabled auto-merge (squash) January 28, 2026 22:06
@github-actions
Copy link
Contributor

👋 A preview of the new documentation is available at: http://697a88a7ab60d50a86fef35f--dubzzz-fast-check.netlify.app

Removed test for property blocking the main thread due to potential infinite loop.
@github-actions
Copy link
Contributor

👋 A preview of the new documentation is available at: http://697b96a8ea337f1cd42b1bca--dubzzz-fast-check.netlify.app

@github-actions
Copy link
Contributor

👋 A preview of the new documentation is available at: http://697b97ef3adaa42125025346--dubzzz-fast-check.netlify.app

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