Closed DigitalWolf98 closed 1 month ago
Hi. Please provide minimal resource to reproduce the issue. And did you check is static import works for you?
Hello.
Yes, I checked if the static imports works, unfortunately it also gives an error:
SyntaxError: Cannot use import statement outside a module.
Here's the basic resource I used: https://mega.nz/file/aQITmQjZ#9gB0cPrdFOW3oBsh91rcF_FLZ9NFZLTaAGTtGwSkrb0
Can anyone answer or should I close this problem by marking it as unsolved ?!
Can anyone answer or should I close this problem by marking it as unsolved ?!
Current JS runtimes implementation doesn't support ESM on server and client.
What happened?
I wanted to rewrite the localization system from
Lua
language toJS
. In this system I should have many files with a prularization function for each locale. In the EcmaScript standard, it is possible to dynamically import the necessary modules. When attempting to use the entryconst _module = import('module.js');
an errorTypeError: Invalid host defined options.
is thrown.On one of the forums, I saw an entry where a user mentioned the need to disable
v8-compile-cache
. Here is his verbatim quote:I don't know if this is the case and how to do it since I have no experience with it, please help me fix it.
Expected result
Dynamic import and module execution (ES).
Reproduction steps
package.json
file withtype=“module”
to support imports.server/main.js
:server/module_*.js
:Importancy
There's a workaround
Area(s)
FiveM, FXServer, ScRT: JS
Specific version(s)
FiveM, tx: v7.2.2, fx: b8981, Windows/master
Additional information
There is a workaround using the native
LoadResourceFile()
function and usingeval()
, but as we all know the eval function is not recommended for a number of reasons.Code example
server/main.js
: