-
Notifications
You must be signed in to change notification settings - Fork 40
feat: externalize jsx-runtime #2448
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Updates @grafana/create-plugin scaffolds and tooling to avoid bundling react/jsx-runtime (and react/jsx-dev-runtime) so plugins don’t couple themselves to React internals as Grafana moves toward React 19.
Changes:
- Bump scaffolded plugins’
grafanaDependencyto>=12.3.0(app/panel/datasource/scenes-app templates). - Externalize
react/jsx-runtimeandreact/jsx-dev-runtimein the common bundler externals template. - Add AST utilities + a new “externalize-jsx-runtime” addition codemod (with tests) to retrofit existing plugins.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/create-plugin/templates/scenes-app/src/plugin.json | Bumps default Grafana dependency for new scenes-app scaffolds. |
| packages/create-plugin/templates/panel/src/plugin.json | Bumps default Grafana dependency for new panel scaffolds. |
| packages/create-plugin/templates/datasource/src/plugin.json | Bumps default Grafana dependency for new datasource scaffolds. |
| packages/create-plugin/templates/app/src/plugin.json | Bumps default Grafana dependency for new app scaffolds. |
| packages/create-plugin/templates/common/.config/bundler/externals.ts | Adds react/jsx-runtime and react/jsx-dev-runtime to scaffold externals list. |
| packages/create-plugin/src/codemods/utils.ts | Adds a helper to render template files for codemods (with optional warning injection). |
| packages/create-plugin/src/codemods/utils.ast.ts | Introduces reusable recast AST helpers for codemods. |
| packages/create-plugin/src/codemods/utils.ast.test.ts | Adds unit tests for the new AST helpers. |
| packages/create-plugin/src/codemods/additions/scripts/externalize-jsx-runtime.ts | New addition codemod to externalize jsx runtimes and adjust plugin.json ranges. |
| packages/create-plugin/src/codemods/additions/scripts/externalize-jsx-runtime.test.ts | Tests for the new addition codemod behavior and idempotency. |
packages/create-plugin/src/codemods/additions/scripts/externalize-jsx-runtime.ts
Show resolved
Hide resolved
packages/create-plugin/src/codemods/additions/scripts/externalize-jsx-runtime.ts
Show resolved
Hide resolved
packages/create-plugin/src/codemods/additions/scripts/externalize-jsx-runtime.test.ts
Show resolved
Hide resolved
packages/create-plugin/src/codemods/additions/scripts/externalize-jsx-runtime.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did an initial pass and it looks good but I added some comments, I'm going to test this locally as well
packages/create-plugin/src/codemods/additions/scripts/externalize-jsx-runtime.ts
Show resolved
Hide resolved
packages/create-plugin/src/codemods/additions/scripts/externalize-jsx-runtime.ts
Show resolved
Hide resolved
…nt code with single quotes
c8f1fd8 to
d0277cb
Compare
hugohaggmark
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work 🚀
- tested on an existing rspack project
- tested on an existing webpack project

What this PR does / why we need it:
The approaching move to React 19 in Grafana core codebase has highlighted an issue with plugins that are bundling
react/jsx-runtimewhich expects a specific version of React as it uses the react internals API. This PR aims to address this with the following:react/jsx-runtimeandreact/jsx-dev-runtimeexternalised for new plugin scaffoldsWhich issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Can be tested by using the canary release version from below like so
npx @grafana/create-plugin@canary add externalize-jsx-runtime📦 Published PR as canary version:
Canary Versions✨ Test out this PR locally via:
npm install website@5.5.0-canary.2448.21942905946.0 npm install @grafana/create-plugin@6.9.0-canary.2448.21942905946.0 # or yarn add website@5.5.0-canary.2448.21942905946.0 yarn add @grafana/create-plugin@6.9.0-canary.2448.21942905946.0