Repository navigation
fix: emit type module marker in _types package.json - #467
javadtavakoli wants to merge 1 commit into
Conversation
|
@javadtavakoli is attempting to deploy a commit to the Wevm Team on Vercel. A member of the Team first needs to authorize it. |
|
Friendly ping @jxom — this is the ox half of wevm/viem#4903 (which you merged; wevm/viem#4843 identified the bundled CI hasn't run yet — looks like the workflows need approval for a first-time contributor. Happy to adjust anything. |
|
Thanks @javadtavakoli! Superseded by #579, which lands this change on |
Supersedes #467. Amp-Thread-ID: https://ampcode.com/threads/T-01a1bc8e-d920-74b4-aabe-ef8b2e6421b2 Co-authored-by: Amp <amp@ampcode.com> Co-authored-by: Javad Tavakoli <16999504+javadtavakoli@users.noreply.github.com> Co-authored-by: jxom <jake@tempo.xyz>
Summary
{"type":"module"}intosrc/_types/package.jsonduringbuild:types, matching the existing_esm/_cjsmarkersmodule: node16(TS1479 / TS1541)This is the same fix that was accepted in viem: wevm/viem#4903. That change came out of wevm/viem#4843, which fixed viem's own
_types/marker and explicitly identified the bundledox0.14.x as the remaining source of the leftoverTS1479s. This PR is that remaining half.The problem
scripts/prepublish.tsdoesdelete packageJson.type, so the published rootpackage.jsonhas no"type"field and defaults to CommonJS.build:esmandbuild:cjseach write a marker into the folder they emit, butbuild:typesdoes not:package.json"type"_esm/"module"✅_cjs/"commonjs"✅_types/So every
_types/**/*.d.tsis resolved as CommonJS. Those files use ESM syntax and importabitype, which is"type": "module"— a CJS file importing ESM:This survives ox's own CI because
check:typestypechecks the source, never the emitted_types/as a consumer resolves it through theexportsmap. It only appears downstream.Reproduction
index.ts:Verify the fix is exactly the missing marker:
Which configurations are affected
module: node16module: nodenextTypeScript 5.8 taught
nodenextthat Node 22+ permitsrequire(esm), sonodenexton current TypeScript no longer surfaces it — please reproduce withnode16, which is still a fully supported setting and is what pins Node 16 CJS/ESM semantics.I also hit this on a larger
module: node16project consuming ox through viem, where it produced 12 × TS1479 across 7 declaration files (Abi,AbiConstructor,AbiError,AbiEvent,AbiFunction,AbiItem,AbiParameters); adding the marker cleared all 12.Why it's worth patching the 0.x line
viem@2.56.8pins"ox": "0.14.45"exactly, so this reaches every viem consumer onnode16resolution, not just direct ox users. The workarounds today are turning onskipLibCheckor patchingoxinnode_modules— and library authors who re-export these types withdeclaration: truecan't useskipLibCheckto hide it, since the mismatch propagates into their own emitted declarations.ox@1.xis unaffected — it keeps"type": "module"on the published root and emits todist/— so this targets0.xonly.Test plan
pnpm build:typeswritessrc/_types/package.jsoncontaining{"type":"module"}skipLibCheck: false; absent → TS1479/TS1541 as listedox@0.14.45and the currentox@0.14.47tarball, neither of which ships_types/package.json