refactor: update package.json for ESM support and improve build process#104
refactor: update package.json for ESM support and improve build process#104Kolezhniuk wants to merge 6 commits into
Conversation
Kolezhniuk
commented
Apr 2, 2026
- 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.
…g action versions
There was a problem hiding this comment.
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 toexpect/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.
| 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(); | ||
|
|
There was a problem hiding this comment.
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.
| "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" | ||
| }, |
There was a problem hiding this comment.
Added engines.node: ">=20" to declare the runtime floor matching the new tooling (eslint 10 / vite 8 / vitest 4) and CI (lts/*).
| "@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" |
There was a problem hiding this comment.
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.
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
…eutils and fastfile
|
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. |