Skip to content

fix: build root shims export - #161

Open
mojobeeping wants to merge 1 commit into
davidmyersdev:mainfrom
mojobeeping:mojobeep/restore-shims-root-export
Open

fix: build root shims export#161
mojobeeping wants to merge 1 commit into
davidmyersdev:mainfrom
mojobeeping:mojobeep/restore-shims-root-export

Conversation

@mojobeeping

Copy link
Copy Markdown

Summary

Restores the published vite-plugin-node-polyfills/shims export by building the aggregate shims entrypoint.

package.json currently exports ./shims to ./shims/dist/index.js and ./shims/dist/index.cjs, but the build only emits buffer, global, and process shims. A clean install of vite-plugin-node-polyfills@0.28.0 fails when importing the advertised root shims subpath:

ERR_MODULE_NOT_FOUND Cannot find module '.../node_modules/vite-plugin-node-polyfills/shims/dist/index.js'

This PR:

  • adds shims/index.ts as the aggregate shim entrypoint
  • adds build:shims:index so pnpm run build:shims emits shims/dist/index.js and shims/dist/index.cjs

Verification

pnpm run build
pnpm run test:unit
pnpm exec eslint shims/index.ts package.json
git diff --check

Packed tarball clean-consumer proof:

PUBLISHED_IMPORT_FAIL ERR_MODULE_NOT_FOUND Cannot find module '.../vite-plugin-node-polyfills/shims/dist/index.js'
PATCHED_ESM_OK function object object Blob,BlobOptions,Buffer,File,FileOptions,INSPECT_MAX_BYTES,SlowBuffer,TranscodeEncoding
PATCHED_CJS_OK function object object Blob,BlobOptions,Buffer,File,FileOptions,INSPECT_MAX_BYTES,SlowBuffer,TranscodeEncoding
PACK_HAS_ROOT_SHIMS true true true

chybisov added a commit to lifinance/widget that referenced this pull request Aug 20, 2026
The old note said vite-plugin-env-compatible was the problem and that swapping
in vite-plugin-node-polyfills would fix it. That is no longer true under Vite 8.

The Dynamic SDK reads a bare `process` global (nextTick/versions/emit) and
imports `buffer/index.js`, so it does need Node shims. But
vite-plugin-node-polyfills, while advertising a Vite 8 peer range, aliases its
own shims by bare specifier, and its exports map still carries legacy
trailing-slash keys that resolve to files. Rolldown rejects those:

  Expecting folder to folder mapping.
  ".../vite-plugin-node-polyfills/package.json" should end with "/"

Verified on both 0.26.0 and 0.28.0 (identical exports maps), in `vite build`
and again in dev dependency pre-bundling. Upstream fixes are open but
unreleased: davidmyersdev/vite-plugin-node-polyfills#161 and #154, with #158
and #140 reporting this exact error.

Dropping the plugin entirely gets the example to build once `buffer` is a real
dependency — the SDK's own polyfills.js assigns window.global/window.Buffer —
but the free `process` global remains undefined at runtime.

The @dynamic-labs v5 upgrade itself is sound: it type-checks and bundles. Only
the browser polyfill setup is blocked.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant