Skip to content

Create Devtools package and its Roblox plugin - #14

Draft
jeparlefrancais wants to merge 6 commits into
jsdotlua:mainfrom
jeparlefrancais:what-changed
Draft

Create Devtools package and its Roblox plugin#14
jeparlefrancais wants to merge 6 commits into
jsdotlua:mainfrom
jeparlefrancais:what-changed

Conversation

@jeparlefrancais

@jeparlefrancaisjeparlefrancais commented Sep 15, 2023

Copy link
Copy Markdown
Collaborator

This PR sets up a Roblox plugin that re-implements the React developer extension

We cannot use the existing extensions (like the chrome or firefox extensions) because Roblox does not have a socket API, so it cannot communicate with them. That is why I built this plugin.

The goal was to get the profiler working, so the "components" tab is not implemented.

Notes

  • this is a very experimental plugin
  • the flamegraph view does not translate super well into Roblox, so I've made an attempt at something that looks alright
  • so far, I tested this on a minuscule React tree, I have not idea what it looks like on some real React project. I expect the flamegraph to look particularly funny
  • to view the changes in a commit, open the settings and hit the button to enable changes recording, it is disabled by default
  • settings are not saved (annoying a little because if you want commit changes you have to enable them all the time) but they could definitely be
  • the plugin only works in Run mode, so it will show up after you press the 'Play' button. It could be made to also work in edit mode, it will just need a different setup (and proper reloading capability)

How to test it out

You will need the plugin and a few modification in your code before you render your root.

Build the plugin

rojo build packages/roblox-devtools-plugin -o react-lua-devtools.rbxm

Roblox setup

Here is an example of how to setup the devtools inside Roblox:

-- make sure to set the `__PROFILE__` global to true_G.__PROFILE__=true_G.__DEV__=truelocalPackages=...-- require the ReactDevtools packagelocal_ReactDevTools=require(Packages.ReactDevtools)
localReact=require(Packages.React)
localReactRoblox=require(Packages.ReactRoblox)
-- I have not fully figured out how to make sure everything is properly wired so that -- the devtools are properly hooked up because rendering, so it appears that some -- kind of delay is needed for the extension to properly worktask.wait(1)
localcontainer=Instance.new("Folder")
container.Name="ReactContainer"container.Parent=script.Parent.Parent.PlayerGuilocalroot=ReactRoblox.createRoot(container)
-- render your component here!root:render(React.createElement(YourComponent))

Screenshot of the extension

image

@matthargettmatthargett left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Minor comments. Great work!

Comment threadpackages/react-devtools-core/wally.toml Outdated
@jeparlefrancaisjeparlefrancais changed the title Translate WhatChanged component and its dependenciesCreate Devtools package and its Roblox pluginSep 22, 2023
return
end

if runModes.edit then

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Not good, I essentially make my entire game in Hoarcekat--I need it there!

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

Yep! For now I want to disable it to prevent any confusion about the plugin not working in edit mode.

It's definitely possible to make it work though, the plugin would just need to make sure to re-connect and clean up the connections correctly.

Sign up for freeto 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.

3 participants

@jeparlefrancais@matthargett@Kampfkarren