Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: exclude jsx-runtime from bundle #1928

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

a88zach
Copy link

@a88zach a88zach commented Dec 6, 2024

Updates

Exclude react/jsx-runtime from the final bundle. This should be excluded to allow users to update to React v19.

Including this dependency in the bundle results in
"TypeError: Cannot read properties of undefined (reading 'ReactCurrentDispatcher')"

fixes #1927

@a88zach a88zach requested review from theiliad and a team as code owners December 6, 2024 21:02
Copy link

netlify bot commented Dec 6, 2024

Deploy Preview for carbon-charts-core ready!

Name Link
🔨 Latest commit 88f9659
🔍 Latest deploy log https://app.netlify.com/sites/carbon-charts-core/deploys/6753665249c857000869119b
😎 Deploy Preview https://deploy-preview-1928--carbon-charts-core.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Dec 6, 2024

Deploy Preview for carbon-charts-react ready!

Name Link
🔨 Latest commit 88f9659
🔍 Latest deploy log https://app.netlify.com/sites/carbon-charts-react/deploys/675366528df25800086b25e1
😎 Deploy Preview https://deploy-preview-1928--carbon-charts-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Dec 6, 2024

Deploy Preview for carbon-charts-angular ready!

Name Link
🔨 Latest commit 88f9659
🔍 Latest deploy log https://app.netlify.com/sites/carbon-charts-angular/deploys/67536652a0cf9100080879c3
😎 Deploy Preview https://deploy-preview-1928--carbon-charts-angular.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Dec 6, 2024

Deploy Preview for carbon-charts-docs ready!

Name Link
🔨 Latest commit 88f9659
🔍 Latest deploy log https://app.netlify.com/sites/carbon-charts-docs/deploys/675366524466190008d33ba3
😎 Deploy Preview https://deploy-preview-1928--carbon-charts-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@theiliad
Copy link
Member

I don't think 'react/jsx-runtime' can just be dropped, that could break support for react17 or 18

@a88zach
Copy link
Author

a88zach commented Dec 10, 2024

I don't think 'react/jsx-runtime' can just be dropped, that could break support for react17 or 18

This doesn't necessarily drop it, it just excludes it from the bundle. Then instead of the 3rd party package being bundled, it is required at the top of the bundle. This way the version used matches the version installed by the user which changes between React 18 and 19

It's the same reason you are already excluding react and react-dom. You want the code to use the installed version and not an explicit version

@theiliad
Copy link
Member

I don't think 'react/jsx-runtime' can just be dropped, that could break support for react17 or 18

This doesn't necessarily drop it, it just excludes it from the bundle. Then instead of the 3rd party package being bundled, it is required at the top of the bundle. This way the version used matches the version installed by the user which changes between React 18 and 19

It's the same reason you are already excluding react and react-dom. You want the code to use the installed version and not an explicit version

Are you having these issues with the UMD bundle? or with the ESM?

@a88zach
Copy link
Author

a88zach commented Dec 20, 2024

I'm using NextJs, so it's using the ESM bundle, but it would also be a problem when using the UMD bundle. Although not officially supported yet by this library, if you try to use the library with React 19, you'll see the issue. If you try to search the bundles for react-jsx-runtime, you can see that it gets bundled.

React dependencies should be peer dependencies and not bundled

Copy link
Member

@dabrad26 dabrad26 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@theiliad any update here? This seems logical to require peer deps and this is stopping successful migration to React 19. I confirmed no issue with React 19 and the main Carbon library. The issue is only with the charts package.

    TypeError: Cannot read properties of undefined (reading 'ReactCurrentDispatcher')

      1 | import React from 'react';
    > 3 | import {GaugeChart} from '@carbon/charts-react';

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.

[Bug]: jsx-runtime included in bundle
3 participants