fix(devframe): bundle agnostic ohash digest to keep node:crypto out of browser#6
Merged
Merged
Conversation
…f browser `ohash/crypto` resolves to its `node` variant under tsdown's default conditions, inlining `node:crypto.createHash` into the bundled `utils/hash.mjs` chunk that is transitively re-exported through the `client` entry. Force the agnostic (pure-JS) variant by aliasing `ohash/crypto` to the path produced by `mlly.resolveSync` without the `node` condition. Both implementations emit identical SHA-256 + base64url output, so existing hash snapshots remain stable.
✅ Deploy Preview for devfra ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
5 tasks
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
ohash's main entry importsdigestfromohash/crypto, whose conditional exports picknode(which importsnode:crypto.createHash) when bundled by tsdown. That digest was being inlined intodist/utils/hash.mjsand transitively re-exported throughdist/client/index.mjsviarpc/cache.ts, so every browser consumer ofdevframe/clientended up with anode:cryptoimport — broken.ohash/cryptoto the path produced bymlly.resolveSyncwithconditions: ['import'], skipping thenodebranch only for this specifier (other deps keep normal resolution).mllyto thebuildcatalog and to devframe's devDependencies so the build-time resolution is properly declared. No source change needed — the alias is transparent toutils/hash.ts.Test plan
pnpm build—grep -RE "node:crypto|createHash" packages/devframe/dist/returns no matches; bundled hash chunk now embedsohash/dist/crypto/js/index.mjs.pnpm test— 283 tests pass, snapshots indumps.test.ts.snapunchanged (JS and Node digests are bit-identical for SHA-256 + base64url).pnpm lintandpnpm typecheckclean.