Skip to content

[WIP] Fix ES module native support#778

Closed
derekpierre wants to merge 9 commits into
nucypher:signing-epicfrom
derekpierre:es-module
Closed

[WIP] Fix ES module native support#778
derekpierre wants to merge 9 commits into
nucypher:signing-epicfrom
derekpierre:es-module

Conversation

@derekpierre
Copy link
Copy Markdown
Member

Type of PR:

  • Bugfix
  • Feature
  • Documentation
  • Other

Required reviews:

  • 1
  • 2
  • 3

What this does:

High-level idea of the changes introduced in this PR. List relevant API
changes (if any), as well as related PRs and issues.

Issues fixed/closed:

  • Fixes #...

Why it's needed:

Explain how this PR fits in the greater context of the NuCypher Network. E.g.,
if this PR address a nucypher/productdev issue, let reviewers know!

Notes for reviewers:

What should reviewers focus on? Is there a particular commit/function/section
of your PR that requires more attention from reviewers?

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 20, 2026

Codecov Report

❌ Patch coverage is 89.62264% with 22 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (signing-epic@1571af3). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...o/src/conditions/schemas/export-for-zod-doc-gen.ts 0.00% 19 Missing ⚠️
packages/taco-auth/src/index.ts 0.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##             signing-epic     #778   +/-   ##
===============================================
  Coverage                ?   90.19%           
===============================================
  Files                   ?       98           
  Lines                   ?     8584           
  Branches                ?      316           
===============================================
  Hits                    ?     7742           
  Misses                  ?      839           
  Partials                ?        3           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 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.

Copy link
Copy Markdown

Copilot AI left a comment

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 is a WIP pass at enabling native ES module (ESM) consumption across the monorepo packages by making emitted ESM output Node-compatible (explicit .js specifiers + "type" markers) while retaining CommonJS builds.

Changes:

  • Add build-time generation of dist/es/package.json and dist/cjs/package.json marker files (module/commonjs).
  • Update TS sources/tests to use explicit .js relative specifiers and replace deep ethers/lib/utils imports with ethers.utils.*.
  • Update package exports to provide conditional import/require entries with types, and migrate ESLint configs to .cjs.

Reviewed changes

Copilot reviewed 162 out of 163 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
scripts/fix-dist-markers.cjs Writes per-dist "type" marker package.json files for ESM/CJS.
package.json Runs dist-marker script after root TS build; updates author.
.eslintrc.cjs Adds root ESLint config in CJS format.
packages/test-utils/tsconfig.es.json Sets ES build moduleResolution to Bundler.
packages/test-utils/tsconfig.cjs.json Sets CJS build moduleResolution to node.
packages/test-utils/src/utils.ts Uses .js specifier for internal import.
packages/test-utils/src/index.ts Uses .js specifiers for re-exports.
packages/test-utils/package.json Conditional exports w/ types; adds postbuild dist markers; updates author.
packages/test-utils/.eslintrc.js Removed in favor of .cjs.
packages/test-utils/.eslintrc.cjs Re-adds package ESLint config as .cjs.
packages/taco/tsconfig.es.json Sets ES build moduleResolution to Bundler.
packages/taco/tsconfig.cjs.json Sets CJS build moduleResolution to node.
packages/taco/test/utils.test.ts Switches test imports to .js specifiers.
packages/taco/test/test-utils.ts Switches many test imports to .js specifiers.
packages/taco/test/taco.test.ts Switches test imports to .js specifiers / explicit index paths.
packages/taco/test/taco-sign.test.ts Switches test imports to .js; minor formatting changes.
packages/taco/test/dkg-client.test.ts Switches test imports to .js specifiers.
packages/taco/test/conditions/variable-operation.test.ts Switches test imports to .js specifiers.
packages/taco/test/conditions/sequential.test.ts Switches test imports to .js specifiers.
packages/taco/test/conditions/return-value-test.test.ts Switches test imports to .js specifiers.
packages/taco/test/conditions/predefined/erc721.test.ts Switches test imports to .js specifiers.
packages/taco/test/conditions/predefined/erc20.test.ts Switches test imports to .js specifiers.
packages/taco/test/conditions/predefined/address-allowlist.test.ts Switches test imports to .js specifiers.
packages/taco/test/conditions/lingo.test.ts Switches test imports to .js specifiers.
packages/taco/test/conditions/if-then-else-condition.test.ts Switches test imports to .js specifiers.
packages/taco/test/conditions/context.test.ts Switches test imports to .js specifiers and explicit barrel paths.
packages/taco/test/conditions/conditions.test.ts Switches test imports to .js specifiers.
packages/taco/test/conditions/condition-expr.test.ts Switches test imports to .js specifiers.
packages/taco/test/conditions/compound-condition.test.ts Switches test imports to .js specifiers.
packages/taco/test/conditions/base/time.test.ts Switches test imports to .js specifiers.
packages/taco/test/conditions/base/signing.test.ts Switches test imports to .js specifiers.
packages/taco/test/conditions/base/rpc.test.ts Switches test imports to .js specifiers.
packages/taco/test/conditions/base/jwt.test.ts Switches test imports to .js specifiers.
packages/taco/test/conditions/base/json.test.ts Switches test imports to .js specifiers.
packages/taco/test/conditions/base/json-rpc.test.ts Switches test imports to .js specifiers.
packages/taco/test/conditions/base/json-path.test.ts Switches test imports to .js specifiers.
packages/taco/test/conditions/base/json-api.test.ts Switches test imports to .js specifiers.
packages/taco/test/conditions/base/ecdsa.test.ts Switches test imports to .js specifiers.
packages/taco/test/conditions/base/contract.test.ts Switches test imports to .js specifiers.
packages/taco/test/conditions/base/context-variable.test.ts Switches test imports to .js specifiers.
packages/taco/test/conditions/base/condition.test.ts Switches test imports to .js specifiers.
packages/taco/test/conditions/any-condition-schema.test.ts Switches test imports to .js specifiers.
packages/taco/src/tdec.ts Uses .js internal specifiers; replaces ethers/lib/utils deep imports.
packages/taco/src/taco.ts Uses .js internal specifiers; replaces keccak256 deep import.
packages/taco/src/sign.ts Uses .js internal specifiers.
packages/taco/src/index.ts Uses .js specifiers for public exports/barrels.
packages/taco/src/conditions/shared.ts Uses .js specifiers in schema exports.
packages/taco/src/conditions/sequential.ts Uses .js specifiers for internal imports/exports.
packages/taco/src/conditions/schemas/variable-operation.ts Uses .js specifier for schema import.
packages/taco/src/conditions/schemas/utils.ts Uses .js specifiers for schema imports.
packages/taco/src/conditions/schemas/time.ts Uses .js specifier for schema import.
packages/taco/src/conditions/schemas/signing.ts Replaces deep ethers/lib/utils types with ethers.utils.*; uses .js schema imports.
packages/taco/src/conditions/schemas/sequential.ts Uses .js specifiers for internal imports.
packages/taco/src/conditions/schemas/rpc.ts Uses .js specifiers for internal imports.
packages/taco/src/conditions/schemas/return-value-test.ts Uses .js specifiers for internal imports.
packages/taco/src/conditions/schemas/jwt.ts Uses .js specifiers for internal imports.
packages/taco/src/conditions/schemas/json.ts Uses .js specifiers for internal imports.
packages/taco/src/conditions/schemas/json-rpc.ts Uses .js specifiers for internal imports.
packages/taco/src/conditions/schemas/json-api.ts Uses .js specifiers for internal imports.
packages/taco/src/conditions/schemas/if-then-else.ts Uses .js specifiers for internal imports.
packages/taco/src/conditions/schemas/export-for-zod-doc-gen.ts Uses .js specifiers for export order file.
packages/taco/src/conditions/schemas/ecdsa.ts Uses .js specifiers for internal imports.
packages/taco/src/conditions/schemas/contract.ts Uses .js specifiers for internal imports.
packages/taco/src/conditions/schemas/context.ts Uses .js specifiers for internal imports.
packages/taco/src/conditions/schemas/context-variable.ts Uses .js specifiers for internal imports.
packages/taco/src/conditions/schemas/compound.ts Uses .js specifiers for internal imports.
packages/taco/src/conditions/schemas/common.ts Uses .js specifier for const import.
packages/taco/src/conditions/predefined/index.ts Uses .js specifiers for predefined barrels.
packages/taco/src/conditions/predefined/erc721.ts Uses .js specifier for internal base import.
packages/taco/src/conditions/predefined/erc20.ts Uses .js specifier for internal base import.
packages/taco/src/conditions/predefined/address-allowlist.ts Uses .js specifiers for internal imports/exports.
packages/taco/src/conditions/multi-condition.ts Uses .js specifiers for internal imports.
packages/taco/src/conditions/index.ts Uses .js specifiers for condition module barrels.
packages/taco/src/conditions/if-then-else-condition.ts Uses .js specifiers for internal imports/exports.
packages/taco/src/conditions/context/index.ts Uses .js specifier for context barrel.
packages/taco/src/conditions/context/context.ts Uses .js specifiers for internal imports.
packages/taco/src/conditions/condition.ts Uses .js specifiers for internal imports/exports.
packages/taco/src/conditions/condition-factory.ts Uses .js specifiers for internal imports.
packages/taco/src/conditions/condition-expr.ts Uses .js specifiers for internal imports.
packages/taco/src/conditions/compound-condition.ts Uses .js specifiers for internal imports/exports.
packages/taco/src/conditions/base/time.ts Uses .js specifiers for internal imports/exports.
packages/taco/src/conditions/base/signing.ts Uses .js specifiers for internal imports/exports.
packages/taco/src/conditions/base/rpc.ts Uses .js specifiers for internal imports/exports.
packages/taco/src/conditions/base/jwt.ts Uses .js specifiers for internal imports/exports.
packages/taco/src/conditions/base/json.ts Uses .js specifiers for internal imports/exports.
packages/taco/src/conditions/base/json-rpc.ts Uses .js specifiers for internal imports/exports.
packages/taco/src/conditions/base/json-api.ts Uses .js specifiers for internal imports/exports.
packages/taco/src/conditions/base/index.ts Uses .js specifiers for base barrel exports.
packages/taco/src/conditions/base/ecdsa.ts Uses .js specifiers for internal imports/exports.
packages/taco/src/conditions/base/contract.ts Uses .js specifiers for internal imports/exports.
packages/taco/src/conditions/base/context-variable.ts Uses .js specifiers for internal imports.
packages/taco/package.json Conditional exports w/ types; adds postbuild dist markers; updates author.
packages/taco/integration-test/sign.test.ts Switches integration-test imports to .js specifiers.
packages/taco/integration-test/encrypt-decrypt.test.ts Switches integration-test imports to .js specifiers.
packages/taco/integration-test/condition-lingo.test.ts Switches integration-test imports to .js specifiers.
packages/taco/.eslintrc.js Removed in favor of .cjs.
packages/taco/.eslintrc.cjs Re-adds package ESLint config as .cjs.
packages/taco-auth/tsconfig.es.json Sets ES build moduleResolution to Bundler.
packages/taco-auth/tsconfig.cjs.json Sets CJS build moduleResolution to node.
packages/taco-auth/test/auth-sig.test.ts Switches test imports to .js specifiers.
packages/taco-auth/test/auth-provider.test.ts Switches test imports to .js specifiers and explicit index path.
packages/taco-auth/src/storage.ts Uses .js specifier for internal import.
packages/taco-auth/src/providers/index.ts Uses .js specifiers for provider exports.
packages/taco-auth/src/providers/eip4361/external-eip4361.ts Uses .js specifiers for internal imports.
packages/taco-auth/src/providers/eip4361/eip4361.ts Uses .js specifiers for internal imports.
packages/taco-auth/src/providers/eip4361/auth.ts Uses .js specifier for internal import.
packages/taco-auth/src/providers/eip1271/eip1271.ts Uses .js specifiers for internal imports.
packages/taco-auth/src/providers/eip1271/auth.ts Uses .js specifier for internal import.
packages/taco-auth/src/index.ts Uses .js specifiers for public exports.
packages/taco-auth/src/auth-sig.ts Uses .js specifiers for internal imports.
packages/taco-auth/src/auth-provider.ts Uses .js specifier for internal import.
packages/taco-auth/package.json Conditional exports w/ types; adds postbuild dist markers; updates author.
packages/taco-auth/.eslintrc.js Removed in favor of .cjs.
packages/taco-auth/.eslintrc.cjs Re-adds package ESLint config as .cjs.
packages/shared/tsconfig.es.json Sets ES build moduleResolution to Bundler.
packages/shared/tsconfig.cjs.json Sets CJS build moduleResolution to node.
packages/shared/test/signing-coordinator-cache.test.ts Switches test imports to .js specifiers (mocking concern noted).
packages/shared/test/schemas.test.ts Switches test import to explicit index .js.
packages/shared/test/porter.test.ts Switches test imports to .js specifiers.
packages/shared/src/web3.ts Uses .js specifier for internal import.
packages/shared/src/types.ts Uses .js specifier for internal import.
packages/shared/src/porter.ts Uses .js specifiers for internal imports.
packages/shared/src/index.ts Uses .js specifiers for public exports.
packages/shared/src/contracts/index.ts Uses .js specifiers for contract barrel exports.
packages/shared/src/contracts/ethers-typechain/index.ts Updates generated exports to .js specifiers (generator overwrite concern noted).
packages/shared/src/contracts/ethers-typechain/factories/index.ts Updates generated exports to .js specifiers.
packages/shared/src/contracts/ethers-typechain/factories/SubscriptionManager__factory.ts Updates generated import to .js specifier.
packages/shared/src/contracts/ethers-typechain/factories/SigningCoordinator__factory.ts Updates generated import to .js specifier.
packages/shared/src/contracts/ethers-typechain/factories/GlobalAllowList__factory.ts Updates generated import to .js specifier.
packages/shared/src/contracts/ethers-typechain/factories/Coordinator__factory.ts Updates generated import to .js specifier.
packages/shared/src/contracts/ethers-typechain/SubscriptionManager.ts Updates generated import to .js specifier.
packages/shared/src/contracts/ethers-typechain/SigningCoordinator.ts Updates generated import to .js specifier.
packages/shared/src/contracts/ethers-typechain/GlobalAllowList.ts Updates generated import to .js specifier.
packages/shared/src/contracts/ethers-typechain/Coordinator.ts Updates generated import to .js specifier.
packages/shared/src/contracts/agents/subscription-manager.ts Uses .js specifiers for internal imports.
packages/shared/src/contracts/agents/signing-coordinator.ts Uses .js specifiers for internal imports.
packages/shared/src/contracts/agents/index.ts Uses .js specifiers for barrel exports.
packages/shared/src/contracts/agents/global-allow-list.ts Uses .js specifiers for internal imports.
packages/shared/src/contracts/agents/coordinator.ts Uses .js specifiers for internal imports.
packages/shared/package.json Conditional exports w/ types; adds postbuild dist markers; updates author.
packages/shared/.eslintrc.js Removed in favor of .cjs.
packages/shared/.eslintrc.cjs Re-adds package ESLint config as .cjs.
packages/pre/tsconfig.es.json Sets ES build moduleResolution to Bundler.
packages/pre/tsconfig.cjs.json Sets CJS build moduleResolution to node.
packages/pre/test/utils.ts Switches test imports to .js specifiers.
packages/pre/test/pre.test.ts Switches test imports to .js specifiers.
packages/pre/test/message-kit.test.ts Switches test imports to .js specifiers.
packages/pre/test/enrico.test.ts Switches test imports to .js specifiers.
packages/pre/test/cohort.test.ts Switches test imports to .js specifiers.
packages/pre/test/acceptance/delay-enact.test.ts Switches test imports to .js specifiers.
packages/pre/test/acceptance/alice-grants.test.ts Switches test imports to .js specifiers.
packages/pre/src/policy.ts Uses .js specifier for internal import.
packages/pre/src/kits/message.ts Uses .js specifier for internal import.
packages/pre/src/kits/index.ts Uses .js specifiers for barrel exports.
packages/pre/src/keyring.ts Uses .js specifier for internal import.
packages/pre/src/index.ts Uses .js specifiers for public exports.
packages/pre/src/characters/index.ts Uses .js specifiers for barrel exports.
packages/pre/src/characters/enrico.ts Uses .js specifier for internal import.
packages/pre/src/characters/bob.ts Uses .js specifiers for internal imports.
packages/pre/src/characters/alice.ts Uses .js specifiers for internal imports.
packages/pre/package.json Conditional exports w/ types; adds postbuild dist markers; updates author.
packages/pre/.eslintrc.js Removed in favor of .cjs.
packages/pre/.eslintrc.cjs Re-adds package ESLint config as .cjs.

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

Comment thread packages/shared/test/signing-coordinator-cache.test.ts Outdated
Comment thread packages/shared/src/contracts/ethers-typechain/index.ts
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 163 out of 164 changed files in this pull request and generated 6 comments.


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

Comment on lines +5 to +6
"module": "CommonJS",
"moduleResolution": "node"
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

tsconfig.cjs.json sets moduleResolution to node, but this package’s TS sources now import local modules using .js specifiers (e.g. import ... from './utils.js'). With moduleResolution: node, TypeScript typically requires the referenced .js file to exist on disk (it won’t map ./utils.js to ./utils.ts), which can break the CJS build. Consider using moduleResolution: "Bundler"/"NodeNext" here as well, or remove this override to inherit the ESM config’s resolution so .js specifiers resolve to .ts sources during compilation.

Copilot uses AI. Check for mistakes.
Comment on lines +5 to +6
"module": "CommonJS",
"moduleResolution": "node"
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

tsconfig.cjs.json forces moduleResolution: "node", but the codebase now uses .js extensions in relative imports from TS sources. Unless the corresponding .js files exist in src/ at build time, this can make tsc --build for the CJS project fail to resolve modules. Using moduleResolution: "Bundler"/"NodeNext" (or inheriting it from the ES config) avoids this by allowing .js specifiers to resolve to .ts sources.

