Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

335
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda