Closed deathbeam closed 3 years ago
Oh, you are trying to transpile RuneLite, that's cool :)
Do you have any error during transpilation? There are multiple unit test cases on enums with and without modules so I would be suprised if this is actually broken. Maybe you hit a side case. Anyway we will try to fix it together. It could be great if you could narrow down to a minimal repro, and I will take a look asap. Btw 3.0.0-RC8 is out :)
Thanks for reporting
Well im not transpiling RuneLite, just subset of it for RL website for time tracking. I don't see any errors when building the project, but here is the output anyway:
I tried with 3.0.0-RC8 and the issue persists.
I set up minimal repro case here: https://github.com/deathbeam/runelite-web-base/tree/min-repro/src/main/java/timetracking
So it looks like if the enum isnt referenced directly, the import isnt inferred (see VarbitCallerNotWorking and VarbitCallerWorking classes).
Here is VarbitCallerNotWorking.js:
// @ts-nocheck
/* eslint-disable */
export class VarbitCallerNotWorking {
static getVarbitId(varbitWrapper) {
return Varbits["_$wrappers"][varbitWrapper.getVarbit()].getId();
}
}
VarbitCallerNotWorking["__class"] = "timetracking.VarbitCallerNotWorking";
and here VarbitCallerWorking.js:
// @ts-nocheck
/* eslint-disable */
export class VarbitCallerWorking {
static getVarbitId(varbitWrapper) {
const varbit = varbitWrapper.getVarbit();
return Varbits["_$wrappers"][varbit].getId();
}
}
VarbitCallerWorking["__class"] = "timetracking.VarbitCallerWorking";
import { Varbits } from './Varbits';
EDIT: And even in the working example, the imports are still at bottom
We will fix it. Thanks
@deathbeam Could you please try on 3.0.0-RC11 This bug should be fixed on it
@lgrignon Yea, now it is working, thanks (and the enum import is at top while rest is at bottom but i guess that is unrelated to this issue).
So I was using JSweet 3.0.0-RC3 but it dissapeared so I had to upgrade. But when I tried to upgrade to latest version, the imports for enums in generated JavaScript code were missing.
Here is repository I am trying to generate code from: https://github.com/deathbeam/runelite-web-base/tree/not-working
Example of not working generated code:
As you can see, there i no import for Varbits (and alos for some reason imports are at bottom. Here is same class but with RC3:
And here is the source java code: