eclipsesource / J2V8

Java Bindings for V8
2.55k stars 355 forks source link

const { JSDOM } = jsdom; #562

Closed Osiris-Team closed 3 years ago

Osiris-Team commented 3 years ago
D:\Coding\JAVA\Headless-Browser\browser-apis.js:3: SyntaxError: Unexpected token {

const { JSDOM } = jsdom;
      ^
SyntaxError: Unexpected token {
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:387:25)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
com.eclipsesource.v8.V8ScriptExecutionException
    at com.eclipsesource.v8.V8._executeFunction(Native Method)
    at com.eclipsesource.v8.V8.executeFunction(V8.java:1000)
    at com.eclipsesource.v8.V8Function.call(V8Function.java:80)
    at com.eclipsesource.v8.NodeJS.require(NodeJS.java:143)
    at BrowserTest.testNodeJSRequire(BrowserTest.java:46)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:688)
    at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
    at org.junit.jupiter.engine....

const { JSDOM } = jsdom; works in the chrome devtools console without problem. I thought the currently implemented version of the V8 engine would be able to do this too?

ahmadov commented 3 years ago

Hello @Osiris-Team,

which version of J2V8 do you use? I highly doubt it, but it's possible that the version you're using does not support that feature.

Osiris-Team commented 3 years ago

Latest available on maven

Osiris-Team commented 3 years ago

Closing because of no response

caoccao commented 3 years ago

I wonder if you mind trying Javet which is an awesome way of embedding Node.js and V8 in Java.

Osiris-Team commented 3 years ago

@caoccao dammn that wouldve been great a few days ago... Just integrated Node.js by myself into Java haha https://github.com/Osiris-Team/Headless-Browser

caoccao commented 3 years ago

@caoccao dammn that wouldve been great a few days ago... Just integrated Node.js by myself into Java haha https://github.com/Osiris-Team/Headless-Browser

I thought you tried because there are other open issues referencing Javet.

I just took a glance at your project. It looks nice. I think it could be built upon Javet. And I don't recommend GraalJS because it has so many inconsistencies with V8/Chrome/ES so that in the long term 80% of development team's time would be spent on fighting with those inconsistencies and waiting for Oracle's mercy.

Osiris-Team commented 3 years ago

@caoccao sounds like you already got some experience on that topic haha. Definitively going to check out javet.

caoccao commented 3 years ago

@caoccao sounds like you already got some experience on that topic haha. Definitively going to check out javet.

A further look, it seems the Node.js you integrate is an out-of-process one? I have to admit out-of-process Node.js is very slow, compared to the in-process one provided by Javet.

If you are interested, let's avoid using J2V8 as a chatroom. Javet lovers are at discord. I look forward to seeing you.