Git Product home page Git Product logo

Comments (10)

felipejoribeiro avatar felipejoribeiro commented on July 18, 2024 1

Hello @tomoakley , currently using nvim-dap-reactnative with Hermes, typescripts and vscode-node-debug2 without problems. Currently using the vscode debugger from this repo: [email protected]:microsoft/vscode-node-debug2.git
My configs are identical to README.md

"react": "18.1.0",
"react-native": "0.70.6",

Would love to use vscode-js-debug, as it can be installed with packer. Will look at this matter latter.

from nvim-dap-reactnative.

tomoakley avatar tomoakley commented on July 18, 2024

I've managed to get it to attach to the debugger, and hit some breakpoints. However, two issues:

  1. I have to use the debugger keyword in the TypeScript - using the DAP toggle_breakpoint method means it won't hit it
  2. Sourcemaps aren't working so while it hits each debugger I can't see the values of variables etc

Here is my config:

require('dap-vscode-js').setup({
  debugger_executable = os.getenv('HOME') .. '.local/share/nvim/mason/packages/js-debug-adapter/js-debug/src/dapDebugServer.js',
  adapters = { 'pwa-node' },
})

for _, language in ipairs({ "typescript", "javascript", "javascriptreact", "typescriptreact" }) do
  dap.configurations[language] = {
    {
      name = "React Native",
      type = "pwa-node",
      request = "attach",
      program = "${file}",
      cwd = "${workspaceFolder}",
      sourceMaps = true,
      protocol = "inspector",
      console = "integratedTerminal",
      port = 8081,
      outDir = "${workspaceFolder}/.vscode/.react",
      resolveSourceMapLocations = {"**", "!**/node_modules/!(expo)/**", "!**/debuggerWorker.js, ${workspaceFolder}/.vscode/.react/debuggerWorker.js.map"},
    },
  }
end

Also I don't get any output/response at all in the tmux window where nvim-dap-reactnative is running (apart from the "starting debugger app line" when I first run the node src/standalone.js command), and if I cancel it, it doesn't appear to have any effect on nvim-dap.

from nvim-dap-reactnative.

tomoakley avatar tomoakley commented on July 18, 2024

I've tried making some changes in the nvim-dap-reactnative code to use the createDebuggingConfigForRNHermes instead, and in my dotfiles use port = 35000 instead but I still can't get it connect :(

from nvim-dap-reactnative.

tomoakley avatar tomoakley commented on July 18, 2024

Hello @tomoakley , currently using nvim-dap-reactnative with Hermes, typescripts and vscode-node-debug2 without problems. Currently using the vscode debugger from this repo: [email protected]:microsoft/vscode-node-debug2.git My configs are identical to README.md

"react": "18.1.0",
"react-native": "0.70.6",

Would love to use vscode-js-debug, as it can be installed with packer. Will look at this matter latter.

thanks @felipejoribeiro. it's probably something in the app I work on then. will try and get it working again, and try with vscode-node-debug2 as well. will look at your dotfiles too

from nvim-dap-reactnative.

tomoakley avatar tomoakley commented on July 18, 2024

I can't seem to get the RN app to connect to the nvim-dap-reactnative websocket url. the websocket is started but then nothing comes through in the onMessage callback when I start my app. One thing to note is that the app always seems to be in debug mode - bringing up the dev menu just shows "Open Debugger" rather than "Debug JS Remotely". Pressing "Open Debugger" shows

info Opening flipper://null/Hermesdebuggerrn?device=React%20Native...

in the metro bundler logs and Flipper opens.

The app is using:

    "react": "18.1.0",
    "react-native": "0.70.6",

in package.json

any ideas?
@sultanahamer @felipejoribeiro

also - I'm running this on iOS simulator. I haven't tried with Android yet.

from nvim-dap-reactnative.

tomoakley avatar tomoakley commented on July 18, 2024

so this appears to work for Android. I open the app on the emulator, bring up the dev menu, press "Debug" and it reloads the app and stops on the white screen. I can then run continue, dapui comes up and I can see my variable scope at the breakpoints I define.

So how do I get this working on iOS? I do most of my work on the iOS simulator so it'd be great to have it there.

from nvim-dap-reactnative.

felipejoribeiro avatar felipejoribeiro commented on July 18, 2024

it's great that its working on android. It shows that the setup is alright. Here i use the debugger in the ios emulator as well without problems. After initializing the adapter, i click on the 'shake' option and i select debug in the menu and it connects.
Are you initiating the emulator with something like react-native run-ios?

from nvim-dap-reactnative.

tomoakley avatar tomoakley commented on July 18, 2024

yeah react-native run-ios. There's no "Debug" option in the iOS dev menu bought up by shake. I found this issue on the RN github: facebook/react-native#34615 (comment), he made https://github.com/gusgard/react-native-devsettings to re-add "Debug JS Remotely" on RN 70 builds. I added it in to the app I work on, selecting this option on iOS now means the app connects to the debugger and nvim-dap works. At some point I will try to investigate why 'Debug' is not there at all.

I'm not fully aware why Meta removed this option, or if there would be any consequences to adding back this option. It seems to work for now, and I've only added it in __DEV__ builds. I would guess by selecting this option it changes the JS engine back to v8 from Hermes as in old RN releases.

I also have a couple of questions about nvim-dap-reactnative (or vscode-react-native seeming as it's a port):

  • what is the difference between createDebuggingConfigForPureRN and createDebuggingConfigForRNHermes?
  • in standalone.ts it has useHermesEngine: false in the attachArgs object. How do Hermes connect to the debugger if that is false?
    I think the answers to both is to do with v8/JSC/Hermes but I don't understand enough about RN architecture to know exactly. Would be really good to understand this a bit better.

from nvim-dap-reactnative.

megalithic avatar megalithic commented on July 18, 2024

@tomoakley any updates on getting things to work? interested in creating a short demo showing off the process of running it and operating it? i know that's a big lift, but this seems to be the thing there are always posts on reddit (RIP) and other social platforms asking for help to get setup. or @felipejoribeiro too?

thanks!

from nvim-dap-reactnative.

sultanahamer avatar sultanahamer commented on July 18, 2024

@megalithic we have not tested this on iOS but similar steps should do it in general.

from nvim-dap-reactnative.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.