adapters-vite / adapters: CommonJS type declarations import Vite's ESM-only types, so a CommonJS consumer gets TS1479
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 54/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- node.js, typescript, vite
- Domain
- build-system, developer-experience
Research direction
Start by inspecting the published .d.cts declarations for @openzeppelin/adapters-vite and the six adapters’ vite-config entries, then trace how the declaration build uses tsdown and rolldown-plugin-dts. Check whether an upstream bundler option preserves the import type resolution attribute, and add the proposed CommonJS type-check probe for each entry. Done means all seven probes pass under node16 with skipLibCheck: false.
Written by the indexing model from the issue text.
Description
What happens
The CommonJS declaration files of seven published entries import types from vite, and Vite publishes its types as ES modules only:
@openzeppelin/adapters-vite:dist/index.d.ctsimportsPlugin,PluginOptionandUserConfig(checked in the published 15.0.0).- The
vite-configentry of six adapters, eachdist/vite-config.d.ctsimportingUserConfig(Midnight's alsoPlugin):adapter-stellar(checked in the published 6.0.2),adapter-evm,adapter-evm-core,adapter-midnight,adapter-polkadot,adapter-solana.
A consumer file that is CommonJS, imports one of these entries, and type-checks with "module": "node16" or "node18" (or "nodenext" before TypeScript 5.8) and skipLibCheck: false gets TS1479, reported inside the package's .d.cts, for example at dist/vite-config.d.cts(1,28). Since TypeScript 5.8, nodenext accepts a require of an ES module, so that setting no longer errors.
Run-time behavior is not affected. It is a type-check error only.
Why it matters
- The packages ship a
requirecondition with its own types, so they claim to support CommonJS consumers. For these entries the types do not hold under the settings above. - The error points into
node_modules, at a file the consumer cannot edit, and does not say what to do. - Workarounds exist (an
.mtsVite config, a.tsconfig in a"type": "module"package, orskipLibCheck: true), but each consumer has to find them.
Suggested fix
The declaration a CommonJS consumer needs is import type { UserConfig } from 'vite' with { 'resolution-mode': 'import' }. A hand-written .d.cts in that form passes. The build does not produce it today (tsdown 0.19 with rolldown-plugin-dts):
- Written that way in source, the bundler emits the import without
type, and undernode16that is TS2823. - The inline form,
import('vite', { with: { 'resolution-mode': 'import' } }).UserConfig, is hoisted to a plainimport * as … from "vite", which drops the attribute, and TS1479 comes back.
So the options are:
- A post-build step that rewrites the
viteimport in each.d.ctsto theimport type … with { 'resolution-mode': 'import' }form. - A declaration bundler, or bundler version or setting, that keeps
import typetogether with its attribute. Worth checking upstream first, since it would need no custom step.
Either way, fix all seven entries together. Consumers that build through adapters-vite would otherwise still get the error from that package. Add a type-check probe per entry (a CommonJS file under node16, skipLibCheck: false) to the dist checks so it stays fixed.
Not suggested: replacing UserConfig with a local structural type. It changes the declared return type of the adapters' config functions, and adapters-vite exposes Vite types in its public API, so it cannot work there.
- Dominant language
- TypeScript
- Stars
- 2
- Forks
- 2
- Avg merge
- 6h 33m
- Merged PRs (30d)
- 11
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from OpenZeppelin/openzeppelin-adapters
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
OpenZeppelin/openzeppelin-adapters#114 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
OpenZeppelin/openzeppelin-adapters#90 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
OpenZeppelin/openzeppelin-adapters#72 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
OpenZeppelin/openzeppelin-adapters#47 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
OpenZeppelin/openzeppelin-adapters#116 ·
Maintainers usually reply within 1 day
All issues in OpenZeppelin/openzeppelin-adapters
Similar issues
-
Codex使用可 かんたん コード
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ryuki-moro/Nicomaru#348 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
Bug
Difficulty 1/5 Under an hour Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
area-integrations
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day