Modules and TypeScript in plain V8 embedding Project

309 views
Skip to first unread message

d.wiel...@gmail.com

unread,
Sep 15, 2016, 11:55:27 AM9/15/16
to v8-users
Hello,

I try to embed V8 into a C/C++ program. I want to use TypeScript but I'm not shure if it is possible to do so in bare V8. I know it is possible in Node.js but I'm not sure if it is possible for V8 only.
I also want to use "require" or "import" or the like to create modules and use them at runtime. Everything that I found seems to require a browser or Node.js (Common.js, Require.js, ...). Also TypeScript wants to translate its modules into one of those standard APIs.
It does not seem easy to implement a correct self-made module system.

Can anybody point me in the right direction? Is it is possible to use TypeScript and modules in bare V8 in an embedding scenario? And if it is, are there any resources where I can find further information?

Any help is appreciated.

Jochen Eisinger

unread,
Sep 16, 2016, 1:12:19 AM9/16/16
to v8-users
V8 itself doesn't support typescript, you'll have to compile your sources to javascript first. We're currently working on native module support, but that's not yet ready for use, so if you want modules, you will need to implement a module loader yourself (as e.g. node.js does)

--
--
v8-users mailing list
v8-u...@googlegroups.com
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups "v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

d.wiel...@gmail.com

unread,
Sep 16, 2016, 1:30:05 AM9/16/16
to v8-users
I know that V8 doesn't support typescript. My question is, is it possible to use typescript and compile it to javascript that V8 does understand. I mean if I use typescript and for example modules in typescript and typescript translates them to common.js syntax then V8 cannot execute this. Are there any other features of typescript that translate to javascript that cannot be executed from V8 apart from modules?

Is there any information that helps to implement a module loader? My impression when reading about module loaders is that it is not very easy to do it right regarding scoping and the like. If I use typescript and compile it to common.js syntax then I have to implement the callback functions so that my implementation behaves exactly like node.js. Is this assumption correct? Or do I overestimate the complexity of a module loader?

Ben Noordhuis

unread,
Sep 16, 2016, 3:24:47 AM9/16/16
to v8-users
On Fri, Sep 16, 2016 at 7:30 AM, <d.wiel...@gmail.com> wrote:
> I know that V8 doesn't support typescript. My question is, is it possible to
> use typescript and compile it to javascript that V8 does understand. I mean
> if I use typescript and for example modules in typescript and typescript
> translates them to common.js syntax then V8 cannot execute this. Are there
> any other features of typescript that translate to javascript that cannot be
> executed from V8 apart from modules?

That seems like a question for the TypeScript project, not v8-users.

> Is there any information that helps to implement a module loader? My
> impression when reading about module loaders is that it is not very easy to
> do it right regarding scoping and the like. If I use typescript and compile
> it to common.js syntax then I have to implement the callback functions so
> that my implementation behaves exactly like node.js. Is this assumption
> correct? Or do I overestimate the complexity of a module loader?

This too is a question you probably won't find an answer for here.
Perhaps try nodejs@?
Reply all
Reply to author
Forward
0 new messages