Skip to content

Fix React embed ESM packaging for Vite 8#192

Open
byrnehollander wants to merge 6 commits intoformsort:masterfrom
byrnehollander:rewrite-react-embed-esm
Open

Fix React embed ESM packaging for Vite 8#192
byrnehollander wants to merge 6 commits intoformsort:masterfrom
byrnehollander:rewrite-react-embed-esm

Conversation

@byrnehollander
Copy link
Copy Markdown

@byrnehollander byrnehollander commented Apr 29, 2026

What changes

  • Adds ESM entrypoints for @formsort/react-embed and its direct embed dependency chain while preserving CJS entrypoints.
  • Rewrites @formsort/react-embed around hooks, stable event callbacks, cleanup, StrictMode behavior, and prop-driven reloads.
  • Handles old CJS-only messaging manager installs from the web ESM entry, and bundles constants into the manager ESM build.

Why

A Vite 8 upgrade exposed that React embed and its dependency chain were still CJS-oriented, which caused the embed to break in modern ESM builds. This PR fixes that packaging issue for other consumers while also modernizing the small React wrapper code that was already being touched.

Upgrade path

This should be a minor upgrade for documented usage: root imports continue to work for ESM and CJS, and React embed props are not renamed or removed. It is minor rather than patch because package output changed and EmbedFlow now reloads when load props such as clientLabel, flowLabel, variantLabel, queryParams, or embedConfig change. Deep lib/* imports are internal and are not guaranteed.

Verification

  • corepack yarn build, corepack yarn test, corepack yarn lint
  • Focused React embed and web embed API builds/tests
  • CJS require and ESM import smoke tests
  • Vite 8 packed-tarball build, fake CJS messaging manager smoke, and Parcel event-log example build against packed tarballs

Closes #184

@byrnehollander byrnehollander changed the title Rewrite react embed for ESM compatibility Modernize embed packages for ESM compatibility Apr 29, 2026
@byrnehollander byrnehollander changed the title Modernize embed packages for ESM compatibility Modernize React embed for ESM compatibility Apr 29, 2026
@byrnehollander byrnehollander changed the title Modernize React embed for ESM compatibility Modernize React embed and package ESM outputs Apr 29, 2026
@byrnehollander byrnehollander changed the title Modernize React embed and package ESM outputs Modernize React embed ESM/CJS packaging Apr 29, 2026
@byrnehollander byrnehollander changed the title Modernize React embed ESM/CJS packaging Fix React embed ESM packaging for Vite 8 Apr 29, 2026
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.

[Request] Publish code with ESM syntax/avoid using default export with CJS syntaxes

1 participant