Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

Create Devtools package and its Roblox plugin#14

Draft
jeparlefrancais wants to merge 6 commits intojsdotlua:main from
jeparlefrancais:what-changed
Draft

Create Devtools package and its Roblox plugin #14
jeparlefrancais wants to merge 6 commits intojsdotlua:main from
jeparlefrancais:what-changed

Conversation

@jeparlefrancais
Copy link
Collaborator

@jeparlefrancais jeparlefrancais commented Sep 15, 2023
edited
Loading

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__ = true
local Packages = ...
-- require the ReactDevtools package
local _ReactDevTools = require(Packages.ReactDevtools)
local React = require(Packages.React)
local ReactRoblox = 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 work
task.wait(1)
local container = Instance.new("Folder")
container.Name = "ReactContainer"
container.Parent = script.Parent.Parent.PlayerGui
local root = ReactRoblox.createRoot(container)
-- render your component here!
root:render(React.createElement(YourComponent))

Screenshot of the extension

image

OverHash reacted with thumbs up emoji matthargett reacted with hooray emoji matthargett, Kampfkarren, grilme99, filiptibell, and alexitosex reacted with rocket emoji
Copy link
Collaborator

@matthargett matthargett left a comment

Choose a reason for hiding this comment

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

Minor comments. Great work!

@jeparlefrancais jeparlefrancais changed the title (削除) Translate WhatChanged component and its dependencies (削除ここまで) (追記) Create Devtools package and its Roblox plugin (追記ここまで) Sep 22, 2023
return
end

if runModes.edit then
Copy link

@Kampfkarren Kampfkarren Sep 22, 2023

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
Collaborator Author

@jeparlefrancais jeparlefrancais Sep 23, 2023

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 free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@matthargett matthargett matthargett left review comments

+1 more reviewer

@Kampfkarren Kampfkarren Kampfkarren left review comments

Reviewers whose approvals may not affect merge requirements

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /