Is there a way to change the name of the JS module...
# javascript
a
Is there a way to change the name of the JS module generated by Kotlin? For example, if I'd like to prefix it with a scope (https://docs.npmjs.com/misc/scope)?
a
Normally changing the
outputFile
is enough. That obviously won't work with scopes
Hm..
I don't think there is convenient way to declare a scope's module at the moment.
I don't think I'll be able to verify this today, but as far as I remember there are 4 places where module names are used.
The filename. Doesn't take much to change
The string passed to
Kotlin.defineModule
. When some other module depends on this one the inliner uses this as a hint to make sure is looking at the correct module.
The
require
calls. Also top-level `var`'s in case of plain and UMD module kinds. Those are the dependencies.
And the last one is the string in the
meta.js
file. That one is used by the compiler. That is how the compiler will think your module is named. That's also what will be passed to
require
So in order to make is all perfect you can try to change the last 3 to
@scope/name
format.
If you are only using the compiler js code from JS you don't have to change anything at all - it'll work as is
Also could you file an issue about the inability to define scope'd npm packages here: https://youtrack.jetbrains.com/issues
a
Thanks for the info! I just wanted to make sure that it was actually not possible before filing an issue 🙂
a
Thanks)
a
a
Thanks