feat: expose wrapped (Fast) React components#300
Conversation
|
cc @hawkticehurst ! I wasn't able to add you as a reviewer |
hawkticehurst
left a comment
There was a problem hiding this comment.
Finally had a free moment to take a closer pass on this PR and it's looking great!
Left a couple of comments asking for changes and some minor nits when you're back in the office, but super excited with the progress! Thank you again for the help.
|
@hawkticehurst All feedback addressed! I've tested that the build works locally, though I'm confused about one thing. I've been testing locally with a tool called
(You'll recall that in this new world, we have to publish from within the dist directory otherwise we won't get the subdirectory imports. I wish there was a better way of doing this 🤔 ) Unfortunately the latter Any thoughts here? |
Hmm, it's probably just a case of removing the With that said, I could envision potentially doing something fancy with the npm |
Lol thanks for the reminder, I had forgotten about that. But yeah we can manage for now and hopefully the ability to export subdirectory type info will land sooner versus later 😪. |
hawkticehurst
left a comment
There was a problem hiding this comment.
Changes look and function great! Thank you!
While reviewing I did catch two more things that I left comments on.
|
@hawkticehurst Hi Hawk! I read through the discussions in the fast repo, and was just wondering if there's an ETA on getting the stop-gap solution merged. We're currently hoping to adopt the toolkit (in React) to try it out as early as possible. |
|
@pwang347 Hi Paul! I'd wager publishing a set of React components (i.e. this PR) is probably still two or so weeks out. However, if you're really eager and can't wait to get up and running I could decidedly have the stop-gap solution mentioned in those issue threads published first thing next week, which would unblock the ability for toolkit users to wrap the web components themselves (I would, of course, give some guidance on how to do that properly). Then once this PR lands (which will do the job of wrapping components for toolkit users) you could simply remove your wrapping code and switch to importing React components directly. Lemme know if that's something you would be interested in or if you'd rather wait for this PR. :) |
|
@hawkticehurst Sounds good! Yes, I think even with the added manual wrapping, having the stopgap solution in the meantime to unblock would be great (if it's not too much trouble for you). Appreciate the fast response, thanks! |
@pwang347 the temporary solution has been published and a quick summary/guide on the update has been posted here (decided to put it in a thread with a higher visibility conversation about the ongoing React work). Hope that helps unblock you and feel free to open GH issues with any questions or problems you run into! |
|
@hawkticehurst this is great, will give it a try today or tomorrow! thanks again! |
|
Latest changes from |
Great, let us know how it goes! |
Gave it a try, and so far everything seems to be working great (plugged it into the app, events were working and things felt good)! Only issue I ran into was microsoft/fast#5198, but was able to resolve it with the |
That's great to hear! Also wasn't aware of this issue so thanks for mentioning it/giving a heads up! |
After reading through, I realize I was actually aware of this so thank you for the reminder! |
|
And just to be super clear in case others run into this problem--you got this issue because you are using a TS version >4.3.5? |
Apologies for the late reply, yes I am using 4.4.4! |
hawkticehurst
left a comment
There was a problem hiding this comment.
Looks fantastic, left some notes/requests for final polish but I think we're basically there!
…building the React components
… over new react build dir
|
Incredible work @mattrothenberg! Thank you again for helping make this a reality! |
|
@pwang347 I'm sure you probably saw already, but in case you didn't as of You should be able to remove the file that wraps components (and uninstall the import { VSCodeButton, VSCodeDropdown } from '@vscode/webview-ui-toolkit/react';Let me know if you have any questions! |
|
@hawkticehurst @mattrothenberg This is great, thank you! |
Link to relevant issue
This pull request resolves #299
Description of changes
This PR adds the ability for users to import wrapped React components directly from a subdirectory of the
@vscode/webview-ui-toolkitpackage thusly:Specifically, this PR:
Adds a
src/react/index.tsfile which exports wrapped versions of all of the components in this libraryAdds a
tsconfig-react.jsonand (supporting NPM script) to package up the aforementioned file.Proposes a modification to our build process, such that users can import directly from the
reactsubdirectory. 🚨 Please note that this requires a significant change to the build process. 🚨Specifically, the steps are:
package.jsonfile to the/distdirectory. This stub file is a mirror image of the originalpackage.jsonwith the exception of the values in themainandtypesfields losing their/distprefix.2.
cding into the/distdirectory and running publish from within there. This ensures that the built files that end up being distributed on NPM have a flat structure (rather than a nested dist directory) 👇Old, Nested Directory structure
In this old world, the
mainfile was/dist/esm/index.js.New, Flattened Directory structure
In this new world, the
mainfile is/esm/index.js, but users can also import directly fromreact/index.js.There are likely less kludgy ways of doing this, but this seems to work 🤷 .
Finally, I'd like to follow-up this PR by building a Storybook dedicated solely to the wrapped React components. As far as I an tell, it's extremely difficult (if not impossible) to use multiple frameworks within a single Storybook instance. It is possible, however, to "compose" storybooks via the following API https://storybook.js.org/docs/react/workflows/storybook-composition. To that end, once this PR is merged and once I have the other Storybook set up, I will update the Storybook here to pull in the published React SB instance.