I am curious how Javet handles import/export keywords in javascript. #4
-
Hello. First of all, I must say thanks for maintaining this project. I'm planning to make a small game app which supports modding capability by javascript and reached to this project today. What I wonder is, how Javet handles import statements with relative paths. How can I inject absolute execution path into Javet before running it via methods like Thanks for reading in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 10 replies
-
Thank you for raising this good question. I haven't tested that behavior, so V8 decides what to do for now. Here are 3 general directions I'm thinking of.
Regarding (1) + (2), I think you may leverage custom class / resource loader to achieve your goal. Yes, that implies a bit of work. Regarding (3), I think in the future you just need to tell Javet where to locate the JS entry file along with Hope that gives you some ideas. And your input may impact Javet in the future. Thank you. |
Beta Was this translation helpful? Give feedback.
-
I just analyzed V8 + Node source code and found dynamic import is not supported by default, unless certain amount of C++ work backing V8 up. I think it might not be worthy of supporting dynamic import in Javet because once Node was embedded, that would be resolved. |
Beta Was this translation helpful? Give feedback.
-
Stay tuned. NodeJS integration is on the way. |
Beta Was this translation helpful? Give feedback.
-
Finally, Javet supports latest Node.js LTS. The short answer is: Yes, you can get identical behavior that Node.js has in Javet. The detailed answer you are looking for is at this link. |
Beta Was this translation helpful? Give feedback.
-
I've been asked quite a few times on how long I spent embedding Node.js. Well, it took almost 3 weeks to unlock Node.js v14.16.0 for Linux and Windows. I started from the Windows one and it was quite hard. After settling down the Windows version, I jumped into the Linux one. It was a journey full of desperation that would almost kill this project. Finally, I made it. That may partially explain why I don't intend to support MacOS / Android by myself. Any volunteers? |
Beta Was this translation helpful? Give feedback.
-
Thanks for your devotion |
Beta Was this translation helpful? Give feedback.
-
Doing testing with Javet es6 modules, it works with the exception of relative paths.
I really would prefer to use native ES6 with relative imports in the newer V8 without the node version (unless I have to). |
Beta Was this translation helpful? Give feedback.
Finally, Javet supports latest Node.js LTS. The short answer is: Yes, you can get identical behavior that Node.js has in Javet.
The detailed answer you are looking for is at this link.