I am having trouble with wrangler CLI.
After I ran the command wrangler publish for my worker project,
it seems that the original code is converted
to a more primitive form of JavaScript.
My question is:
Is such a behaviour the manner in that wrangler normally works,
or well I have a problem in my compiler configuration?
I am using wrangler cli version 2.6.2.
In my home system (Windows 10), I am running npm version 9.2.0.
Actually, the command npm version told me:
>> npm version
{
npm: '9.2.0',
node: '19.3.0',
v8: '10.8.168.21-node.8',
uv: '1.44.2',
zlib: '1.2.13',
brotli: '1.0.9',
ares: '1.18.1',
modules: '111',
nghttp2: '1.51.0',
napi: '8',
llhttp: '8.1.0',
uvwasi: '0.0.13',
openssl: '3.0.7+quic',
cldr: '42.0',
icu: '72.1',
tz: '2022f',
unicode: '15.0',
ngtcp2: '0.8.1',
nghttp3: '0.7.0'
}
After running the command wrangler publish
I can see that my original code has been transformed
when published in my cloudfloare worker subdomain,
by converting it to some form of more basic or primitive JavaScript version.
For instance, all my access to private members of classes
has been converted to some form of global lambdas,
and all my private members has been converted
from the hashed form of ES2022 to an underscore-prefixed form
(#memb is converted to _memb, and so on).
To show you what is happening, I write down here the heading
of the file appearing in the “Quick Edit” online dashboard:
var __accessCheck = (obj, member, msg) => {
if (!member.has(obj))
throw TypeError("Cannot " + msg);
};
var __privateGet = (obj, member, getter) => {
__accessCheck(obj, member, "read from private field");
return getter ? getter.call(obj) : member.get(obj);
};
var __privateAdd = (obj, member, value) => {
if (member.has(obj))
throw TypeError("Cannot add the same private member more than once");
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
};
var __privateSet = (obj, member, value, setter) => {
__accessCheck(obj, member, "write to private field");
setter ? setter.call(obj, value) : member.set(obj, value);
return value;
};
var __privateMethod = (obj, member, method) => {
__accessCheck(obj, member, "access private method");
return method;
};
Besides, a lot of global “var” variables are defined there.