fix(cc-widgets): externalize react/jsx-runtime to prevent bundling Re…#635
Open
cmullenx wants to merge 1 commit intowebex:nextfrom
Open
fix(cc-widgets): externalize react/jsx-runtime to prevent bundling Re…#635cmullenx wants to merge 1 commit intowebex:nextfrom
cmullenx wants to merge 1 commit intowebex:nextfrom
Conversation
|
This pull request is automatically being deployed by Amplify Hosting (learn more). |
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.
COMPLETES #. https://jira-eng-sjc12.cisco.com/jira/browse/CAI-7686
Ability of epic-app to consume the widgets
When webex/cc-widgets is consumed by a Vite-based application the bundled react/jsx-runtime and react/jsx-dev-runtime modules inside cc-widgets cause an error. This happens because webpack bundles a separate copy of React's jsx-runtime into the cc-widgets output, which then conflicts with the host application's React instance during Vite's esbuild pre-bundling. Vite cannot deduplicate React when jsx-runtime is embedded inside the webpack bundle rather than declared as an external dependency.
Updating the webpack externals for cc-widgets
Added react/jsx-runtime and react/jsx-dev-runtime to the externals configuration in packages/contact-center/cc-widgets/webpack.config.js. This ensures webpack generates require("react/jsx-runtime") calls instead of bundling the jsx-runtime code, allowing the consuming bundler (Vite/esbuild) to resolve these to the host application's single React instance.
This update also had to be made in the cc-digital-interactions package
< DESCRIBE THE CONTEXT OF THE ISSUE >
Vite based application could not use latest version of widgets
Updated webpack build
Change Type
The following scenarios were tested
Verified that the original npm webex/cc-widgets@1.28.0-next.27 (without this fix) reproduces the ReactCurrentOwner error in a Vite-based app (epic-app)
Rebuilt cc-widgets with the jsx-runtime externals, copied dist to epic-app, cleared Vite cache, and confirmed the ReactCurrentOwner error is resolved
All existing unit tests pass (pre-commit hook ran successfully: cc-store, cc-components, cc-digital-channels, cc-widgets, cc-station-login, cc-task, cc-ui-logging, cc-user-state, test-fixtures)
The GAI Coding Policy And Copyright Annotation Best Practices
Checklist before merging
Make sure to have followed the contributing guidelines before submitting.