tslab depends on a branched version of TypeScript (@tslab/typescript-for-tslab
) to use unexported APIs of TypeScript compiler.
See README of the branched version for details of modifications.
At the same time, tslab also dev-depends on the mainline TypeScript to compile src code and run tests with ts-jest
.
Also, tslab
has @types/node
as dependencies
, not devDependencies
. This is intentional to fix #10.
To share variables among code cells, tslab
converts references to variables defined in previous cells (e.g. x + y
) to references to properties of exports
(e.g. exports.x + exports.y
) before running code in vm.runInThisContext
.
getCustomTransformers
insrc/converter.ts
vm.runInThisContext
insrc/executor.ts
Previously, tslab
used vm.runInContext
with a customized context which hooks accesses to variables defined in previous cells.
But tslab
switched to the current approach with vm.runInThisContext
to avoid problems like #32.
exports
is defined as aProxy
- It forwards assigned variables to
locals
to share exported variables among cells. - We don't expose
locals
asexports
directly because irreversible operations (e.g.Object.defineProperty(exports, "__esModule", { value: true });
) can be applied toexports
but we don't want to share the results of irreversible operations among cells.
tslab install
registers tslab
command to Jupyter environment.
This behavior requires users to install tslab
in a directory in PATH
environment variable.
Initially, tslab install
registered the absolute path of bin/tslab
to Jupyter.
But I simplified it to support Windows (commit).