Garmingo / framework-js-server

TypeScript version of Framework library (server version)
https://garmingo.com
Other
0 stars 2 forks source link

Exports fails #2

Open antonstjernquist opened 8 months ago

antonstjernquist commented 8 months ago

Export for core objects fails.

[ script:x]     at new Framework2 (@template_app/dist/server.js:28237:51)
[ script:x]     at @template_app/dist/server.js:32376:17
[    c-scripting-core] Failed to load script dist/server.js.

Here: this.framework = exports["qb-core"]["GetCoreObject"]();

I think you need to save exports in some variable first, something like:

const exps = global.exports;
this.framework = exps["qb-core"]["GetCoreObject"]();
TheRealFloatDev commented 8 months ago

That is interesting. In our tests it worked perfectly fine, but I will have a look at it. Do you happen to know if your version with saving it in a variable first is working?

antonstjernquist commented 8 months ago

That is interesting. In our tests it worked perfectly fine, but I will have a look at it. Do you happen to know if your version with saving it in a variable first is working?

Yepp! This seems to solve the issue for me 👍

Unsure if only happens when you bundle the output. I'm using Typescript and I believe the bundled version is "scoped", meaning I can only access the exports via the global scope.

Just "global.exports" solves it as well

TheRealFloatDev commented 8 months ago

Bundling might be the issue, depending on the used bundler. I will do some testing and maybe the little extra step of saving it in a variable can solve the issue for most bundlers.