Copilot uses AI. Check for mistakes.
Comment on lines +5 to +6
"module": "CommonJS",
"moduleResolution": "node"
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

This CJS build config sets moduleResolution to node, but this PR updates many internal imports to include .js extensions (for ESM compatibility). With moduleResolution: node, TypeScript can fail to resolve ./foo.js to ./foo.ts during compilation, which may break build:cjs. Prefer moduleResolution: "Bundler"/"NodeNext" here (or drop the override) so .js specifiers are resolvable from TS source.

Suggested change
"module": "CommonJS",
"moduleResolution": "node"
"module": "CommonJS"

Copilot uses AI. Check for mistakes.
Comment on lines +5 to +6
"module": "CommonJS",
"moduleResolution": "node"
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

moduleResolution is set to node in the CJS tsconfig, but the package’s TS source imports now use .js in specifiers. This combination commonly causes tsc to look for real .js files in src/ (which don’t exist), failing the CJS build. Using moduleResolution: "Bundler"/"NodeNext" (or inheriting from tsconfig.es.json) will keep .js specifiers compatible with TS source files.

Copilot uses AI. Check for mistakes.
Comment on lines +5 to +6
"module": "CommonJS",
"moduleResolution": "node"
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

The CJS tsconfig overrides moduleResolution to node, but this PR changes internal TS imports to include .js file extensions. If TypeScript treats ./x.js as a literal file path under moduleResolution: node, the CJS build can fail because src/*.js files don’t exist (only *.ts). Consider switching this to moduleResolution: "Bundler"/"NodeNext" or inheriting from the ES config so .js specifiers resolve to TS sources during compilation.

Copilot uses AI. Check for mistakes.
Comment thread packages/shared/src/contracts/ethers-typechain/Coordinator.ts
@derekpierre derekpierre mentioned this pull request Apr 21, 2026
20 tasks
@derekpierre derekpierre deleted the branch nucypher:signing-epic April 21, 2026 12:31
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.

3 participants