Skip to content

Technical Details

Don Jayamanne edited this page Aug 12, 2021 · 2 revisions
  • Node REPL is used to run code
  • Result of the nodejs REPL is the output in the cell.
  • acorn is used to convert all const let into var
  • acorn is used to convert the top level awaits and wrap with IIFE (just as node.js runtime does) This extension has the same code from nodejs (slightly modified, to retain the source maps) This extension has the same tests from nodejs
  • acorn is used to hoist functions/classes. This is something the nodejs REPL does not support (a fix has been submitted upstream)
  • TypeScript compiler is used to convert typescript into JS code
  • TypeScript compiler is used to convert JavaScript into JavaScript that can be run in Nodejs (e.g. if ES style imports are used in javascript, that will be converted into commonjs imports)
  • tslib is injected into the REPL global context tslib helpers are not included in the output JS generated as part of the typescript compilation
  • TypeScript compiler has some hardcoded configuration items (plan is to allow users to provide their own)
  • The node.js REPL runs in a separate process, and communication happens over websockets.
  • Output from the node.js REPL goes into the process output streams (e.g. running code console.log(...), in the REPL will send output to the process, this output is captured by the extension that spanws the node REPL process.
  • Imports are analyzed and converted into commonjs require statements (even if typescript generates its own). This is required to preserve the name provided by the user, e.g. import * as fs from 'fs', we need to ensure the variable fs exists for subsequent cells.

Home

Clone this wiki locally