Anyone used KotlinJS with Firebase? It does not al...
# javascript
n
Anyone used KotlinJS with Firebase? It does not allow me to
sortBy
on
mutableList
More specifically:
children.sortBy{ it.toString() }
generates
Copy code
var sortWith = Kotlin.kotlin.collections.sortWith_nqfjgj$;
  var wrapFunction = Kotlin.wrapFunction;
  var compareBy$lambda = wrapFunction(function () {
    var compareValues = Kotlin.kotlin.comparisons.compareValues_s00gnj$;
    return function (closure$selector) {
      return function (a, b) {
        var selector = closure$selector;
        return compareValues(selector(a), selector(b));
      };
    };
  });
  var Comparator = Kotlin.kotlin.Comparator;
  function Comparator$ObjectLiteral(closure$comparison) {
    this.closure$comparison = closure$comparison;
  }
  Comparator$ObjectLiteral.prototype.compare = function (a, b) {
    return this.closure$comparison(a, b);
  };
  Comparator$ObjectLiteral.$metadata$ = {kind: Kotlin.Kind.CLASS, interfaces: [Comparator]};
and Firebase complains:
Copy code
TypeError: wrapFunction is not a function
    at /tmp/fbfn_20366LgmtP4EM7pSy/kot.js:96:26
    at Object.<anonymous> (/tmp/fbfn_20366LgmtP4EM7pSy/kot.js:167:2)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)
kotlin_version = '1.1.50'
via gradle if it matters
k
And what about
kotlin.js
library. Which version are you using?
Seems that you are using new compiler (1.1.50) with old kotlin.js
n
I think it is set to same value: compile
"org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
testCompile "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version"
k
Please, run
./gradlew dependencies
and see which version of
kotlin-stdlib-js
artifact is used
n
compile - Dependencies for source set 'main' (deprecated, use 'implementation ' instead). \--- org.jetbrains.kotlinkotlin stdlib js1.1.50 testCompile - Dependencies for source set 'test' (deprecated, use 'testImplementation ' instead). +--- org.jetbrains.kotlinkotlin stdlib js1.1.50 \--- org.jetbrains.kotlinkotlin test js1.1.50 \--- org.jetbrains.kotlinkotlin stdlib js1.1.50
k
Ok, I don't know then. If you could create a self-contained project that reproduced the problem, I could investigate it myself
n
Ok, thank you I'll try.
Ok, I think you were right that it was about standard lib. I think
require('kotlin')
simply failed due to path issues and was null. At least on empty non Firebase project it seems to fail similarly if it is not imported. I now need to figure out how to put
kotlin.js
in correct path
Thanks for help 🙂
Ok I was wrong, Kotlin lib is imported and deployed on Firebase, I can call it. Strange. Maybe the issue is just with Firebase deploy verification, not with the generated js code.