Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

330
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda