Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any APIs related to V8::ScriptCompiler? #130

Closed
levimm opened this issue Sep 6, 2017 · 6 comments
Closed

Any APIs related to V8::ScriptCompiler? #130

levimm opened this issue Sep 6, 2017 · 6 comments

Comments

@levimm
Copy link

levimm commented Sep 6, 2017

I'm trying to migrate an old addon using Nan to Napi.

In Nan, there's API called Nan::CompileScript which will invoke v8::ScriptCompiler::Compile to compile the source javascript code. But I couldn't find any related to compile script in Napi.

I guess I have to use both v8 part code and Napi part in the addon. However, I don't know how to convert v8::Value type to Napi::Value.

Please advice.

@gabrielschulhof
Copy link
Contributor

@nodejs/addon-api looks like we might need to implement nodejs/abi-stable-node#51

@gabrielschulhof
Copy link
Contributor

@levimm would a C++ wrapper around the API proposed in nodejs/abi-stable-node#51 help you out?

@gabrielschulhof
Copy link
Contributor

@levimm specifically, do you need support for simply executing a script, or do you need access to the intermediate step of compiling the script as well? Can you give us a link to the module you wish to port so we can have a look at your API usage pattern?

@levimm
Copy link
Author

levimm commented Sep 6, 2017

@gabrielschulhof Executing the script is enough for my situation. It's a self addon. Basically, related part of logic just compiles and runs the script.
Btw, is it possible to convert construct the Napi object or value from v8 handle?

@gabrielschulhof
Copy link
Contributor

@levimm we do not expose the details of the underlying engine. After all, you may not be running on V8 at all. For example, you may be running ChakraCore, or some other JavaScript engine.

@levimm
Copy link
Author

levimm commented Sep 7, 2017

@gabrielschulhof Thanks for your effort. Your commit helps me a lot.

@levimm levimm closed this as completed Sep 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants