So, maybe I am asking wrong way. I want to do nod...
# javascript
f
So, maybe I am asking wrong way. I want to do node js library. Which was originaly kotlinjs. And it is bundled. This library should have some js file, package.json and index.d.ts. So I did example project.
Copy code
compileKotlin2Js {
    kotlinOptions.outputFile = "${projectDir}/build/web/output.js"
    kotlinOptions.moduleKind = "commonjs"
    kotlinOptions.sourceMap = true
}
which is like:
Copy code
(function (_, Kotlin) {
  'use strict';
  var println = Kotlin.kotlin.io.println_s8jyv4$;
  var Kind_OBJECT = Kotlin.Kind.OBJECT;
  var Kind_CLASS = Kotlin.Kind.CLASS;
  function Example() {
    Example$Companion_getInstance();
    println('Example constructor');
  }
  Example.prototype.exampleMethod = function () {
    println('Example method');
  };
  function Example$Companion() {
    Example$Companion_instance = this;
  }
  Example$Companion.prototype.exampleStaticMethod = function () {
    println('Example static method');
  };
  Example$Companion.$metadata$ = {
    kind: Kind_OBJECT,
    simpleName: 'Companion',
    interfaces: []
  };
  var Example$Companion_instance = null;
  function Example$Companion_getInstance() {
    if (Example$Companion_instance === null) {
      new Example$Companion();
    }
    return Example$Companion_instance;
  }
  Example.$metadata$ = {
    kind: Kind_CLASS,
    simpleName: 'Example',
    interfaces: []
  };
  Object.defineProperty(Example, 'Companion', {
    get: Example$Companion_getInstance
  });
  var package$net = <http://_.net|_.net> || (<http://_.net|_.net> = {});
  var package$aliceintokyo = package$net.aliceintokyo || (package$net.aliceintokyo = {});
  package$aliceintokyo.Example = Example;
  Kotlin.defineModule('output', _);
  return _;
}(module.exports, require('kotlin')));

//# sourceMappingURL=output.js.map
So now I want it to use in node js project. When I created simple nodeje module, installed it and I called
Copy code
var simple = require("simple");
console.log(simple)
I got printed:
Copy code
[object Module]
When I did same with example, I got no error, but:
Copy code
[object Object]
What am I doing wrong? How to require compiled kotlinjs?
Actually, this works. Need to check original project