Describe the Bug
The diagram-editor package currently bundles the use-sync-external-store as CJS. In some ESM/browser consumers, this can result in a CJS runtime call to require("react"), which fails in browser-only environments with:
Dynamic require of "react" is not supported
This issue prevents the entire package to be loaded by the browser.
This is related to the use-sync-external-store ESM compatibility issue discussed in react/react#24590.
Steps to reproduce
- Build the
@serverlessworkflow/diagram-editor package as an ESM bundle.
- Inspect the generated
dist/index.js.
- Observe the cjs path from the dist:
$ grep -n 'use-sync-external-store' packages/serverless-workflow-diagram-editor/dist/index.js
4221://#region ../../node_modules/.pnpm/use-sync-external-store@1.6.0_react@19.2.7/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js
4266: d || a.startTransition === void 0 || (d = !0, console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));
- Consume the package from a browser-only ESM application or another ESM bundle.
- Load the Diagram Editor in the browser.
- The Diagram Editor is not loaded
Expected Behavior
The package should not bundle the CommonJS libraries shim into the ESM dist/index.js, and the Diagram Editor should load successfully in the browser.
Editor Version
0.0.0
Platform
Web / Browser
Additional Context
No response
Describe the Bug
The diagram-editor package currently bundles the
use-sync-external-storeas CJS. In some ESM/browser consumers, this can result in a CJS runtime call torequire("react"), which fails in browser-only environments with:This issue prevents the entire package to be loaded by the browser.
This is related to the use-sync-external-store ESM compatibility issue discussed in react/react#24590.
Steps to reproduce
@serverlessworkflow/diagram-editorpackage as an ESM bundle.dist/index.js.Expected Behavior
The package should not bundle the CommonJS libraries shim into the ESM
dist/index.js, and the Diagram Editor should load successfully in the browser.Editor Version
0.0.0
Platform
Web / Browser
Additional Context
No response