Skip to content

refactor: update package.json for ESM support and improve build process#104

Open
Kolezhniuk wants to merge 6 commits into
masterfrom
feat/esm-migration
Open

refactor: update package.json for ESM support and improve build process#104
Kolezhniuk wants to merge 6 commits into
masterfrom
feat/esm-migration

Conversation

@Kolezhniuk

Copy link
Copy Markdown
Contributor
  • Modified the "exports" field in package.json to support both ESM and CommonJS.
  • Removed rollup configuration file as Vite is now used for building.
  • Updated scripts for linting, cleaning, and testing using Vitest.
  • Added new devDependencies for eslint, vite, and vitest.
  • Changed test assertions from assert to expect using Vitest.
  • Refactored test files to utilize binFileUtils for reading binary files.
  • Introduced eslint and vite configuration files for better code quality and build management.

- Modified the "exports" field in package.json to support both ESM and CommonJS.
- Removed rollup configuration file as Vite is now used for building.
- Updated scripts for linting, cleaning, and testing using Vitest.
- Added new devDependencies for eslint, vite, and vitest.
- Changed test assertions from assert to expect using Vitest.
- Refactored test files to utilize binFileUtils for reading binary files.
- Introduced eslint and vite configuration files for better code quality and build management.
@Kolezhniuk Kolezhniuk marked this pull request as ready for review May 11, 2026 10:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the project to better support ESM + CommonJS consumers while migrating the build/test tooling from Rollup/Mocha to Vite/Vitest, and adds ESLint for consistent code quality checks.

Changes:

  • Replace Rollup build config with a Vite-based library build that outputs build/main.cjs.
  • Migrate tests from assert/Mocha to expect/Vitest and refactor fixture loading via @iden3/binfileutils.
  • Update CI to run on Ubuntu with Node LTS and add an ESLint flat config.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
vite.config.js Adds Vite library build config and Vitest project configuration.
eslint.config.js Introduces ESLint flat config and project-wide lint rules.
package.json Updates exports/scripts and swaps tooling + dependency sources for ESM migration.
package-lock.json Updates lockfile to v3 and captures new dependency graph (including git dependencies).
src/r1csfile.js Minor refactor to satisfy linting (unused catch binding).
test/r1csfile.js Migrates to Vitest and refactors fixture reading.
test/r1csfile_cg.test.js Migrates to Vitest and refactors binary fixture reading for custom gates.
build/main.cjs Updates generated CJS bundle output to match new build toolchain.
.github/workflows/ci.yml Simplifies CI matrix and updates actions + Node setup.
rollup.cjs.config.js Removes obsolete Rollup configuration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/r1csfile.js Outdated
Comment thread test/r1csfile_cg.test.js
Comment on lines +26 to 30
const filePath = fixturePath("circuitCG.r1cs");
const { fd, sections } = await binFileUtils.readBinFile(filePath, "r1cs", 1, 1<<25, 1<<22);
const cir = await readR1csFd(fd, sections, { loadCustomGates: true });
await fd.close();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed — the read is now in a try block with fd.close() in finally, so the descriptor is released even if the read or assertions throw.

Comment thread package.json
Comment on lines +44 to +51
"devDependencies": {
"@eslint/js": "^10.0.1",
"eslint": "^10.1.0",
"globals": "^17.4.0",
"rimraf": "^6.1.3",
"vite": "^8.0.3",
"vitest": "^4.1.2"
},

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added engines.node: ">=20" to declare the runtime floor matching the new tooling (eslint 10 / vite 8 / vitest 4) and CI (lts/*).

Comment thread package.json
Comment on lines +54 to +56
"@iden3/binfileutils": "https://github.com/iden3/binfileutils.git#feat/esm-migration",
"fastfile": "https://github.com/iden3/fastfile.git#feat/esm-migration",
"ffjavascript": "https://github.com/iden3/ffjavascript.git#feat/esm-migration"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Intentional and temporary. This is a coordinated ESM migration across iden3 repos — binfileutils, fastfile and ffjavascript have no ESM release published yet, so the only available ESM source is their feat/esm-migration branches. These will be repinned to immutable published versions (tag/SHA) before this PR is released. Keeping the comment open as a release checklist item.

OBrezhniev and others added 3 commits June 4, 2026 00:19
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
refactor: simplify return statement in readR1csFixture function

test: ensure file descriptor is closed in parse R1CS Custom Gates test
@OBrezhniev

Copy link
Copy Markdown
Member

For comparison: I re-applied this migration on top of our optimization stack rather than replaying it, so the MSM/CIOS/memory work is preserved and a couple of bugs are fixed. See #106 (based on our optimization branch, so its diff is the migration alone).

Migration-vs-migration diff: feat/esm-migration...feature/esm-tooling

Deviations are called out in #106's description.

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.

4 participants