Skip to content
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

feat: add RN experimental debugger compatibility #508

Merged
merged 15 commits into from
May 6, 2024

Conversation

RafikiTiki
Copy link
Member

@RafikiTiki RafikiTiki commented Feb 23, 2024

TODO

  • Verify if the Flipper debugging experience is working properly – if not – create an issue and address it later
  • Consider reverting DevtoolsPlugin removal – it might be needed for the deprecated Remote JS debugging. We need this to work before it's removed from the RN core

Summary

This PR introduces compatibility with the new Experimental Debugger to the Repack devserver.

Experimental Debugger info:

To test this feature the dev server has to be started with the --experimental-debugger flag. To play with it using TesterApp simply run yarn TesterApp:start --experimental-debugger from the root of the repo.

image

Additional benefits

This PR also made it possible to remove a custom implementation of the Hermes Inspector Proxy and reuse what @react-native/dev-middleware provides – less code to maintain and less breaking changes in the future 🤞

Next steps

In the future, we'll likely remove the Remote JS debugger and the whole debugger-app package – this will, of course, be a breaking change and we want to wait till it gets removed from the RN core itself.

@RafikiTiki RafikiTiki added the status:wip The issue is being worked on. label Feb 23, 2024
Copy link

changeset-bot bot commented Feb 23, 2024

🦋 Changeset detected

Latest commit: 8bbd016

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@callstack/repack-dev-server Major
@callstack/repack Major
@callstack/repack-init Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

This pull request has been marked as stale because it has been inactive for 60 days. Please update this pull request or it will be automatically closed in 14 days.

@github-actions github-actions bot added the Stale label Mar 31, 2024
@RafikiTiki RafikiTiki force-pushed the feat/experimental-debugger-compatibility branch from c776d12 to d7bb6ae Compare April 2, 2024 17:22
@github-actions github-actions bot removed the Stale label Apr 3, 2024
@RafikiTiki RafikiTiki force-pushed the feat/experimental-debugger-compatibility branch from d7bb6ae to f03e338 Compare April 3, 2024 07:51
@jbroma
Copy link
Member

jbroma commented Apr 3, 2024

  • Added eslint-disable directive fro @react-native/dev-middleware because there is no main field declared there. (description of the problem)
  • Added TS path override for @react-native/dev-middleware because we use moduleResolution: 'node' which doesn't read package exports, and changing this is out of scope of this PR

@RafikiTiki RafikiTiki force-pushed the feat/experimental-debugger-compatibility branch 2 times, most recently from c420455 to 101c661 Compare April 4, 2024 13:41
@jbroma
Copy link
Member

jbroma commented Apr 4, 2024

@szymonrybczak should we use @react-native/dev-middleware as a peer dependency in our dev-server? I think it makes sense because it's always included with react-native as part of @react-native/community-cli-plugin, would love to hear your point of view

@thymikee
Copy link
Member

thymikee commented Apr 4, 2024

Using it as a peer dependency would make it auto-install as a dep when using npm, right? Can we treat it as an optional dependency that we require and throw error saying that it's supposed to be there, so most likely make sure you've installed the deps?

@thymikee
Copy link
Member

thymikee commented Apr 4, 2024

FYI, in 0.75 the template will have the dependency on @react-native-communit/cli, but likely not directly on the @react-native/community-cli-plugin: react-native-community/template#7

@jbroma
Copy link
Member

jbroma commented Apr 4, 2024

Using it as a peer dependency would make it auto-install as a dep when using npm, right?

that might be the case, let's mark it as optional inside of peerDependenciesMeta then I guess?

Can we treat it as an optional dependency that we require and throw error saying that it's supposed to be there, so most likely make sure you've installed the deps?

We could make it optional and just skip integrating that part with debugger altogether. On the other hand, I'm not sure we need the error handling here since dev-server doesn't make much sense outside of react-native context so it should be safe to assume react-native is there. I would love to hear others opinion on this though.

FYI, in 0.75 the template will have the dependency on @react-native-communit/cli, but likely not directly on the @react-native/community-cli-plugin: react-native-community/template#7

I don't see anything there (or related PR) regarding @react-native/community-cli-plugin, but if that happens then I guess we could just align to that in the future.

Base automatically changed from v4 to main April 5, 2024 14:18
@jbroma jbroma force-pushed the feat/experimental-debugger-compatibility branch from 4dbb06a to 8223ea0 Compare April 15, 2024 17:31
packages/repack/src/commands/start.ts Outdated Show resolved Hide resolved
Copy link

vercel bot commented Apr 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
repack-website ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 6, 2024 4:30pm

@RafikiTiki RafikiTiki force-pushed the feat/experimental-debugger-compatibility branch from 9b98075 to 98c9925 Compare May 6, 2024 13:08
@RafikiTiki
Copy link
Member Author

Deprecated Remote Debugging #578 update – I reverted removal of part of the devtoolsPlugin.ts and used a few middlewares from @react-native-community/cli-server-api & replaced vendored code for the debugger-ui with @react-native-community/cli-debugger-ui. This enabled me to completely remove the packages/debugger-app.

Additionally, I left a TODO comment to remove the internal code/dependencies related to the deprecated remote debugging once it is removed from the React Native core itself.

@thymikee @jbroma, this should be good to be re-reviewed. The last thing to consider is the status of the added dependencies:

"@react-native-community/cli-debugger-ui": "^13.6.6",
"@react-native-community/cli-server-api": "^13.6.6",
"@react-native/dev-middleware": "^0.73.8",

As mentioned above, the first two will be removed in the future, while @react-native/dev-middleware will continue to be used. I've seen the discussion earlier about moving them to the peerDeps. Since debugging is essential to the development experience, it should be provided by repack. Previously we had all of the code implemented internally – I think leaving them as regular dependencies will be a better dev experience rather than marking them optional and providing runtime checks/errors in case they're not installed.

@jbroma
Copy link
Member

jbroma commented May 6, 2024

Great works so far @RafikiTiki 🎉 Thanks for keeping the old debugger ❤️

As for the deps:

  • I would keep CLI deps as peer deps (since they are all direct deps of CLI which is a direct dep of react-native)
  • Keep @react-native/dev-middleware as a direct dependency since it's supported from 0.73 onwards, and we need to still support 0.72 and 0.71 - later on we can switch to peer dep setup like above 👍

cc @thymikee

Copy link
Member

@jbroma jbroma left a comment

Choose a reason for hiding this comment

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

few nits

packages/TesterApp/src/App.tsx Outdated Show resolved Hide resolved
packages/dev-server/README.md Show resolved Hide resolved
@RafikiTiki RafikiTiki linked an issue May 6, 2024 that may be closed by this pull request
Copy link
Member

@jbroma jbroma left a comment

Choose a reason for hiding this comment

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

1 nit, other than that LGTM 🎉

packages/dev-server/src/createServer.ts Outdated Show resolved Hide resolved
Copy link
Member

@jbroma jbroma left a comment

Choose a reason for hiding this comment

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

Missing changeset

Copy link
Member

@jbroma jbroma left a comment

Choose a reason for hiding this comment

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

LGTM 🎉

@jbroma jbroma merged commit fec8962 into main May 6, 2024
5 checks passed
@jbroma jbroma deleted the feat/experimental-debugger-compatibility branch May 6, 2024 17:20
@jbroma jbroma removed the status:wip The issue is being worked on. label May 6, 2024
Sign up for free to 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.

Vendored Device class is broken when it comes to debugging
3 participants