Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

333
Views
Injecting code when debugging JS from VS Code

VS Code has rather good support for running and debugging JavaScript.

The JavaScript I'd like to debug this way normally runs on Jint which is a JS interpreter written entirely in C#. Some of Jint's virtues for this application include portability, fine-grained throttling of hosted JS and the ability to inject objects from the dotnet host process, something that I have exploited to implement sandboxing - there's no direct file access, instead an injected WorkingFolder object provides access to any file in a predetermined working folder. An arbitrary parameter graph is also injected, in the form of a JSON string.

The JS code is dependent on these injected objects.

If I run this code using node, faking injected strings and objects could be done by injecting some JS at the start. I could hide all this behind a single require but I'd like to make it completely transparent. I suppose you could think of it as dependency injection into the global namespace.

The question then is how one might go about this.

I have considered coming at it from the other direction and building a Jint host. That would easily resolve the injection problem, but then I'd have to implement all the debugger support. Jint does have debugging support but I corresponded with the developer and it's not ready for prime-time.

I could hijack the launch process and prepend some code, maybe create a new file with the requisite JS prepended and launch that. Or maybe this is something that node (or even VS Code) supports. I wouldn't know, that's why I'm asking whether anyone has done something like this with this toolchain.

Conceptually this could be seen as parallel to running TypeScript. Source in one end, transformation occurs, JS comes out the other end and then it's launched with a map back to the source so that breakpoints can work in in the original source.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!