fix #187: Dynamic require error from bundled use-sync-external-store shim#188
Open
fantonangeli wants to merge 2 commits into
Conversation
Signed-off-by: fantonangeli <fabrizio.antonangeli@gmail.com>
Signed-off-by: fantonangeli <fabrizio.antonangeli@gmail.com>
✅ Deploy Preview for swf-editor ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses #187 by preventing use-sync-external-store from being bundled into the @serverlessworkflow/diagram-editor ESM build (avoiding the CommonJS shim path that can trigger require("react") at runtime in browser-only ESM consumers). It also ensures the package is available at runtime by declaring it as a direct dependency.
Changes:
- Mark
use-sync-external-store(including subpaths) as Rollup external in the diagram editor’s Vite library build. - Add
use-sync-external-storeas a runtime dependency of@serverlessworkflow/diagram-editor. - Add the dependency to the pnpm catalog and lockfile, and include a changeset for release.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-workspace.yaml | Adds use-sync-external-store to the shared pnpm catalog for consistent versioning. |
| pnpm-lock.yaml | Locks use-sync-external-store@1.6.0 and records it under the diagram editor importer. |
| packages/serverless-workflow-diagram-editor/vite.config.ts | Externalizes use-sync-external-store to avoid bundling the CJS shim into the ESM output. |
| packages/serverless-workflow-diagram-editor/package.json | Declares use-sync-external-store as a runtime dependency. |
| .changeset/fix-cjs-use-sync-external-store-bundle.md | Adds a release note describing the ESM compatibility fix and dependency change. |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Closes #187
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.
How to test
@serverlessworkflow/diagram-editorpackagedist/index.js.No CJS is found
5. Load the Diagram Editor in the browser.
6. The Diagram Editor is not loaded