K/JS docs says that a `Char` is mapped to a JS `Nu...
# javascript
e
K/JS docs says that a
Char
is mapped to a JS
Number
> The number represents the character's code. An expression like
Copy code
if (Char.MAX_HIGH_SURROGATE < Char.MAX_LOW_SURROGATE) {
  println("Yes")
}
Will generate
Copy code
Companion_getInstance();
var tmp = _Char___init__impl__6a9atx(56319);
Companion_getInstance();
if (Char__compareTo_impl_ypi4mb(tmp, _Char___init__impl__6a9atx(57343)) < 0) {
  println('Yes');
}
I wonder if the compiler can be improved to inline the two numbers. This is relevant since when we use the characters directly
Copy code
if ('\uDBFF' < '\uDC00') {
  println("Yes")
}
We get the JS
Copy code
println('Yes');
j
This is how value types look. Did you try a minified build? Usually they disappear
e
Well, in case of a Node.js library, builds don't pass by a minifier/bundler, so I'd have to set up an additional step myself, which is something I'd like to have set up by the Kotlin's tooling at some point, not by me.
The char const val could simply be inlined, so to get the second result, much like what happens with other primitive types
t
I'd like to have set up by the Kotlin's tooling at some point, not by me.
1. Do you have additional dependencies? a. Do you need bundle with dependencies inside? 2. Which module kind do you use?
e
1. Yes / I'd like to bundle in a single package (taking into account the granularity option) 2. CommonJS and ESM
There is an issue for webpack support in Node https://youtrack.jetbrains.com/issue/KT-35620 I had come across it last year and tried to emulate it with the
browser
target, but IIRC there were other issues.