Open fabiospampinato opened 1 year ago
I'm importing the following:
https://cdn.skypack.dev/voby
Which highlights that the transform that SkyPack is using for transpiling optional chaining is broken. I have the following source code:
const IS_BROWSER = !!globalThis.CDATASection?.toString?.().match ( /^\s*function\s+CDATASection\s*\(\s*\)\s*\{\s*\[native code\]\s*\}\s*$/ );
But it gets transpiled to this:
var a, b; const IS_BROWSER = !!((_b = (_a = globalThis.CDATASection) == null ? void 0 : _a.toString) == null ? void 0 : _b().match(/^\s*function\s+CDATASection\s*\(\s*\)\s*\{\s*\[native code\]\s*\}\s*$/));
Which seems correct at first look, but it isn't, because when _b() is called the this of the function call is undefined, while in the original code that this would have been globalThis.CDATASection itself, i.e. the thing to stringify.
_b()
this
undefined
globalThis.CDATASection
I'm importing the following:
Which highlights that the transform that SkyPack is using for transpiling optional chaining is broken. I have the following source code:
But it gets transpiled to this:
Which seems correct at first look, but it isn't, because when
_b()
is called thethis
of the function call isundefined
, while in the original code thatthis
would have beenglobalThis.CDATASection
itself, i.e. the thing to stringify.