Skip to content

Conversation

@pauldesmondparker
Copy link

Fix mismatch of ethers/lib.commonjs Provider with ethers/lib.esm Provider. This has been an issue when attempting to construct configuration driven provider fallbacks for did-resolver

Drilling down to the Provider type via this package within an esm package yielded a lib.commonjs Provider that did not match the esm ethers Provider.

Restructure build directories into lib.commonjs and lib.esm. Matches structure in ethers.js

Adjust .gitignore to exclude new out directories

Separated into two tsconfig files named tsconfig.{common,esm}.json

[package.json]
Removed source [not in spec]
Removed type, module, and types from top level Added import and require to exports and re-added types Modified files to point to new out dirs, removed LICENSE (included by default), and src (no utility).
Modified script clean
Added new build: scripts both called from build

Fix mismatch of ethers/lib.commonjs Provider with ethers/lib.esm
Provider. This has been an issue when attempting to construct
configuration driven provider fallbacks for did-resolver

Drilling down to the Provider type via this package within an esm
package yielded a `lib.commonjs` `Provider` that did not match the esm
ethers `Provider`.

Restructure build directories into `lib.commonjs` and `lib.esm`. Matches
structure in ethers.js

Adjust .gitignore to exclude new out directories

Separated into two tsconfig files named `tsconfig.{common,esm}.json`

[package.json]
Removed `source` [not in spec]
Removed `type`, `module`, and `types` from top level
Added `import` and `require` to `exports` and re-added `types`
Modified `files` to point to new out dirs, removed LICENSE (included by
default), and src (no utility).
Modified script `clean`
Added new `build:` scripts both called from `build`
@pauldesmondparker
Copy link
Author

This might seem like a non-issue without some context. We're pulling two types, one from ethers the other from ethr-did-resolver to let us build a FallbackProvider from a configuration list. The types: FallbackProviderConfig and ProviderConfiguration.

type ArgumentsType<T> = T extends (...args: infer U) => any ? U : never;
type FuncGetResolver = typeof ethrDidResolver;
type FuncParameter = ArgumentsType<FuncGetResolver>[0];
interface InfuraConfiguration {
  infuraProjectId: string;
}
type MultiProviderConfiguration = Exclude<FuncParameter, InfuraConfiguration>;
type ProviderConfiguration = Exclude<
  MultiProviderConfiguration['networks'],
  undefined
>[number];

type ProviderOrConfig = ConstructorParameters<
  typeof FallbackProvider
>[0][number];

type FallbackProviderConfig = ProviderOrConfig extends AbstractProvider
  ? never
  : ProviderOrConfig;

However, at the end of this process the Provider type in each is different because ethr-did-resolver uses a require pathway to pull in its ethers.js dependency. This resulted in the following mismatch:

...ethers/lib.esm/providers/network").Network> is not assignable to type
...ethers/lib.commonjs/providers/network").Network>

@pauldesmondparker pauldesmondparker force-pushed the feat/split-esm-commonjs branch from 1a5ea48 to 1235b16 Compare July 22, 2025 07:56
@pauldesmondparker pauldesmondparker force-pushed the feat/split-esm-commonjs branch from 1235b16 to 85e79b1 Compare July 22, 2025 08:06
@pauldesmondparker
Copy link
Author

pauldesmondparker commented Jul 22, 2025

For ease of testing, use the branch #publish on my repo.

Warning

Only pnpm has been tested by me.

With package.json and pnpm:

  "pnpm": {
    "overrides": {
      "ethr-did-resolver": "pauldesmondparker/ethr-did-resolver#publish"
    }
  },

npm:

  "overrides": {
    "ethr-did-resolver": "github:pauldesmondparker/ethr-did-resolver#publish"
  }

yarn:

  "resolutions": {
    "ethr-did-resolver": "https://github.com/pauldesmondparker/ethr-did-resolver#publish"
  }

@pauldesmondparker
Copy link
Author

pauldesmondparker commented Jul 25, 2025

Fixed test. Forgot to specify a tsconfig file in Jest config.

Locally I get a warning about linking for Ganache, but it's likely the version of node I used: lts/iron.

Also ran format and lint.

@pauldesmondparker
Copy link
Author

pauldesmondparker commented Jul 25, 2025

Using lts/hydrogen (same as ci), gives the same linking failure locally:
image

Note

Tests are passing though.

@stale
Copy link

stale bot commented Oct 6, 2025

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 6, 2025
@mirceanis mirceanis added the pinned an issue that may take a while to fix and should not be closed automatically. label Oct 6, 2025
@stale stale bot removed the stale label Oct 6, 2025
@mirceanis mirceanis self-requested a review October 6, 2025 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pinned an issue that may take a while to fix and should not be closed automatically.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants