Repository navigation
fix: emit type module marker in _types package.json - #467
Open
javadtavakoli wants to merge 1 commit into
Open
javadtavakoli wants to merge 1 commit into
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. |
Author
|
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. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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