-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Labels
Description
Hi there,
Context: I'm writing Kotlin JS, which generates a AMD-style JS module, which then gets plumbed through Rollup using rollup-plugin-amd, which in turn depends on...this.
The JS Kotlin generates initially looks 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 _;
});After trickling through the build process, the final output JS is 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 looks fine-ish, except for one problem -- it's assuming there's a _ global when there is none. This causes JS errors when loading the page. As an immediate workaround, I'll create a "_" object on the page to absorb exports, but that seems odd to me. Thoughts?
Thanks!
Reactions are currently unavailable