fix(pow): mark Node-only imports so browser bundlers skip them - #35
Open
0x3639 wants to merge 1 commit into
Open
fix(pow): mark Node-only imports so browser bundlers skip them#350x3639 wants to merge 1 commit into
0x3639 wants to merge 1 commit into
Conversation
Prefix the fs/url/path dynamic imports in pow.ts with `node:` and add `/* @vite-ignore */` next to the existing `webpackIgnore`. Vite/Rolldown otherwise resolves the three specifiers, emits "externalized for browser compatibility" warnings for fs and path, and (with a polyfill plugin present) ships a never-fetched ~51 KB `url` polyfill chunk. Behaviour under isNode() is unchanged: verified PoW init + generate from the packed tarball on Node 22. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NoKrSzV9FwJHGutEwsATAY
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
Follow-up to #34 (targets
feature/browser-bundles, one commit). Prefixes the three Node-only dynamic imports insrc/pow/pow.tswithnode:and adds/* @vite-ignore */alongside the existing/* webpackIgnore: true */:Why
With the modular build now resolved directly by browser bundlers, Vite/Rolldown still tries to resolve the bare
fs/url/pathspecifiers even though they sit underisNode():and, when the consumer has a Node polyfill plugin (common for
Buffer), it emits a never-fetchedurlpolyfill chunk (~51 KB minified) referenced from the SDK chunk. Thenode:prefix plus@vite-ignoremakes every bundler leave the specifiers alone.Verification
urlchunk gone, 271 → 223 modules transformed, no__vite-browser-externalstubs emitted. Tree-shaking results from feat: make the browser build tree-shakeable, drop UMD #34 unchanged (no argon2 / KeyFile / KeyStore / eval in output).--bundle --platform=browserondist/index.js: clean exit.init()+generate()succeed through thenode:imports;KeyStore/KeyFileround trip unaffected.npm test: 650 passing.npm run lint/npm run buildclean.🤖 Generated with Claude Code
https://claude.ai/code/session_01NoKrSzV9FwJHGutEwsATAY