Unreadable logs printed to .swc
ItamarMalka opened this issue · 11 comments
When the plugin has any errors with transforming it logs an unreadable file (AFAIK, I tried reading it with all sort of stuff)...
attached an example log I had thrown when trying to use the plugin for moving a fe project from ts-jest -> swc
and when trying to update swc-core 1.2.224 -> 1.2.232 (maybe something got broken there but can't be sure because I can't read the logs there...)
example_log.zip
Purposed Solution:
- Have an option to mute those logs
- Find out how to make them readable
Not sure if this is related to strip = "debuginfo"
.
Could you try this?
jest_workaround.tar.gz
Or you can remove this line and compile it yourself.
https://github.com/magic-akari/jest_workaround/blob/baa177682215f5aa99b1921a8fde95ad50e674ed/Cargo.toml#L39
Looking into it rn, regarding what I wrote with the swc upgrade (1.2.224 -> 1.2.232), did you happen to notice anything?
didn't see anything in the release notes that looks like a breaking change
Update:
couldn't get cargo to build it (got alot of '...' not found in this scope maybe I got the wrong rust version? also not familiar with rust so maybe I didn't setup the project properly)
and when overwriting with the compiled wasm in node_modules the logs are still printed for me
Hey, after updating to the 1.2.239 core version & 0.1.7 workaround version I found a different issue popping up for me, not sure if I should log this into a different issue or not...
I might be way off with the drill down here but what I saw is
when transforming a enum export e.g
export enum SomeEnum {
A = 'A',
B = 'B'
}
output from swc transform: playground link
output with the plugin:
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "SomeEnum", {
enumerable: true,
get: ()=>SomeEnum,
configurable: true
});
var SomeEnum;
(function(SomeEnum) {
exports.SomeEnum["A"] = "A";
exports.SomeEnum["B"] = "B";
})(exports.SomeEnum || (exports.SomeEnum = {}));
which fails out with Cannot set property SomeEnum of [object Object] which has only a getter
Hey, after updating to the 1.2.239 core version & 0.1.7 workaround version I found a different issue popping up for me, not sure if I should log this into a different issue or not... when transforming a enum export e.g
export enum SomeEnum { A = 'A', B = 'B' }
output from swc transform: playground link output with the plugin:
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "SomeEnum", { enumerable: true, get: ()=>SomeEnum, configurable: true }); var SomeEnum; (function(SomeEnum) { exports.SomeEnum["A"] = "A"; exports.SomeEnum["B"] = "B"; })(exports.SomeEnum || (exports.SomeEnum = {}));
which fails out with
Cannot set property SomeEnum of [object Object] which has only a getter
- check #7
Allowing the exported variable to be mutable internally and externally is difficult.
oh so this pr should solve it right? since it will drop those 'exports.' am I right?
oh so this pr should solve it right? since it will drop those 'exports.' am I right?
Yes, but I don't know if there are any other unfixed issues.
When an exported variable changes externally, the internal callee points to the new reference. We do this by prefixing the callee with exports.
.
But exported variables can still be changed internally.
Changing exported variables internally and externally can result in inconsistent references.
I don't know what the expected behaviour is.
@ItamarMalka Does the original issue still exist?
If the TS enum remains unsolved, we should discuss it in a new issue.
@magic-akari The change removing the 'exports.' did fix the TS enum issue for me so it works fine now,
regarding the original issue I still can not read the logs that are printed from the plugin...
Hey @magic-akari did you see anything new regarding this?
(it's just that every now and then when a swc/core version increases the plugin fails to transform the code and we don't know the reason for it...)
Hey @magic-akari did you see anything new regarding this?
(it's just that every now and then when a swc/core version increases the plugin fails to transform the code and we don't know the reason for it...)
This is a breaking change from SWC AST.
I have nothing better to do than to upgrade and release a new version.
No luck, Upgrading to the latest dependencies did not fix it.
I will follow the version of swc_core
. Compatibility can be found in this link https://swc.rs/docs/plugin/selecting-swc-core