Kotlin JS AMD generating extra `exports` dependency


#1

Hi, I’m seeing some weird behavior with exports and _.

Basically my initial generated JS looks something like this:

define(['exports', 'kotlin'], function (_, Kotlin) {
  'use strict';
  var defineInlineFunction = Kotlin.defineInlineFunction;
  function main(args) {
  }
  _.main_kand9s$ = main;
  main([]);
  Kotlin.defineModule('my-module', _);
  return _;
});

But when I plumb it through rollup (in amd mode), it produces this:

var app = (function (Kotlin) {
  'use strict';

  Kotlin = Kotlin && Kotlin.hasOwnProperty('default') ? Kotlin['default'] : Kotlin;

  var defineInlineFunction = Kotlin.defineInlineFunction;
  function main(args) {
  }
  _.main_kand9s$ = main;

  return _;

}(kotlin));

Which doesn’t work because _ isn’t defined.

What’s going on? Is this a KotlinJS bug or a Rollup bug? Or something I’m doing wrong?