Code Repo Node Runtime docs?

  1. Any docs on specifics of v8 runtime and what libraries are actually available?

I noticed i’m able to import widely used NPM packages and types for valid compilation in ts code repo editor but you only find out they are unrunnable in the runtime.
Seems even basic things like jwt/crypto util libs (ie jsonwebtoken, jose, eventually found jsrsasign can be used) not compatible with current node runtime.

  1. From this post sounds like larger changes are coming for more node support?

https://community.palantir.com/t/timing-functions-in-typescript-repos-for-nodejs-such-as-settimeout-setinterval-etc/2448

In general, you cannot import Node.js APIs since Typescript functions are executed in a very basic isolated V8 runtime environment.
...
We are also looking into providing Typescript Function authors with full access to Node.js APIs as part of our roadmap this year. Stay tuned!

So yeah curious on any short term insights or just to make due till more widely available node runtime accessible. Thanks.

ps. Code Repos is freaking badass overall.

2 Likes

Hey @SerKnight ,

V8 is an implementation of the ECMAScript JavaScript language specification, for which you can find detailed documentation at tc39.es/ecma262/. This specification defines the behavior of built-in keywords like let, var and const, data structures like arrays and objects, and async-await. The current TypeScript Functions runtime is built on V8.

There is a separate set of APIs that belong to various other standards and are commonly referred to as Web APIs due to their use in browsers, but recent versions of Node.js implement support for them as well (you can find a list at developer.mozilla.org/en-US/docs/Web/API). This includes timer APIs like setTimeout, the fetch standard, and ReadableStream. While TypeScript Functions support a number of these, you will need to import and use polyfills for ones that are missing, like TextEncoder.

Additionally, there are runtime APIs that might only exist in a browser runtime, or only exist in a server-side runtime like Node.js. For example, the fs Node.js module is not available in Chrome, but there are libraries like memfs that provide a virtual filesystem for browsers.

We are currently working on a new back-end that will allow TypeScript Functions to be executed in a full Node.js runtime, so hopefully you won’t need to think too hard about what APIs exist!

Great thank you T - very helpful for validating if a library can be used before going to deep down implementation.

My plan now is to use compute modules but will definitely be keeping eyes out for full npm compatibility for ts code repos!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.