-
Notifications
You must be signed in to change notification settings - Fork 187
feat: React properties vite plugin #22137
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
…plugin' into feat/react-component-properties-plugin
flow-server/src/main/resources/plugins/react-component-properties-plugin/index.ts
Outdated
Show resolved
Hide resolved
flow-server/src/main/resources/plugins/react-component-properties-plugin/index.ts
Show resolved
Hide resolved
Are you sure intrinsic element types are imported? Here, vite tests do not load them so I mimic them here. It should not happen in the PR where plugin is inline with a test project https://github.com/vaadin/copilot-internal/pull/6576 |
I have no idea what that means. I ran the test project in Copilot. |
flow-server/src/main/resources/plugins/react-component-properties-plugin/index.ts
Outdated
Show resolved
Hide resolved
flow-server/src/main/resources/plugins/react-component-properties-plugin/index.ts
Outdated
Show resolved
Hide resolved
flow-server/src/main/resources/plugins/react-component-properties-plugin/index.ts
Show resolved
Hide resolved
flow-server/src/main/resources/plugins/react-component-properties-plugin/index.ts
Show resolved
Hide resolved
flow-server/src/main/resources/plugins/react-component-properties-plugin/index.ts
Outdated
Show resolved
Hide resolved
This reverts commit 9acfbca.
Fixed the Vite plugin to correctly find the JSX namespace in all scenarios: - No React import (automatic JSX runtime with jsx: "react-jsx") - Default React import (import React from 'react') - Explicit JSX import (import type { JSX } from 'react') - Namespace import (import * as React from 'react') The fix uses multiple strategies to locate JSX namespace and only includes the current file in the TypeScript program for better performance and proper module resolution. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
flow-server/src/main/resources/plugins/react-component-properties-plugin/index.ts
Show resolved
Hide resolved
flow-server/src/main/resources/plugins/react-component-properties-plugin/index.ts
Show resolved
Hide resolved
Did check the performance impact of this? |
I did not see any performance impact so far but it would be better to test it with a page with many components and pages. I will create a snapshot locally and perform testing in the Hilla application to save timestamps of the transform operation |
Tried the solution that Claude suggested, and it is almost the same result. It is not possible to reuse the same ts.program with different files, as it is immutable and given files are cached. |
…plugin' into feat/react-component-properties-plugin
|
Description
The PR introduces a new Vite plugin that identifies properties of each JSX element during the transformation step, which is used by the Copilot Properties Panel in the browser.
How it works (build-time):
.tsx
module (excluding anything under/generated/
), the plugin:ResponseData
payload.How it works (runtime, via injected code):
2) Adds a global registry under
window.Vaadin.copilot.ReactProperties
:properties: Record<string, ResponseData>
– in-memory map of tagName → ResponseData.registerer(tagName: string, value: ResponseData)
– helper to populateproperties
.For non-intrinsic elements (custom React components), the plugin tries to attach
the payload directly to the component function/object on
__debugProperties
(mimicking a "Fiber-adjacent" location) for quick introspection:
MyComponent.__debugProperties = { error: false, properties: [...] }
If that attachment isn’t possible (e.g.,
MyComponent
isn't resolvable as a value),it falls back to
registerer("MyComponent", payload)
.For intrinsic elements (e.g., 'div', 'button'), the plugin always registers to the
global registry via
registerer("div", payload)
.https://github.com/vaadin/copilot-internal/pull/6576 is the inline version of both client and plugin implementation.
Type of change
Checklist
Additional for
Feature
type of change